From 4af49202c73dc3984eb2902f76479889cf8fb71d Mon Sep 17 00:00:00 2001 From: taiyu Date: Thu, 20 Aug 2015 19:24:07 -0700 Subject: [PATCH] floating bug fix --- sway/container.c | 5 ++++- sway/focus.c | 5 ++++- sway/layout.c | 9 +++++---- sway/workspace.c | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/sway/container.c b/sway/container.c index 3d0c7f5f8..f92612164 100644 --- a/sway/container.c +++ b/sway/container.c @@ -107,9 +107,12 @@ swayc_t *new_output(wlc_handle handle) { // create and initilize default workspace swayc_t *ws = new_workspace(output, ws_name); ws->is_focused = true; + if (!active_workspace) { + active_workspace = ws; + } free(ws_name); - + return output; } diff --git a/sway/focus.c b/sway/focus.c index 76e76a42b..6b2f8a7dc 100644 --- a/sway/focus.c +++ b/sway/focus.c @@ -86,7 +86,10 @@ void set_focused_container(swayc_t *c) { sway_log(L_DEBUG, "Setting focus to %p:%ld", c, c->handle); // 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 *workspace = c; + if (workspace->type != C_WORKSPACE) { + workspace = swayc_parent_by_type(c, C_WORKSPACE); + } swayc_t *focused = get_focused_view(workspace); if (active_workspace == workspace && swayc_is_fullscreen(focused)) { return; diff --git a/sway/layout.c b/sway/layout.c index f76ccd1df..33acbe6ac 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -37,7 +37,8 @@ void add_child(swayc_t *parent, swayc_t *child) { child->parent = parent; // set focus for this container if (parent->children->length == 1) { - set_focused_container_for(parent, child); + parent->focused = child; + set_focused_container_for(parent, get_focused_view(parent)); } } @@ -48,7 +49,7 @@ void add_floating(swayc_t *ws, swayc_t *child) { child->parent = ws; child->is_floating = true; if (!ws->focused) { - set_focused_container_for(ws, child); + ws->focused = child; } } @@ -73,7 +74,7 @@ swayc_t *replace_child(swayc_t *child, swayc_t *new_child) { new_child->parent = child->parent; if (child->parent->focused == child) { - set_focused_container_for(child->parent, new_child); + child->parent->focused = new_child; } child->parent = NULL; return parent; @@ -102,7 +103,7 @@ swayc_t *remove_child(swayc_t *child) { // Set focused to new container if (parent->focused == child) { if (parent->children->length > 0) { - set_focused_container_for(parent, parent->children->items[i?i-1:0]); + parent->focused = parent->children->items[i?i-1:0]; } else { parent->focused = NULL; } diff --git a/sway/workspace.c b/sway/workspace.c index d436da8e2..ce626de4a 100644 --- a/sway/workspace.c +++ b/sway/workspace.c @@ -182,5 +182,5 @@ void workspace_switch(swayc_t *workspace) { } sway_log(L_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name); set_focused_container(get_focused_view(workspace)); - arrange_windows(workspace, -1, -1); + arrange_windows(workspace->parent, -1, -1); }