From 8ca0427a879085b3380b6ed4d50c059f4589b5c7 Mon Sep 17 00:00:00 2001 From: chayleaf <chayleaf-git@pavluk.org> Date: Fri, 23 Aug 2024 05:34:58 +0700 Subject: [PATCH 4/4] mobile: dont occupy exclusive layers with fullscreen --- sway/tree/container.c | 4 ++-- sway/tree/view.c | 43 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/sway/tree/container.c b/sway/tree/container.c index 62bff1ea..6cfbc27a 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -1235,7 +1235,7 @@ static void container_fullscreen_workspace(struct sway_container *con) { con->saved_height = con->pending.height; if (con->pending.workspace) { - con->pending.workspace->fullscreen = con; + // con->pending.workspace->fullscreen = con; struct sway_seat *seat; struct sway_workspace *focus_ws; wl_list_for_each(seat, &server.input->seats, link) { @@ -1262,7 +1262,7 @@ static void container_fullscreen_global(struct sway_container *con) { } set_fullscreen(con, true); - root->fullscreen_global = con; + // root->fullscreen_global = con; con->saved_x = con->pending.x; con->saved_y = con->pending.y; con->saved_width = con->pending.width; diff --git a/sway/tree/view.c b/sway/tree/view.c index ebf98faa..85adc608 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -35,6 +35,7 @@ #include "sway/config.h" #include "sway/xdg_decoration.h" #include "stringop.h" +#include "sway/layers.h" bool view_init(struct sway_view *view, enum sway_view_type type, const struct sway_view_impl *impl) { @@ -250,6 +251,18 @@ static bool gaps_to_edge(struct sway_view *view) { return gaps.top > 0 || gaps.right > 0 || gaps.bottom > 0 || gaps.left > 0; } +void calculate_exclusive(struct sway_view *view, struct wlr_box *usable_area) { + struct wlr_surface *surface = view->surface; + if (!surface) return; + struct wlr_layer_surface_v1 *layer_surface = wlr_layer_surface_v1_try_from_wlr_surface(surface); + if (!layer_surface) return; + struct wlr_layer_surface_v1_state *state = &layer_surface->current; + usable_area->y += state->margin.top; + usable_area->height -= state->margin.top + state->margin.bottom; + usable_area->x += state->margin.left; + usable_area->width -= state->margin.left + state->margin.right; +} + void view_autoconfigure(struct sway_view *view) { struct sway_container *con = view->container; struct sway_workspace *ws = con->pending.workspace; @@ -261,16 +274,30 @@ void view_autoconfigure(struct sway_view *view) { struct sway_output *output = ws ? ws->output : NULL; if (con->pending.fullscreen_mode == FULLSCREEN_WORKSPACE) { - con->pending.content_x = output->lx; - con->pending.content_y = output->ly; - con->pending.content_width = output->width; - con->pending.content_height = output->height; + struct wlr_box box = { + .x = output->lx, + .y = output->ly, + .width = output->width, + .height = output->height, + }; + calculate_exclusive(view, &box); + con->pending.content_x = box.x; + con->pending.content_y = box.y; + con->pending.content_width = box.width; + con->pending.content_height = box.height; return; } else if (con->pending.fullscreen_mode == FULLSCREEN_GLOBAL) { - con->pending.content_x = root->x; - con->pending.content_y = root->y; - con->pending.content_width = root->width; - con->pending.content_height = root->height; + struct wlr_box box = { + .x = root->x, + .y = root->y, + .width = root->width, + .height = root->height, + }; + calculate_exclusive(view, &box); + con->pending.content_x = box.x; + con->pending.content_y = box.y; + con->pending.content_width = box.width; + con->pending.content_height = box.height; return; } -- 2.45.2