diff options
author | minus <minus@mnus.de> | 2015-08-25 18:24:15 +0200 |
---|---|---|
committer | minus <minus@mnus.de> | 2015-08-25 18:24:15 +0200 |
commit | f22c9379530ebaacefcc337714cc2a5fe0db8902 (patch) | |
tree | d45200574d07c1522e3c83c378b4e5d1a66d4594 | |
parent | refactored workspace_next/prev (diff) | |
download | sway-f22c9379530ebaacefcc337714cc2a5fe0db8902.tar.gz sway-f22c9379530ebaacefcc337714cc2a5fe0db8902.tar.zst sway-f22c9379530ebaacefcc337714cc2a5fe0db8902.zip |
refactored view visibility
- replace visibilty mask integers with an enum
- set output's visibilty mask on creation
- added update_visibility to manually update a containers visibility (e.g. when it moved to an invisible workspace)
-rw-r--r-- | include/container.h | 8 | ||||
-rw-r--r-- | sway/container.c | 17 | ||||
-rw-r--r-- | sway/focus.c | 7 | ||||
-rw-r--r-- | sway/handlers.c | 3 |
4 files changed, 27 insertions, 8 deletions
diff --git a/include/container.h b/include/container.h index aadba5de..f684129a 100644 --- a/include/container.h +++ b/include/container.h | |||
@@ -56,6 +56,11 @@ struct sway_container { | |||
56 | struct sway_container *focused; | 56 | struct sway_container *focused; |
57 | }; | 57 | }; |
58 | 58 | ||
59 | enum view_visibility { | ||
60 | INVISIBLE = 1, | ||
61 | VISIBLE = 2 | ||
62 | }; | ||
63 | |||
59 | // Container Creation | 64 | // Container Creation |
60 | 65 | ||
61 | swayc_t *new_output(wlc_handle handle); | 66 | swayc_t *new_output(wlc_handle handle); |
@@ -106,4 +111,7 @@ void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *); | |||
106 | void set_view_visibility(swayc_t *view, void *data); | 111 | void set_view_visibility(swayc_t *view, void *data); |
107 | void reset_gaps(swayc_t *view, void *data); | 112 | void reset_gaps(swayc_t *view, void *data); |
108 | 113 | ||
114 | |||
115 | void update_visibility(swayc_t *container); | ||
116 | |||
109 | #endif | 117 | #endif |
diff --git a/sway/container.c b/sway/container.c index d23cef8f..666d6a2c 100644 --- a/sway/container.c +++ b/sway/container.c | |||
@@ -520,16 +520,25 @@ void set_view_visibility(swayc_t *view, void *data) { | |||
520 | if (!ASSERT_NONNULL(view)) { | 520 | if (!ASSERT_NONNULL(view)) { |
521 | return; | 521 | return; |
522 | } | 522 | } |
523 | uint32_t *p = data; | 523 | uint32_t mask = *(uint32_t *)data; |
524 | if (view->type == C_VIEW) { | 524 | if (view->type == C_VIEW) { |
525 | wlc_view_set_mask(view->handle, *p); | 525 | wlc_view_set_mask(view->handle, mask); |
526 | if (*p == 2) { | 526 | if (mask & VISIBLE) { |
527 | wlc_view_bring_to_front(view->handle); | 527 | wlc_view_bring_to_front(view->handle); |
528 | } else { | 528 | } else { |
529 | wlc_view_send_to_back(view->handle); | 529 | wlc_view_send_to_back(view->handle); |
530 | } | 530 | } |
531 | } | 531 | } |
532 | view->visible = (*p == 2); | 532 | view->visible = mask & VISIBLE; |
533 | sway_log(L_DEBUG, "Container %p is now %s", view, view->visible ? "visible" : "invisible"); | ||
534 | } | ||
535 | |||
536 | void update_visibility(swayc_t *container) { | ||
537 | swayc_t *ws = swayc_active_workspace_for(container); | ||
538 | bool visible = ws->parent->focused == container; | ||
539 | uint32_t mask = visible ? VISIBLE : INVISIBLE; | ||
540 | sway_log(L_DEBUG, "Setting visibility of container %p to %s", container, visible ? "visible" : "invisible"); | ||
541 | container_map(ws, set_view_visibility, &mask); | ||
533 | } | 542 | } |
534 | 543 | ||
535 | void reset_gaps(swayc_t *view, void *data) { | 544 | void reset_gaps(swayc_t *view, void *data) { |
diff --git a/sway/focus.c b/sway/focus.c index e369de30..823eefa2 100644 --- a/sway/focus.c +++ b/sway/focus.c | |||
@@ -28,12 +28,11 @@ static void update_focus(swayc_t *c) { | |||
28 | if (parent->focused) { | 28 | if (parent->focused) { |
29 | swayc_t *ws = parent->focused; | 29 | swayc_t *ws = parent->focused; |
30 | // hide visibility of old workspace | 30 | // hide visibility of old workspace |
31 | uint32_t mask = 1; | 31 | uint32_t mask = INVISIBLE; |
32 | container_map(ws, set_view_visibility, &mask); | 32 | container_map(ws, set_view_visibility, &mask); |
33 | // set visibility of new workspace | 33 | // set visibility of new workspace |
34 | mask = 2; | 34 | mask = VISIBLE; |
35 | container_map(c, set_view_visibility, &mask); | 35 | container_map(c, set_view_visibility, &mask); |
36 | wlc_output_set_mask(parent->handle, 2); | ||
37 | destroy_workspace(ws); | 36 | destroy_workspace(ws); |
38 | } | 37 | } |
39 | break; | 38 | break; |
@@ -45,8 +44,8 @@ static void update_focus(swayc_t *c) { | |||
45 | // for example, stacked and tabbing change stuff. | 44 | // for example, stacked and tabbing change stuff. |
46 | break; | 45 | break; |
47 | } | 46 | } |
47 | c->parent->focused = c; | ||
48 | } | 48 | } |
49 | c->parent->focused = c; | ||
50 | } | 49 | } |
51 | 50 | ||
52 | bool move_focus(enum movement_direction direction) { | 51 | bool move_focus(enum movement_direction direction) { |
diff --git a/sway/handlers.c b/sway/handlers.c index 3a4e31ae..8b3ae3c1 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -90,6 +90,9 @@ swayc_t *container_under_pointer(void) { | |||
90 | static bool handle_output_created(wlc_handle output) { | 90 | static bool handle_output_created(wlc_handle output) { |
91 | swayc_t *op = new_output(output); | 91 | swayc_t *op = new_output(output); |
92 | 92 | ||
93 | // Visibilty mask to be able to make view invisible | ||
94 | wlc_output_set_mask(output, VISIBLE); | ||
95 | |||
93 | if (!op) { | 96 | if (!op) { |
94 | return false; | 97 | return false; |
95 | } | 98 | } |