Merge pull request #2360 from RyanDwyer/floating-containers

Allow containers to float
This commit is contained in:
Drew DeVault 2018-07-28 09:30:12 -04:00 committed by GitHub
commit 53069f1403
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 218 additions and 113 deletions

View file

@ -437,18 +437,22 @@ static void dispatch_cursor_button_floating(struct sway_cursor *cursor,
seat_pointer_notify_button(seat, time_msec, button, state);
return;
}
struct sway_container *floater = cont;
while (floater->parent->layout != L_FLOATING) {
floater = floater->parent;
}
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->wlr_seat);
bool mod_pressed = keyboard &&
(wlr_keyboard_get_modifiers(keyboard) & config->floating_mod);
enum wlr_edges edge = find_resize_edge(cont, cursor);
enum wlr_edges edge = find_resize_edge(floater, cursor);
bool over_title = edge == WLR_EDGE_NONE && !surface;
// Check for beginning move
uint32_t btn_move = config->floating_mod_inverse ? BTN_RIGHT : BTN_LEFT;
if (button == btn_move && state == WLR_BUTTON_PRESSED &&
(mod_pressed || over_title)) {
seat_begin_move(seat, cont, button);
seat_begin_move(seat, floater, button);
return;
}
@ -459,12 +463,12 @@ static void dispatch_cursor_button_floating(struct sway_cursor *cursor,
if ((resizing_via_border || resizing_via_mod) &&
state == WLR_BUTTON_PRESSED) {
if (edge == WLR_EDGE_NONE) {
edge |= cursor->cursor->x > cont->x + cont->width / 2 ?
edge |= cursor->cursor->x > floater->x + floater->width / 2 ?
WLR_EDGE_RIGHT : WLR_EDGE_LEFT;
edge |= cursor->cursor->y > cont->y + cont->height / 2 ?
edge |= cursor->cursor->y > floater->y + floater->height / 2 ?
WLR_EDGE_BOTTOM : WLR_EDGE_TOP;
}
seat_begin_resize(seat, cont, button, edge);
seat_begin_resize(seat, floater, button, edge);
return;
}
@ -598,7 +602,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
seat_set_focus_layer(cursor->seat, layer);
}
seat_pointer_notify_button(cursor->seat, time_msec, button, state);
} else if (cont && container_is_floating(cont)) {
} else if (cont && container_is_floating_or_child(cont)) {
dispatch_cursor_button_floating(cursor, time_msec, button, state,
surface, sx, sy, cont);
} else if (surface && cont && cont->type != C_VIEW) {

View file

@ -125,12 +125,14 @@ static void seat_send_focus(struct sway_container *con,
}
static struct sway_container *seat_get_focus_by_type(struct sway_seat *seat,
struct sway_container *container, enum sway_container_type type) {
struct sway_container *container, enum sway_container_type type,
bool only_tiling) {
if (container->type == C_VIEW) {
return container;
}
struct sway_container *floating = container->type == C_WORKSPACE ?
struct sway_container *floating =
container->type == C_WORKSPACE && !only_tiling ?
container->sway_workspace->floating : NULL;
if (container->children->length == 0 &&
(!floating || floating->children->length == 0)) {
@ -144,6 +146,10 @@ static struct sway_container *seat_get_focus_by_type(struct sway_seat *seat,
}
if (container_has_child(container, current->container)) {
if (only_tiling &&
container_is_floating_or_child(current->container)) {
continue;
}
return current->container;
}
if (floating && container_has_child(floating, current->container)) {
@ -170,7 +176,7 @@ void seat_focus_inactive_children_for_each(struct sway_seat *seat,
struct sway_container *seat_get_focus_inactive_view(struct sway_seat *seat,
struct sway_container *container) {
return seat_get_focus_by_type(seat, container, C_VIEW);
return seat_get_focus_by_type(seat, container, C_VIEW, false);
}
static void handle_seat_container_destroy(struct wl_listener *listener,
@ -185,7 +191,6 @@ static void handle_seat_container_destroy(struct wl_listener *listener,
bool set_focus =
focus != NULL &&
(focus == con || container_has_child(con, focus)) &&
con->parent && con->parent->children->length > 1 &&
con->type != C_WORKSPACE;
seat_container_destroy(seat_con);
@ -193,7 +198,7 @@ static void handle_seat_container_destroy(struct wl_listener *listener,
if (set_focus) {
struct sway_container *next_focus = NULL;
while (next_focus == NULL) {
next_focus = seat_get_focus_by_type(seat, parent, C_VIEW);
next_focus = seat_get_focus_by_type(seat, parent, C_VIEW, false);
if (next_focus == NULL && parent->type == C_WORKSPACE) {
next_focus = parent;
@ -650,7 +655,7 @@ void seat_set_focus_warp(struct sway_seat *seat,
struct sway_container *new_output_last_ws = NULL;
if (last_output && new_output && last_output != new_output) {
new_output_last_ws =
seat_get_focus_by_type(seat, new_output, C_WORKSPACE);
seat_get_focus_by_type(seat, new_output, C_WORKSPACE, false);
}
if (container && container->parent) {
@ -761,10 +766,6 @@ void seat_set_focus_warp(struct sway_seat *seat,
}
}
if (last_focus != NULL) {
cursor_send_pointer_motion(seat->cursor, 0, true);
}
seat->has_focus = (container != NULL);
update_debug_tree();
@ -865,7 +866,12 @@ void seat_set_exclusive_client(struct sway_seat *seat,
struct sway_container *seat_get_focus_inactive(struct sway_seat *seat,
struct sway_container *container) {
return seat_get_focus_by_type(seat, container, C_TYPES);
return seat_get_focus_by_type(seat, container, C_TYPES, false);
}
struct sway_container *seat_get_focus_inactive_tiling(struct sway_seat *seat,
struct sway_container *container) {
return seat_get_focus_by_type(seat, container, C_TYPES, true);
}
struct sway_container *seat_get_active_child(struct sway_seat *seat,