aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2015-08-25 16:39:16 -0400
committerDrew DeVault <sir@cmpwn.com>2015-08-25 16:39:16 -0400
commit77dcf70a9b9037f7582718c37b4dff04324d8c7a (patch)
tree3099d9e4b4f1b2491bfc0e93d9976e4e8161fd89 /sway
parent0bf380a0b1a83f49e2e33066ab6504d308dcec89 (diff)
parent225c2fbe5b9219fd848c2d6d11cadef9ef1b42f0 (diff)
Merge pull request #132 from taiyu-len/master
fixed segfault on exit + a little fixup of that floatfocus pr
Diffstat (limited to 'sway')
-rw-r--r--sway/container.c2
-rw-r--r--sway/focus.c25
-rw-r--r--sway/handlers.c9
-rw-r--r--sway/layout.c4
4 files changed, 23 insertions, 17 deletions
diff --git a/sway/container.c b/sway/container.c
index 6fbfa360..cd7c9b13 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -477,7 +477,7 @@ swayc_t *swayc_active_workspace_for(swayc_t *cont) {
/* Fallthrough */
case C_OUTPUT:
- cont = cont->focused;
+ cont = cont ? cont->focused : NULL;
/* Fallthrough */
case C_WORKSPACE:
diff --git a/sway/focus.c b/sway/focus.c
index 1086f1a8..f7b55b27 100644
--- a/sway/focus.c
+++ b/sway/focus.c
@@ -164,14 +164,25 @@ void set_focused_container_for(swayc_t *a, swayc_t *c) {
}
swayc_t *get_focused_view(swayc_t *parent) {
- while (parent && parent->type != C_VIEW) {
- if (parent->type == C_WORKSPACE && parent->focused == NULL) {
- return parent;
+ swayc_t *c = parent;
+ while (c && c->type != C_VIEW) {
+ if (c->type == C_WORKSPACE && c->focused == NULL) {
+ return c;
}
- parent = parent->focused;
+ c = c->focused;
}
- if (parent == NULL) {
- return swayc_active_workspace_for(parent);
+ if (c == NULL) {
+ c = swayc_active_workspace_for(parent);
}
- return parent;
+ return c;
+}
+
+swayc_t *get_focused_float(swayc_t *ws) {
+ if(!sway_assert(ws->type == C_WORKSPACE, "must be of workspace type")) {
+ ws = swayc_active_workspace();
+ }
+ if (ws->floating->length) {
+ return ws->floating->items[ws->floating->length - 1];
+ }
+ return NULL;
}
diff --git a/sway/handlers.c b/sway/handlers.c
index 4d1dc56c..758af8d6 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -231,14 +231,7 @@ static void handle_view_destroyed(wlc_handle handle) {
break;
}
- swayc_t *focused_view = get_focused_view(&root_container);
- if (focused_view->type == C_WORKSPACE && focused_view->children->length == 0) {
- if (focused_view->floating->length > 0) {
- focused_view = focused_view->floating->items[focused_view->floating->length-1];
- focused_view = get_focused_view(focused_view);
- }
- }
- set_focused_container(focused_view);
+ set_focused_container(get_focused_view(&root_container));
}
static void handle_view_focus(wlc_handle view, bool focus) {
diff --git a/sway/layout.c b/sway/layout.c
index cd47037b..ed9479ab 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -151,7 +151,9 @@ swayc_t *remove_child(swayc_t *child) {
// Set focused to new container
if (parent->focused == child) {
if (parent->children->length > 0) {
- parent->focused = parent->children->items[i?i-1:0];
+ parent->focused = parent->children->items[i ? i-1:0];
+ } else if (parent->floating && parent->floating->length) {
+ parent->focused = parent->floating->items[parent->floating->length - 1];
} else {
parent->focused = NULL;
}