]> git.mdlowis.com Git - proto/labwc.git/commitdiff
view: add view_output() and view_wlr_output()
authorJohan Malm <jgm323@gmail.com>
Tue, 20 Jul 2021 18:40:37 +0000 (19:40 +0100)
committerJohan Malm <jgm323@gmail.com>
Tue, 20 Jul 2021 18:40:37 +0000 (19:40 +0100)
src/view.c

index 895dff74ff25a3584025b4e24677c623e717c211..94e5063639bc6167fe211df6ff6d1c9d72049847 100644 (file)
@@ -35,10 +35,10 @@ view_unminimize(struct view *view)
 }
 
 /*
- * view_output - return the output that a view is mostly on
+ * view_wlr_output - return the output that a view is mostly on
  */
 static struct wlr_output *
-view_output(struct view *view)
+view_wlr_output(struct view *view)
 {
        struct wlr_output_layout *layout = view->server->output_layout;
        struct wlr_output *output;
@@ -49,19 +49,26 @@ view_output(struct view *view)
        return output;
 }
 
+static struct output *
+view_output(struct view *view)
+{
+       struct wlr_output *wlr_output = view_wlr_output(view);
+       return output_from_wlr_output(view->server, wlr_output);
+}
+
 void
 view_center(struct view *view)
 {
-       struct wlr_output *output = view_output(view);
-       if (!output) {
+       struct wlr_output *wlr_output = view_wlr_output(view);
+       if (!wlr_output) {
                return;
        }
 
        struct wlr_output_layout *layout = view->server->output_layout;
        struct wlr_output_layout_output* ol_output =
-               wlr_output_layout_get(layout, output);
-       int center_x = ol_output->x + output->width / 2;
-       int center_y = ol_output->y + output->height / 2;
+               wlr_output_layout_get(layout, wlr_output);
+       int center_x = ol_output->x + wlr_output->width / 2;
+       int center_y = ol_output->y + wlr_output->height / 2;
        view_move(view, center_x - view->w / 2, center_y - view->h / 2);
 }
 
@@ -78,16 +85,13 @@ view_maximize(struct view *view, bool maximize)
                view->unmaximized_geometry.width = view->w;
                view->unmaximized_geometry.height = view->h;
 
-               struct wlr_output *wlr_output = view_output(view);
-               struct output *output =
-                       output_from_wlr_output(view->server, wlr_output);
-
+               struct output *output = view_output(view);
                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);
+                       output->wlr_output, &ox, &oy);
                box.x -= ox;
                box.y -= oy;
 
@@ -98,10 +102,9 @@ view_maximize(struct view *view, bool maximize)
                        box.width -= border.right + border.left;
                        box.height -= border.top + border.bottom;
                }
-               box.width /= wlr_output->scale;
-               box.height /= wlr_output->scale;
+               box.width /= output->wlr_output->scale;
+               box.height /= output->wlr_output->scale;
                view_move_resize(view, box);
-               view_move(view, box.x, box.y);
                view->maximized = true;
        } else {
                /* unmaximize */