summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2015-08-16 22:11:33 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2015-08-16 22:11:33 -0400
commitcb504c8f7b0face15a29de5b3b9f12ffe8bc6848 (patch)
tree1351a85fa95badc95b0408387c90c366495c28ab
parentMerge pull request #52 from taiyu-len/master (diff)
parentfix (diff)
downloadsway-cb504c8f7b0face15a29de5b3b9f12ffe8bc6848.tar.gz
sway-cb504c8f7b0face15a29de5b3b9f12ffe8bc6848.tar.zst
sway-cb504c8f7b0face15a29de5b3b9f12ffe8bc6848.zip
Merge pull request #53 from taiyu-len/master
send_to_back/bring_to_front set when view changes visibility.
-rw-r--r--include/container.h3
-rw-r--r--include/layout.h1
-rw-r--r--sway/container.c12
-rw-r--r--sway/handlers.c2
-rw-r--r--sway/layout.c3
-rw-r--r--sway/workspace.c13
6 files changed, 20 insertions, 14 deletions
diff --git a/include/container.h b/include/container.h
index a54e016a..dd934be6 100644
--- a/include/container.h
+++ b/include/container.h
@@ -68,4 +68,7 @@ swayc_t *destroy_view(swayc_t *view);
68swayc_t *find_container(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data); 68swayc_t *find_container(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data);
69void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *); 69void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *);
70 70
71//Mappings
72void set_view_visibility(swayc_t *view, void *data);
73
71#endif 74#endif
diff --git a/include/layout.h b/include/layout.h
index 38a1f24b..a7f43fda 100644
--- a/include/layout.h
+++ b/include/layout.h
@@ -22,6 +22,7 @@ void arrange_windows(swayc_t *container, int width, int height);
22void unfocus_all(swayc_t *container); 22void unfocus_all(swayc_t *container);
23void focus_view(swayc_t *view); 23void focus_view(swayc_t *view);
24void focus_view_for(swayc_t *ancestor, swayc_t *container); 24void focus_view_for(swayc_t *ancestor, swayc_t *container);
25
25swayc_t *get_focused_container(swayc_t *parent); 26swayc_t *get_focused_container(swayc_t *parent);
26swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent); 27swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent);
27 28
diff --git a/sway/container.c b/sway/container.c
index 89958a4f..3cf9e47a 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -227,3 +227,15 @@ void container_map(swayc_t *container, void (*f)(swayc_t *view, void *data), voi
227 } 227 }
228} 228}
229 229
230void set_view_visibility(swayc_t *view, void *data) {
231 uint32_t *p = data;
232 if (view->type == C_VIEW) {
233 wlc_view_set_mask(view->handle, *p);
234 if (*p == 2) {
235 wlc_view_bring_to_front(view->handle);
236 } else {
237 wlc_view_send_to_back(view->handle);
238 }
239 }
240 view->visible = (*p == 2);
241}
diff --git a/sway/handlers.c b/sway/handlers.c
index 0e68a3c8..9ee4f3cb 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -238,8 +238,8 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier
238} 238}
239 239
240static bool handle_pointer_motion(wlc_handle view, uint32_t time, const struct wlc_origin *origin) { 240static bool handle_pointer_motion(wlc_handle view, uint32_t time, const struct wlc_origin *origin) {
241 static wlc_handle prev_view = 0;
241 mouse_origin = *origin; 242 mouse_origin = *origin;
242 static wlc_handle prev_view = -1;
243 if (config->focus_follows_mouse && prev_view != view) { 243 if (config->focus_follows_mouse && prev_view != view) {
244 focus_pointer(); 244 focus_pointer();
245 } 245 }
diff --git a/sway/layout.c b/sway/layout.c
index a6d6fcbb..4407742a 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -237,7 +237,7 @@ void unfocus_all(swayc_t *container) {
237} 237}
238 238
239void focus_view(swayc_t *view) { 239void focus_view(swayc_t *view) {
240 sway_log(L_DEBUG, "Setting focus for %p", view); 240 sway_log(L_DEBUG, "Setting focus for %p:%ld", view, view->handle);
241 swayc_t *c = view; 241 swayc_t *c = view;
242 //Set focus from root to view 242 //Set focus from root to view
243 while (c != &root_container) { 243 while (c != &root_container) {
@@ -272,4 +272,3 @@ void focus_view_for(swayc_t *top, swayc_t *view) {
272 } 272 }
273} 273}
274 274
275
diff --git a/sway/workspace.c b/sway/workspace.c
index a3238da6..9bc3215f 100644
--- a/sway/workspace.c
+++ b/sway/workspace.c
@@ -80,15 +80,6 @@ bool workspace_by_name(swayc_t *view, void *data) {
80 (strcasecmp(view->name, (char *) data) == 0); 80 (strcasecmp(view->name, (char *) data) == 0);
81} 81}
82 82
83void set_mask(swayc_t *view, void *data) {
84 uint32_t *p = data;
85
86 if (view->type == C_VIEW) {
87 wlc_view_set_mask(view->handle, *p);
88 }
89 view->visible = (*p == 2);
90}
91
92swayc_t *workspace_find_by_name(const char* name) { 83swayc_t *workspace_find_by_name(const char* name) {
93 return find_container(&root_container, workspace_by_name, (void *) name); 84 return find_container(&root_container, workspace_by_name, (void *) name);
94} 85}
@@ -194,9 +185,9 @@ void workspace_switch(swayc_t *workspace) {
194 185
195 // set all c_views in the old workspace to the invisible mask if the workspace 186 // set all c_views in the old workspace to the invisible mask if the workspace
196 // is in the same output & c_views in the new workspace to the visible mask 187 // is in the same output & c_views in the new workspace to the visible mask
197 container_map(focused_workspace, set_mask, &mask); 188 container_map(focused_workspace, set_view_visibility, &mask);
198 mask = 2; 189 mask = 2;
199 container_map(workspace, set_mask, &mask); 190 container_map(workspace, set_view_visibility, &mask);
200 wlc_output_set_mask(ws_output->handle, 2); 191 wlc_output_set_mask(ws_output->handle, 2);
201 192
202 destroy_workspace(focused_workspace); 193 destroy_workspace(focused_workspace);