aboutsummaryrefslogtreecommitdiffstats
path: root/sway/container.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/container.c')
-rw-r--r--sway/container.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/sway/container.c b/sway/container.c
index cd7c9b13..8dc2c825 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -9,7 +9,7 @@
9#include "log.h" 9#include "log.h"
10 10
11#define ASSERT_NONNULL(PTR) \ 11#define ASSERT_NONNULL(PTR) \
12 sway_assert (PTR, "%s: " #PTR "must be non-null", __func__) 12 sway_assert (PTR, #PTR "must be non-null")
13 13
14static swayc_t *new_swayc(enum swayc_types type) { 14static swayc_t *new_swayc(enum swayc_types type) {
15 swayc_t *c = calloc(1, sizeof(swayc_t)); 15 swayc_t *c = calloc(1, sizeof(swayc_t));
@@ -305,7 +305,7 @@ swayc_t *destroy_workspace(swayc_t *workspace) {
305 305
306 // Do not destroy if there are children 306 // Do not destroy if there are children
307 if (workspace->children->length == 0 && workspace->floating->length == 0) { 307 if (workspace->children->length == 0 && workspace->floating->length == 0) {
308 sway_log(L_DEBUG, "%s: '%s'", __func__, workspace->name); 308 sway_log(L_DEBUG, "'%s'", workspace->name);
309 swayc_t *parent = workspace->parent; 309 swayc_t *parent = workspace->parent;
310 free_swayc(workspace); 310 free_swayc(workspace);
311 return parent; 311 return parent;
@@ -376,7 +376,7 @@ swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types type) {
376 if (!ASSERT_NONNULL(container)) { 376 if (!ASSERT_NONNULL(container)) {
377 return NULL; 377 return NULL;
378 } 378 }
379 if (!sway_assert(type < C_TYPES && type >= C_ROOT, "%s: invalid type", __func__)) { 379 if (!sway_assert(type < C_TYPES && type >= C_ROOT, "invalid type")) {
380 return NULL; 380 return NULL;
381 } 381 }
382 do { 382 do {
@@ -389,7 +389,7 @@ swayc_t *swayc_parent_by_layout(swayc_t *container, enum swayc_layouts layout) {
389 if (!ASSERT_NONNULL(container)) { 389 if (!ASSERT_NONNULL(container)) {
390 return NULL; 390 return NULL;
391 } 391 }
392 if (!sway_assert(layout < L_LAYOUTS && layout >= L_NONE, "%s: invalid layout", __func__)) { 392 if (!sway_assert(layout < L_LAYOUTS && layout >= L_NONE, "invalid layout")) {
393 return NULL; 393 return NULL;
394 } 394 }
395 do { 395 do {
@@ -402,7 +402,7 @@ swayc_t *swayc_focus_by_type(swayc_t *container, enum swayc_types type) {
402 if (!ASSERT_NONNULL(container)) { 402 if (!ASSERT_NONNULL(container)) {
403 return NULL; 403 return NULL;
404 } 404 }
405 if (!sway_assert(type < C_TYPES && type >= C_ROOT, "%s: invalid type", __func__)) { 405 if (!sway_assert(type < C_TYPES && type >= C_ROOT, "invalid type")) {
406 return NULL; 406 return NULL;
407 } 407 }
408 do { 408 do {
@@ -410,11 +410,12 @@ swayc_t *swayc_focus_by_type(swayc_t *container, enum swayc_types type) {
410 } while (container && container->type != type); 410 } while (container && container->type != type);
411 return container; 411 return container;
412} 412}
413
413swayc_t *swayc_focus_by_layout(swayc_t *container, enum swayc_layouts layout) { 414swayc_t *swayc_focus_by_layout(swayc_t *container, enum swayc_layouts layout) {
414 if (!ASSERT_NONNULL(container)) { 415 if (!ASSERT_NONNULL(container)) {
415 return NULL; 416 return NULL;
416 } 417 }
417 if (!sway_assert(layout < L_LAYOUTS && layout >= L_NONE, "%s: invalid layout", __func__)) { 418 if (!sway_assert(layout < L_LAYOUTS && layout >= L_NONE, "invalid layout")) {
418 return NULL; 419 return NULL;
419 } 420 }
420 do { 421 do {
@@ -494,6 +495,10 @@ bool swayc_is_fullscreen(swayc_t *view) {
494 return view && view->type == C_VIEW && (wlc_view_get_state(view->handle) & WLC_BIT_FULLSCREEN); 495 return view && view->type == C_VIEW && (wlc_view_get_state(view->handle) & WLC_BIT_FULLSCREEN);
495} 496}
496 497
498bool swayc_is_active(swayc_t *view) {
499 return view && view->type == C_VIEW && (wlc_view_get_state(view->handle) & WLC_BIT_ACTIVATED);
500}
501
497// Mapping 502// Mapping
498 503
499void container_map(swayc_t *container, void (*f)(swayc_t *view, void *data), void *data) { 504void container_map(swayc_t *container, void (*f)(swayc_t *view, void *data), void *data) {
@@ -536,6 +541,7 @@ void set_view_visibility(swayc_t *view, void *data) {
536 541
537void update_visibility(swayc_t *container) { 542void update_visibility(swayc_t *container) {
538 swayc_t *ws = swayc_active_workspace_for(container); 543 swayc_t *ws = swayc_active_workspace_for(container);
544 // TODO better visibility setting
539 bool visible = (ws->parent->focused == ws); 545 bool visible = (ws->parent->focused == ws);
540 sway_log(L_DEBUG, "Setting visibility of container %p to %s", container, visible ? "visible" : "invisible"); 546 sway_log(L_DEBUG, "Setting visibility of container %p to %s", container, visible ? "visible" : "invisible");
541 container_map(ws, set_view_visibility, &visible); 547 container_map(ws, set_view_visibility, &visible);