]> git.mdlowis.com Git - proto/labwc.git/commitdiff
view.c: refactor view_maximize()
authorJohan Malm <jgm323@gmail.com>
Mon, 1 Mar 2021 18:15:02 +0000 (18:15 +0000)
committerJohan Malm <jgm323@gmail.com>
Mon, 1 Mar 2021 18:15:02 +0000 (18:15 +0000)
include/labwc.h
src/view.c

index 72cbb97f58e57a75fdeb7501bd26179af6030530..30359aef850dbcb4601fa4023e38ceff9aadf869 100644 (file)
@@ -306,6 +306,7 @@ void interactive_begin(struct view *view, enum input_mode mode,
 void output_init(struct server *server);
 void output_damage_surface(struct output *output, struct wlr_surface *surface,
        double lx, double ly, bool whole);
+void scale_box(struct wlr_box *box, float scale);
 
 void damage_all_outputs(struct server *server);
 void damage_view_whole(struct view *view);
index 467bd50271937030974d36d1dbe98043171c5266..56aef3f33b300fe6ccd4e094a494820832d564a4 100644 (file)
@@ -37,8 +37,7 @@ view_unminimize(struct view *view)
 void
 view_maximize(struct view *view, bool maximize)
 {
-       if(maximize == true)
-       {
+       if(maximize == true) {
                struct wlr_output_layout *layout = view->server->output_layout;
                struct wlr_output* output = wlr_output_layout_output_at(
                        layout, view->x + view->w / 2, view->y + view->h / 2);
@@ -54,35 +53,22 @@ view_maximize(struct view *view, bool maximize)
                view->unmaximized_geometry.width = view->w;
                view->unmaximized_geometry.height = view->h;
 
-               int x = ol_output->x;
-               int y = ol_output->y;
-               int width = output->width;
-               int height = output->height;
-
-               if(view->server_side_deco)
-               {
-                       struct border border = deco_thickness(view);
-                       x += border.right;
-                       x += border.left;
-                       y += border.top;
-                       y += border.bottom;
-
-                       width -= border.right;
-                       width -= border.left;
-                       height -= border.top;
-                       height -= border.bottom;
-               }
-
                struct wlr_box box = {
-                       .x = x * output->scale,
-                       .y = y * output->scale,
-                       .width = width * output->scale,
-                       .height = height * output->scale
+                       .x = ol_output->x,
+                       .y = ol_output->y,
+                       .width = output->width,
+                       .height = output->height,
                };
-
+               if (view->server_side_deco) {
+                       struct border border = deco_thickness(view);
+                       box.x += border.left;
+                       box.y += border.top;
+                       box.width -= border.right + border.left;
+                       box.height -= border.top + border.bottom;
+               }
+               scale_box(&box, output->scale);
                view_move_resize(view, box);
-               view_move(view, box.x * output->scale, box.y * output->scale);
-
+               view_move(view, box.x, box.y);
                view->maximized = true;
        } else {
                /* unmaximize */