]> git.mdlowis.com Git - proto/labwc.git/commitdiff
layers: take into account usable area when maximizing views
authorJohan Malm <jgm323@gmail.com>
Mon, 12 Jul 2021 20:39:09 +0000 (21:39 +0100)
committerJohan Malm <jgm323@gmail.com>
Mon, 12 Jul 2021 20:39:09 +0000 (21:39 +0100)
include/labwc.h
src/layers.c
src/output.c
src/view.c

index c00dc3666451d786c4a80ae2f0159063fdda5476..c1cd528b7362879625da360be03f6e2f4a41c5d3 100644 (file)
@@ -133,6 +133,8 @@ struct output {
        struct wlr_output *wlr_output;
        struct wlr_output_damage *damage;
        struct wl_list layers[4];
+       struct wlr_box usable_area;
+
        struct wl_listener destroy;
        struct wl_listener damage_frame;
        struct wl_listener damage_destroy;
index e340dce7caef6eaa9b1f3aa914d282f7ec840a58..ed70685f330bcf819cab8ca70217f8fd969d8f46 100644 (file)
@@ -167,9 +167,9 @@ arrange_layer(struct wlr_output *output, struct wl_list *list,
 void
 arrange_layers(struct output *output)
 {
+       assert(output);
+
        struct wlr_box usable_area = { 0 };
-       if (!output)
-               return;
        wlr_output_effective_resolution(output->wlr_output,
                &usable_area.width, &usable_area.height);
 
@@ -186,6 +186,9 @@ arrange_layers(struct output *output)
        arrange_layer(output->wlr_output,
                        &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND],
                        &usable_area, true);
+       memcpy(&output->usable_area, &usable_area, sizeof(struct wlr_box));
+
+       /* TODO: re-arrange all views taking into account updated usable_area */
 
        /* Non-exclusive surfaces */
        arrange_layer(output->wlr_output,
index ab002f7ed7772c73cfaaff7298ff558a1d7d14e9..f56873dc30c8f9a0c910c70c1ef8f47349513962 100644 (file)
@@ -809,6 +809,8 @@ new_output_notify(struct wl_listener *listener, void *data)
        output->wlr_output = wlr_output;
        output->server = server;
        output->damage = wlr_output_damage_create(wlr_output);
+       wlr_output_effective_resolution(wlr_output,
+               &output->usable_area.width, &output->usable_area.height);
        wl_list_insert(&server->outputs, &output->link);
 
        output->destroy.notify = output_destroy_notify;
index 0f59e97918d44587150d49a84878a1bf631ec8fd..895dff74ff25a3584025b4e24677c623e717c211 100644 (file)
@@ -73,26 +73,24 @@ view_maximize(struct view *view, bool maximize)
        }
        view->impl->maximize(view, maximize);
        if (maximize) {
-               struct wlr_output *output = view_output(view);
-               if (!output) {
-                       return;
-               }
-
-               struct wlr_output_layout *layout = view->server->output_layout;
-               struct wlr_output_layout_output* ol_output =
-                       wlr_output_layout_get(layout, output);
-
                view->unmaximized_geometry.x = view->x;
                view->unmaximized_geometry.y = view->y;
                view->unmaximized_geometry.width = view->w;
                view->unmaximized_geometry.height = view->h;
 
-               struct wlr_box box = {
-                       .x = ol_output->x,
-                       .y = ol_output->y,
-                       .width = output->width,
-                       .height = output->height,
-               };
+               struct wlr_output *wlr_output = view_output(view);
+               struct output *output =
+                       output_from_wlr_output(view->server, wlr_output);
+
+               struct wlr_box box;
+               memcpy(&box, &output->usable_area, sizeof(struct wlr_box));
+
+               double ox = 0, oy = 0;
+               wlr_output_layout_output_coords(view->server->output_layout,
+                       wlr_output, &ox, &oy);
+               box.x -= ox;
+               box.y -= oy;
+
                if (view->ssd.enabled) {
                        struct border border = ssd_thickness(view);
                        box.x += border.left;
@@ -100,8 +98,8 @@ view_maximize(struct view *view, bool maximize)
                        box.width -= border.right + border.left;
                        box.height -= border.top + border.bottom;
                }
-               box.width /= output->scale;
-               box.height /= output->scale;
+               box.width /= wlr_output->scale;
+               box.height /= wlr_output->scale;
                view_move_resize(view, box);
                view_move(view, box.x, box.y);
                view->maximized = true;