view/ssd: Move view->margin to view->ssd.margin

This commit is contained in:
John Lindgren 2022-11-21 15:13:43 -05:00 committed by Consolatis
parent e79c95489a
commit c536ee9d96
6 changed files with 26 additions and 26 deletions

View file

@ -117,6 +117,13 @@ struct ssd {
struct ssd_sub_tree active; struct ssd_sub_tree active;
struct ssd_sub_tree inactive; struct ssd_sub_tree inactive;
} border; } 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 { struct ssd_part {

View file

@ -59,13 +59,6 @@ struct view {
/* user defined geometry before maximize / tiling / fullscreen */ /* user defined geometry before maximize / tiling / fullscreen */
struct wlr_box natural_geometry; 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 { struct view_pending_move_resize {
bool update_x, update_y; bool update_x, update_y;
int x, y; int x, y;

View file

@ -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, struct wlr_box tgeom = {.x = *x, .y = *y, .width = view->w,
.height = view->h}; .height = view->h};
struct output *output; 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 view_edges; /* The edges of the current view */
struct edges target_edges; /* The desired edges */ struct edges target_edges; /* The desired edges */
struct edges other_edges; /* The edges of the monitor/other view */ 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}; .height = view->h};
struct wlr_box tgeom = {.x = new_view_geo->x, .y = new_view_geo->y, struct wlr_box tgeom = {.x = new_view_geo->x, .y = new_view_geo->y,
.width = new_view_geo->width, .height = new_view_geo->height}; .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 view_edges; /* The edges of the current view */
struct edges target_edges; /* The desired edges */ struct edges target_edges; /* The desired edges */
struct edges other_edges; /* The edges of the monitor/other view */ struct edges other_edges; /* The edges of the monitor/other view */

View file

@ -161,7 +161,7 @@ ssd_create(struct view *view)
ssd_extents_create(view); ssd_extents_create(view);
ssd_border_create(view); ssd_border_create(view);
ssd_titlebar_create(view); ssd_titlebar_create(view);
view->margin = ssd_thickness(view); view->ssd.margin = ssd_thickness(view);
ssd_set_active(view, is_active); ssd_set_active(view, is_active);
} }
@ -175,14 +175,14 @@ ssd_update_geometry(struct view *view)
if (!view->ssd.enabled) { if (!view->ssd.enabled) {
if (view->ssd.tree && view->ssd.tree->node.enabled) { if (view->ssd.tree && view->ssd.tree->node.enabled) {
wlr_scene_node_set_enabled(&view->ssd.tree->node, false); wlr_scene_node_set_enabled(&view->ssd.tree->node, false);
view->margin = ssd_thickness(view); view->ssd.margin = ssd_thickness(view);
} }
return; return;
} else if (!view->ssd.tree) { } else if (!view->ssd.tree) {
ssd_create(view); ssd_create(view);
} else if (!view->ssd.tree->node.enabled) { } else if (!view->ssd.tree->node.enabled) {
wlr_scene_node_set_enabled(&view->ssd.tree->node, true); 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; int width = view->w;

View file

@ -88,10 +88,10 @@ view_get_edge_snap_box(struct view *view, struct output *output,
break; break;
} }
struct wlr_box dst = { struct wlr_box dst = {
.x = x_offset + usable.x + view->margin.left, .x = x_offset + usable.x + view->ssd.margin.left,
.y = y_offset + usable.y + view->margin.top, .y = y_offset + usable.y + view->ssd.margin.top,
.width = base_width - view->margin.left - view->margin.right, .width = base_width - view->ssd.margin.left - view->ssd.margin.right,
.height = base_height - view->margin.top - view->margin.bottom, .height = base_height - view->ssd.margin.top - view->ssd.margin.bottom,
}; };
return dst; 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); struct wlr_box usable = output_usable_area_in_layout_coords(output);
int width = w + view->margin.left + view->margin.right; int width = w + view->ssd.margin.left + view->ssd.margin.right;
int height = h + view->margin.top + view->margin.bottom; int height = h + view->ssd.margin.top + view->ssd.margin.bottom;
*x = usable.x + (usable.width - width) / 2; *x = usable.x + (usable.width - width) / 2;
*y = usable.y + (usable.height - height) / 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 #if HAVE_XWAYLAND
/* TODO: refactor xwayland.c functions to get rid of this */ /* TODO: refactor xwayland.c functions to get rid of this */
if (view->type == LAB_XWAYLAND_VIEW) { if (view->type == LAB_XWAYLAND_VIEW) {
*x += view->margin.left; *x += view->ssd.margin.left;
*y += view->margin.top; *y += view->ssd.margin.top;
} }
#endif #endif
@ -725,18 +725,18 @@ view_move_to_edge(struct view *view, const char *direction)
int x = 0, y = 0; int x = 0, y = 0;
if (!strcasecmp(direction, "left")) { if (!strcasecmp(direction, "left")) {
x = usable.x + view->margin.left + rc.gap; x = usable.x + view->ssd.margin.left + rc.gap;
y = view->y; y = view->y;
} else if (!strcasecmp(direction, "up")) { } else if (!strcasecmp(direction, "up")) {
x = view->x; 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")) { } 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; - rc.gap;
y = view->y; y = view->y;
} else if (!strcasecmp(direction, "down")) { } else if (!strcasecmp(direction, "down")) {
x = view->x; 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; - rc.gap;
} else { } else {
wlr_log(WLR_ERROR, "invalid edge"); wlr_log(WLR_ERROR, "invalid edge");

View file

@ -276,8 +276,8 @@ position_xdg_toplevel_view(struct view *view)
view->x = center_x - view->xdg_surface->current.geometry.width / 2; view->x = center_x - view->xdg_surface->current.geometry.width / 2;
view->y = center_y - view->xdg_surface->current.geometry.height / 2; view->y = center_y - view->xdg_surface->current.geometry.height / 2;
} }
view->x += view->margin.left; view->x += view->ssd.margin.left;
view->y += view->margin.top; view->y += view->ssd.margin.top;
} }
static const char * static const char *