From 2290db9bc3e1ce8ea7846ffeba3613f93122608f Mon Sep 17 00:00:00 2001 From: taiyu Date: Thu, 20 Aug 2015 18:42:36 -0700 Subject: [PATCH] focus change fix for fullscreen, prevent containers from being created on floating windows --- sway/commands.c | 4 ++++ sway/container.c | 2 +- sway/focus.c | 27 ++++++++++++++++----------- sway/handlers.c | 4 +--- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/sway/commands.c b/sway/commands.c index 08e7dca02..f9ff9d911 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -445,6 +445,9 @@ static bool _do_split(struct sway_config *config, int argc, char **argv, int lay } swayc_t *focused = get_focused_container(&root_container); + if (focused->is_floating) { + return true; + } if (focused->type == C_WORKSPACE && focused->children->length <= 1) { /* Case that focus is on an workspace with 0/1 children.change its layout */ sway_log(L_DEBUG, "changing workspace layout"); @@ -508,6 +511,7 @@ static bool cmd_fullscreen(struct sway_config *config, int argc, char **argv) { return false; } + //get focused view and check current state. swayc_t *container = get_focused_view(&root_container); bool current = swayc_is_fullscreen(container); wlc_view_set_state(container->handle, WLC_BIT_FULLSCREEN, !current); diff --git a/sway/container.c b/sway/container.c index e86f6a850..3d0c7f5f8 100644 --- a/sway/container.c +++ b/sway/container.c @@ -135,7 +135,7 @@ swayc_t *new_workspace(swayc_t *output, const char *name) { } swayc_t *new_container(swayc_t *child, enum swayc_layouts layout) { - if (!ASSERT_NONNULL(child)) { + if (!ASSERT_NONNULL(child) || child->is_floating) { return NULL; } swayc_t *cont = new_swayc(C_CONTAINER, 0); diff --git a/sway/focus.c b/sway/focus.c index b349f4fbd..be1476025 100644 --- a/sway/focus.c +++ b/sway/focus.c @@ -84,10 +84,13 @@ void set_focused_container(swayc_t *c) { return; } sway_log(L_DEBUG, "Setting focus to %p:%ld", c, c->handle); - - // Find previous focused view, and the new focused view, if they are the same return - swayc_t *focused = get_focused_view(&root_container); - swayc_t *workspace = active_workspace; + // Get workspace for c, get that workspaces current focused container. + // if that focsued container is fullscreen dont change focus + swayc_t *workspace = swayc_parent_by_type(c, C_WORKSPACE); + swayc_t *focused = get_focused_view(workspace); + if (swayc_is_fullscreen(focused)) { + return; + } // update container focus from here to root, making necessary changes along // the way @@ -101,13 +104,6 @@ void set_focused_container(swayc_t *c) { p->is_focused = false; } - // if the workspace is the same, and previous focus is fullscreen, dont - // change focus - sway_log(L_DEBUG,"%p==%p, f:%d", workspace, active_workspace, swayc_is_fullscreen(focused)); - if (workspace == active_workspace && swayc_is_fullscreen(focused)) { - return; - } - // get new focused view and set focus to it. p = get_focused_view(c); if (p->type == C_VIEW && !(wlc_view_get_type(p->handle) & WLC_BIT_POPUP)) { @@ -137,6 +133,15 @@ void set_focused_container_for(swayc_t *a, swayc_t *c) { return; } } + + // Get workspace for c, get that workspaces current focused container. + // if that focsued container is fullscreen dont change focus + swayc_t *workspace = swayc_parent_by_type(c, C_WORKSPACE); + swayc_t *focused = get_focused_view(workspace); + if (swayc_is_fullscreen(focused)) { + return; + } + // Check if we changing a parent container that will see chnage bool effective = true; while (find != &root_container) { diff --git a/sway/handlers.c b/sway/handlers.c index 4cbe8c472..6c4c195ba 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -420,9 +420,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct } } if (config->focus_follows_mouse && prev_handle != handle) { - // Dont change focus if fullscreen - swayc_t *focused = get_focused_view(view); - if (!swayc_is_fullscreen(focused) && !(pointer_state.l_held || pointer_state.r_held)) { + if (!(pointer_state.l_held || pointer_state.r_held)) { set_focused_container(container_under_pointer()); } }