xdg-shell: remove view->padding

With the wlroots scene-graph API, the padding variable is no longer
needed for windows with Client Side Decoration (CSD).
This commit is contained in:
Johan Malm 2022-04-20 17:00:43 +01:00 committed by Johan Malm
parent 286b2146c3
commit b27955050f
4 changed files with 14 additions and 54 deletions

View file

@ -296,15 +296,6 @@ struct view {
*/ */
struct border margin; struct border margin;
/*
* padding refers to the space between the extremities of the
* wlr_surface and the parts of the surface that is considered the
* window.
* This is only used for xdg-shell views with CSD where the padding
* area is typically invisible except for client-side drop-shawdows.
*/
struct border padding;
struct view_pending_move_resize { struct view_pending_move_resize {
bool update_x, update_y; bool update_x, update_y;
double x, y; double x, y;
@ -379,7 +370,6 @@ void xwayland_unmanaged_create(struct server *server,
void view_set_activated(struct view *view, bool activated); void view_set_activated(struct view *view, bool activated);
void view_close(struct view *view); void view_close(struct view *view);
struct border view_border(struct view *view);
/** /**
* view_move_resize - resize and move view * view_move_resize - resize and move view

View file

@ -40,7 +40,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_border(view); struct border border = view->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 */
@ -107,7 +107,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_border(view); struct border border = view->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

@ -385,18 +385,6 @@ view_adjust_for_layout_change(struct view *view)
} }
} }
struct border
view_border(struct view *view)
{
struct border border = {
.left = view->margin.left - view->padding.left,
.top = view->margin.top - view->padding.top,
.right = view->margin.right + view->padding.right,
.bottom = view->margin.bottom + view->padding.bottom,
};
return border;
}
static void static void
view_output_enter(struct view *view, struct wlr_output *wlr_output) view_output_enter(struct view *view, struct wlr_output *wlr_output)
{ {
@ -446,7 +434,6 @@ view_move_to_edge(struct view *view, const char *direction)
wlr_log(WLR_ERROR, "no output"); wlr_log(WLR_ERROR, "no output");
return; return;
} }
struct border border = view_border(view);
struct wlr_box usable = output_usable_area_in_layout_coords(output); struct wlr_box usable = output_usable_area_in_layout_coords(output);
if (usable.height == output->wlr_output->height if (usable.height == output->wlr_output->height
&& output->wlr_output->scale != 1) { && output->wlr_output->scale != 1) {
@ -459,17 +446,19 @@ 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 + border.left + rc.gap; x = usable.x + view->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 + border.top + rc.gap; y = usable.y + view->margin.top + rc.gap;
} else if (!strcasecmp(direction, "right")) { } else if (!strcasecmp(direction, "right")) {
x = usable.x + usable.width - view->w - border.right - rc.gap; x = usable.x + usable.width - view->w - view->margin.right
- 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 - border.bottom - rc.gap; y = usable.y + usable.height - view->h - view->margin.bottom
- rc.gap;
} }
view_move(view, x, y); view_move(view, x, y);
} }
@ -525,7 +514,6 @@ static struct wlr_box
view_get_edge_snap_box(struct view *view, struct output *output, view_get_edge_snap_box(struct view *view, struct output *output,
enum view_edge edge) enum view_edge edge)
{ {
struct border border = view_border(view);
struct wlr_box usable = output_usable_area_in_layout_coords(output); struct wlr_box usable = output_usable_area_in_layout_coords(output);
if (usable.height == output->wlr_output->height if (usable.height == output->wlr_output->height
&& output->wlr_output->scale != 1) { && output->wlr_output->scale != 1) {
@ -560,10 +548,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 + border.left, .x = x_offset + usable.x + view->margin.left,
.y = y_offset + usable.y + border.top, .y = y_offset + usable.y + view->margin.top,
.width = base_width - border.left - border.right, .width = base_width - view->margin.left - view->margin.right,
.height = base_height - border.top - border.bottom, .height = base_height - view->margin.top - view->margin.bottom,
}; };
return dst; return dst;

View file

@ -42,12 +42,6 @@ handle_commit(struct wl_listener *listener, void *data)
view->w = size.width; view->w = size.width;
view->h = size.height; view->h = size.height;
/* padding changes with maximize/unmaximize */
view->padding.top = size.y;
view->padding.bottom = size.y;
view->padding.left = size.x;
view->padding.right = size.x;
uint32_t serial = view->pending_move_resize.configure_serial; uint32_t serial = view->pending_move_resize.configure_serial;
if (serial > 0 && serial >= view->xdg_surface->current.configure_serial) { if (serial > 0 && serial >= view->xdg_surface->current.configure_serial) {
if (view->pending_move_resize.update_x) { if (view->pending_move_resize.update_x) {
@ -211,17 +205,6 @@ xdg_toplevel_view_close(struct view *view)
wlr_xdg_toplevel_send_close(view->xdg_surface->toplevel); wlr_xdg_toplevel_send_close(view->xdg_surface->toplevel);
} }
static void
update_padding(struct view *view)
{
struct wlr_box padding;
wlr_xdg_surface_get_geometry(view->xdg_surface, &padding);
view->padding.top = padding.y;
view->padding.bottom = padding.y;
view->padding.left = padding.x;
view->padding.right = padding.x;
}
static void static void
xdg_toplevel_view_maximize(struct view *view, bool maximized) xdg_toplevel_view_maximize(struct view *view, bool maximized)
{ {
@ -287,8 +270,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->padding.left; view->x += view->margin.left;
view->y += view->margin.top - view->padding.top; view->y += view->margin.top;
} }
static const char * static const char *
@ -323,7 +306,6 @@ xdg_toplevel_view_map(struct view *view)
ssd_create(view); ssd_create(view);
} }
update_padding(view);
if (!view->fullscreen && requested->fullscreen) { if (!view->fullscreen && requested->fullscreen) {
view_set_fullscreen(view, true, view_set_fullscreen(view, true,
requested->fullscreen_output); requested->fullscreen_output);