From: Johan Malm Date: Mon, 1 Mar 2021 18:15:02 +0000 (+0000) Subject: view.c: refactor view_maximize() X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=e0067536fca71c1a44d61b5457ad68283ca86d13;p=proto%2Flabwc.git view.c: refactor view_maximize() --- diff --git a/include/labwc.h b/include/labwc.h index 72cbb97f..30359aef 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -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); diff --git a/src/view.c b/src/view.c index 467bd502..56aef3f3 100644 --- a/src/view.c +++ b/src/view.c @@ -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 */