From: John Lindgren Date: Mon, 21 Nov 2022 20:13:43 +0000 (-0500) Subject: view/ssd: Move view->margin to view->ssd.margin X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=c536ee9d96f403fdba38e4b9e8434e97b4d6c30b;p=proto%2Flabwc.git view/ssd: Move view->margin to view->ssd.margin --- diff --git a/include/ssd.h b/include/ssd.h index e412ea80..ca3edb3c 100644 --- a/include/ssd.h +++ b/include/ssd.h @@ -117,6 +117,13 @@ struct ssd { struct ssd_sub_tree active; struct ssd_sub_tree inactive; } border; + + /* + * Space between the extremities of the view's wlr_surface + * and the max extents of the server-side decorations. + * For xdg-shell views with CSD, this margin is zero. + */ + struct border margin; }; struct ssd_part { diff --git a/include/view.h b/include/view.h index f94e76da..f317dd2b 100644 --- a/include/view.h +++ b/include/view.h @@ -59,13 +59,6 @@ struct view { /* user defined geometry before maximize / tiling / fullscreen */ struct wlr_box natural_geometry; - /* - * margin refers to the space between the extremities of the - * wlr_surface and the max extents of the server-side decorations. - * For xdg-shell views with CSD, this margin is zero. - */ - struct border margin; - struct view_pending_move_resize { bool update_x, update_y; int x, y; diff --git a/src/resistance.c b/src/resistance.c index 55a9713f..9a090974 100644 --- a/src/resistance.c +++ b/src/resistance.c @@ -41,7 +41,7 @@ resistance_move_apply(struct view *view, double *x, double *y) struct wlr_box tgeom = {.x = *x, .y = *y, .width = view->w, .height = view->h}; struct output *output; - struct border border = view->margin; + struct border border = view->ssd.margin; struct edges view_edges; /* The edges of the current view */ struct edges target_edges; /* The desired edges */ struct edges other_edges; /* The edges of the monitor/other view */ @@ -112,7 +112,7 @@ resistance_resize_apply(struct view *view, struct wlr_box *new_view_geo) .height = view->h}; struct wlr_box tgeom = {.x = new_view_geo->x, .y = new_view_geo->y, .width = new_view_geo->width, .height = new_view_geo->height}; - struct border border = view->margin; + struct border border = view->ssd.margin; struct edges view_edges; /* The edges of the current view */ struct edges target_edges; /* The desired edges */ struct edges other_edges; /* The edges of the monitor/other view */ diff --git a/src/ssd/ssd.c b/src/ssd/ssd.c index a1706a58..9ea1c3b8 100644 --- a/src/ssd/ssd.c +++ b/src/ssd/ssd.c @@ -161,7 +161,7 @@ ssd_create(struct view *view) ssd_extents_create(view); ssd_border_create(view); ssd_titlebar_create(view); - view->margin = ssd_thickness(view); + view->ssd.margin = ssd_thickness(view); ssd_set_active(view, is_active); } @@ -175,14 +175,14 @@ ssd_update_geometry(struct view *view) if (!view->ssd.enabled) { if (view->ssd.tree && view->ssd.tree->node.enabled) { wlr_scene_node_set_enabled(&view->ssd.tree->node, false); - view->margin = ssd_thickness(view); + view->ssd.margin = ssd_thickness(view); } return; } else if (!view->ssd.tree) { ssd_create(view); } else if (!view->ssd.tree->node.enabled) { wlr_scene_node_set_enabled(&view->ssd.tree->node, true); - view->margin = ssd_thickness(view); + view->ssd.margin = ssd_thickness(view); } int width = view->w; diff --git a/src/view.c b/src/view.c index 6f53cbc0..8b76334a 100644 --- a/src/view.c +++ b/src/view.c @@ -88,10 +88,10 @@ view_get_edge_snap_box(struct view *view, struct output *output, break; } struct wlr_box dst = { - .x = x_offset + usable.x + view->margin.left, - .y = y_offset + usable.y + view->margin.top, - .width = base_width - view->margin.left - view->margin.right, - .height = base_height - view->margin.top - view->margin.bottom, + .x = x_offset + usable.x + view->ssd.margin.left, + .y = y_offset + usable.y + view->ssd.margin.top, + .width = base_width - view->ssd.margin.left - view->ssd.margin.right, + .height = base_height - view->ssd.margin.top - view->ssd.margin.bottom, }; return dst; @@ -276,8 +276,8 @@ view_compute_centered_position(struct view *view, int w, int h, int *x, int *y) } struct wlr_box usable = output_usable_area_in_layout_coords(output); - int width = w + view->margin.left + view->margin.right; - int height = h + view->margin.top + view->margin.bottom; + int width = w + view->ssd.margin.left + view->ssd.margin.right; + int height = h + view->ssd.margin.top + view->ssd.margin.bottom; *x = usable.x + (usable.width - width) / 2; *y = usable.y + (usable.height - height) / 2; @@ -292,8 +292,8 @@ view_compute_centered_position(struct view *view, int w, int h, int *x, int *y) #if HAVE_XWAYLAND /* TODO: refactor xwayland.c functions to get rid of this */ if (view->type == LAB_XWAYLAND_VIEW) { - *x += view->margin.left; - *y += view->margin.top; + *x += view->ssd.margin.left; + *y += view->ssd.margin.top; } #endif @@ -725,18 +725,18 @@ view_move_to_edge(struct view *view, const char *direction) int x = 0, y = 0; if (!strcasecmp(direction, "left")) { - x = usable.x + view->margin.left + rc.gap; + x = usable.x + view->ssd.margin.left + rc.gap; y = view->y; } else if (!strcasecmp(direction, "up")) { x = view->x; - y = usable.y + view->margin.top + rc.gap; + y = usable.y + view->ssd.margin.top + rc.gap; } else if (!strcasecmp(direction, "right")) { - x = usable.x + usable.width - view->w - view->margin.right + x = usable.x + usable.width - view->w - view->ssd.margin.right - rc.gap; y = view->y; } else if (!strcasecmp(direction, "down")) { x = view->x; - y = usable.y + usable.height - view->h - view->margin.bottom + y = usable.y + usable.height - view->h - view->ssd.margin.bottom - rc.gap; } else { wlr_log(WLR_ERROR, "invalid edge"); diff --git a/src/xdg.c b/src/xdg.c index f09de3b2..48c80115 100644 --- a/src/xdg.c +++ b/src/xdg.c @@ -276,8 +276,8 @@ position_xdg_toplevel_view(struct view *view) view->x = center_x - view->xdg_surface->current.geometry.width / 2; view->y = center_y - view->xdg_surface->current.geometry.height / 2; } - view->x += view->margin.left; - view->y += view->margin.top; + view->x += view->ssd.margin.left; + view->y += view->ssd.margin.top; } static const char *