fixed segfault on exit + a little fixup of that floatfocus pr
This commit is contained in:
parent
0bf380a0b1
commit
225c2fbe5b
|
@ -19,6 +19,7 @@ enum movement_direction {
|
||||||
|
|
||||||
swayc_t *get_focused_container(swayc_t *parent);
|
swayc_t *get_focused_container(swayc_t *parent);
|
||||||
swayc_t *get_focused_view(swayc_t *parent);
|
swayc_t *get_focused_view(swayc_t *parent);
|
||||||
|
swayc_t *get_focused_float(swayc_t *ws);
|
||||||
|
|
||||||
void set_focused_container(swayc_t *container);
|
void set_focused_container(swayc_t *container);
|
||||||
void set_focused_container_for(swayc_t *ancestor, swayc_t *container);
|
void set_focused_container_for(swayc_t *ancestor, swayc_t *container);
|
||||||
|
|
|
@ -477,7 +477,7 @@ swayc_t *swayc_active_workspace_for(swayc_t *cont) {
|
||||||
/* Fallthrough */
|
/* Fallthrough */
|
||||||
|
|
||||||
case C_OUTPUT:
|
case C_OUTPUT:
|
||||||
cont = cont->focused;
|
cont = cont ? cont->focused : NULL;
|
||||||
/* Fallthrough */
|
/* Fallthrough */
|
||||||
|
|
||||||
case C_WORKSPACE:
|
case C_WORKSPACE:
|
||||||
|
|
25
sway/focus.c
25
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) {
|
swayc_t *get_focused_view(swayc_t *parent) {
|
||||||
while (parent && parent->type != C_VIEW) {
|
swayc_t *c = parent;
|
||||||
if (parent->type == C_WORKSPACE && parent->focused == NULL) {
|
while (c && c->type != C_VIEW) {
|
||||||
return parent;
|
if (c->type == C_WORKSPACE && c->focused == NULL) {
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
parent = parent->focused;
|
c = c->focused;
|
||||||
}
|
}
|
||||||
if (parent == NULL) {
|
if (c == NULL) {
|
||||||
return swayc_active_workspace_for(parent);
|
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,14 +231,7 @@ static void handle_view_destroyed(wlc_handle handle) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
swayc_t *focused_view = get_focused_view(&root_container);
|
set_focused_container(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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_view_focus(wlc_handle view, bool focus) {
|
static void handle_view_focus(wlc_handle view, bool focus) {
|
||||||
|
|
|
@ -151,7 +151,9 @@ swayc_t *remove_child(swayc_t *child) {
|
||||||
// Set focused to new container
|
// Set focused to new container
|
||||||
if (parent->focused == child) {
|
if (parent->focused == child) {
|
||||||
if (parent->children->length > 0) {
|
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 {
|
} else {
|
||||||
parent->focused = NULL;
|
parent->focused = NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue