Implement floating

This commit is contained in:
Ryan Dwyer 2018-05-24 22:30:44 +10:00
parent 1132efe42e
commit 1f2e399ade
21 changed files with 572 additions and 169 deletions

View file

@ -108,6 +108,9 @@ static struct sway_container *container_at_coords(
}
struct sway_container *c;
if ((c = floating_container_at(x, y, surface, sx, sy))) {
return c;
}
if ((c = container_at(ws, ox, oy, surface, sx, sy))) {
return c;
}

View file

@ -113,7 +113,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) {
if (container->type == C_VIEW || container->children->length == 0) {
if (container->type == C_VIEW) {
return container;
}
struct sway_container *floating = container->type == C_WORKSPACE ?
container->sway_workspace->floating : NULL;
if (container->children->length == 0 &&
(!floating || floating->children->length == 0)) {
return container;
}
@ -126,6 +133,9 @@ static struct sway_container *seat_get_focus_by_type(struct sway_seat *seat,
if (container_has_child(container, current->container)) {
return current->container;
}
if (floating && container_has_child(floating, current->container)) {
return current->container;
}
}
return NULL;
@ -568,7 +578,7 @@ void seat_set_focus_warp(struct sway_seat *seat,
// clean up unfocused empty workspace on new output
if (new_output_last_ws) {
if (!workspace_is_visible(new_output_last_ws)
&& new_output_last_ws->children->length == 0) {
&& workspace_is_empty(new_output_last_ws)) {
if (last_workspace == new_output_last_ws) {
last_focus = NULL;
last_workspace = NULL;
@ -581,7 +591,7 @@ void seat_set_focus_warp(struct sway_seat *seat,
if (last_workspace) {
ipc_event_workspace(last_workspace, container, "focus");
if (!workspace_is_visible(last_workspace)
&& last_workspace->children->length == 0) {
&& workspace_is_empty(last_workspace)) {
if (last_workspace == last_focus) {
last_focus = NULL;
}