Replace hacky L_FLOATING container with a list

Workspaces previously had a magical `workspace->floating` container,
which had a layout of L_FLOATING and whose children were actual floating
views. This allowed some conveniences, but was a hacky solution because
the container has to be exempt from focus, coordinate transactions with
the workspace, and omit emitting IPC events (which we didn't do).

This commit changes it to be a list directly in the sway_workspace. The
L_FLOATING layout is no longer used so this has been removed as well.

* Fixes incorrect check in the swap command (it checked if the
containers had the L_FLOATING layout, but this layout applied to the
magical container).
* Introduces workspace_add_floating
This commit is contained in:
Ryan Dwyer 2018-08-19 15:07:07 +10:00
parent 389d159c81
commit 2b5a404ac9
20 changed files with 109 additions and 136 deletions

View file

@ -724,7 +724,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
uint32_t btn_move = config->floating_mod_inverse ? BTN_RIGHT : BTN_LEFT;
if (button == btn_move && state == WLR_BUTTON_PRESSED &&
(mod_pressed || on_titlebar)) {
while (cont->parent->layout != L_FLOATING) {
while (cont->parent->type != C_WORKSPACE) {
cont = cont->parent;
}
seat_begin_move(seat, cont, button);
@ -746,7 +746,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
BTN_LEFT : BTN_RIGHT;
if (mod_pressed && button == btn_resize) {
struct sway_container *floater = cont;
while (floater->parent->layout != L_FLOATING) {
while (floater->parent->type != C_WORKSPACE) {
floater = floater->parent;
}
edge = 0;

View file

@ -688,7 +688,8 @@ void seat_set_focus_warp(struct sway_seat *seat,
// If we've focused a floating container, bring it to the front.
// We do this by putting it at the end of the floating list.
if (container && container_is_floating(container)) {
list_move_to_end(container->parent->children, container);
list_move_to_end(
container->parent->sway_workspace->floating, container);
}
// clean up unfocused empty workspace on new output
@ -850,7 +851,7 @@ void seat_set_exclusive_client(struct sway_seat *seat,
struct sway_container *seat_get_focus_inactive(struct sway_seat *seat,
struct sway_container *con) {
if (con->type == C_WORKSPACE && !con->children->length &&
!con->sway_workspace->floating->children->length) {
!con->sway_workspace->floating->length) {
return con;
}
if (con->type == C_VIEW) {
@ -873,7 +874,7 @@ struct sway_container *seat_get_focus_inactive_tiling(struct sway_seat *seat,
struct sway_seat_container *current;
wl_list_for_each(current, &seat->focus_stack, link) {
struct sway_container *con = current->container;
if (con->layout != L_FLOATING && !container_is_floating_or_child(con) &&
if (!container_is_floating_or_child(con) &&
container_has_ancestor(current->container, ancestor)) {
return con;
}
@ -884,13 +885,13 @@ struct sway_container *seat_get_focus_inactive_tiling(struct sway_seat *seat,
struct sway_container *seat_get_focus_inactive_floating(struct sway_seat *seat,
struct sway_container *ancestor) {
if (ancestor->type == C_WORKSPACE &&
!ancestor->sway_workspace->floating->children->length) {
!ancestor->sway_workspace->floating->length) {
return NULL;
}
struct sway_seat_container *current;
wl_list_for_each(current, &seat->focus_stack, link) {
struct sway_container *con = current->container;
if (con->layout != L_FLOATING && container_is_floating_or_child(con) &&
if (container_is_floating_or_child(con) &&
container_has_ancestor(current->container, ancestor)) {
return con;
}
@ -898,11 +899,6 @@ struct sway_container *seat_get_focus_inactive_floating(struct sway_seat *seat,
return NULL;
}
static bool impl_focus_active_child(struct sway_container *con, void *data) {
struct sway_container *parent = data;
return con->parent == parent && con->layout != L_FLOATING;
}
struct sway_container *seat_get_active_child(struct sway_seat *seat,
struct sway_container *parent) {
if (parent->type == C_VIEW) {
@ -911,7 +907,7 @@ struct sway_container *seat_get_active_child(struct sway_seat *seat,
struct sway_seat_container *current;
wl_list_for_each(current, &seat->focus_stack, link) {
struct sway_container *con = current->container;
if (con->parent == parent && con->layout != L_FLOATING) {
if (con->parent == parent) {
return con;
}
}