From 40772387829736f5a73bc4f97968b2e44b28a333 Mon Sep 17 00:00:00 2001 From: taiyu Date: Sun, 16 Aug 2015 18:59:12 -0700 Subject: [PATCH 1/2] sends hidden views to back, visible view to front --- sway/handlers.c | 2 +- sway/layout.c | 2 +- sway/workspace.c | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) 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 } static bool handle_pointer_motion(wlc_handle view, uint32_t time, const struct wlc_origin *origin) { + static wlc_handle prev_view = 0; mouse_origin = *origin; - static wlc_handle prev_view = -1; if (config->focus_follows_mouse && prev_view != view) { focus_pointer(); } diff --git a/sway/layout.c b/sway/layout.c index a6d6fcbb..963bd8dc 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -237,7 +237,7 @@ void unfocus_all(swayc_t *container) { } void focus_view(swayc_t *view) { - sway_log(L_DEBUG, "Setting focus for %p", view); + sway_log(L_DEBUG, "Setting focus for %p:%ld", view, view->handle); swayc_t *c = view; //Set focus from root to view while (c != &root_container) { diff --git a/sway/workspace.c b/sway/workspace.c index a3238da6..15828658 100644 --- a/sway/workspace.c +++ b/sway/workspace.c @@ -82,10 +82,14 @@ bool workspace_by_name(swayc_t *view, void *data) { void set_mask(swayc_t *view, void *data) { uint32_t *p = data; - if (view->type == C_VIEW) { wlc_view_set_mask(view->handle, *p); } + if (*p == 2) { + wlc_view_bring_to_front(view->handle); + } else { + wlc_view_send_to_back(view->handle); + } view->visible = (*p == 2); } From f1d5305dc61944deebbab2322118d7a1a15b998e Mon Sep 17 00:00:00 2001 From: taiyu Date: Sun, 16 Aug 2015 19:06:31 -0700 Subject: [PATCH 2/2] fix --- include/container.h | 3 +++ include/layout.h | 1 + sway/container.c | 12 ++++++++++++ sway/layout.c | 1 - sway/workspace.c | 17 ++--------------- 5 files changed, 18 insertions(+), 16 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); swayc_t *find_container(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data); void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *); +//Mappings +void set_view_visibility(swayc_t *view, void *data); + #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); void unfocus_all(swayc_t *container); void focus_view(swayc_t *view); void focus_view_for(swayc_t *ancestor, swayc_t *container); + swayc_t *get_focused_container(swayc_t *parent); swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent); 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 } } +void set_view_visibility(swayc_t *view, void *data) { + uint32_t *p = data; + if (view->type == C_VIEW) { + wlc_view_set_mask(view->handle, *p); + if (*p == 2) { + wlc_view_bring_to_front(view->handle); + } else { + wlc_view_send_to_back(view->handle); + } + } + view->visible = (*p == 2); +} diff --git a/sway/layout.c b/sway/layout.c index 963bd8dc..4407742a 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -272,4 +272,3 @@ void focus_view_for(swayc_t *top, swayc_t *view) { } } - diff --git a/sway/workspace.c b/sway/workspace.c index 15828658..9bc3215f 100644 --- a/sway/workspace.c +++ b/sway/workspace.c @@ -80,19 +80,6 @@ bool workspace_by_name(swayc_t *view, void *data) { (strcasecmp(view->name, (char *) data) == 0); } -void set_mask(swayc_t *view, void *data) { - uint32_t *p = data; - if (view->type == C_VIEW) { - wlc_view_set_mask(view->handle, *p); - } - if (*p == 2) { - wlc_view_bring_to_front(view->handle); - } else { - wlc_view_send_to_back(view->handle); - } - view->visible = (*p == 2); -} - swayc_t *workspace_find_by_name(const char* name) { return find_container(&root_container, workspace_by_name, (void *) name); } @@ -198,9 +185,9 @@ void workspace_switch(swayc_t *workspace) { // set all c_views in the old workspace to the invisible mask if the workspace // is in the same output & c_views in the new workspace to the visible mask - container_map(focused_workspace, set_mask, &mask); + container_map(focused_workspace, set_view_visibility, &mask); mask = 2; - container_map(workspace, set_mask, &mask); + container_map(workspace, set_view_visibility, &mask); wlc_output_set_mask(ws_output->handle, 2); destroy_workspace(focused_workspace);