Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

use wlr_scene_subsurface_tree_set_clip #455

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 41 additions & 34 deletions client.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,6 @@ client_is_x11(Client *c)
#endif
}

static inline void
client_get_size_hints(Client *c, struct wlr_box *max, struct wlr_box *min)
{
struct wlr_xdg_toplevel *toplevel;
struct wlr_xdg_toplevel_state *state;
#ifdef XWAYLAND
if (client_is_x11(c)) {
xcb_size_hints_t *size_hints = c->surface.xwayland->size_hints;
if (size_hints) {
max->width = size_hints->max_width;
max->height = size_hints->max_height;
min->width = size_hints->min_width;
min->height = size_hints->min_height;
}
return;
}
#endif
toplevel = c->surface.xdg->toplevel;
state = &toplevel->current;
max->width = state->max_width;
max->height = state->max_height;
min->width = state->min_width;
min->height = state->min_height;
}

static inline struct wlr_surface *
client_surface(Client *c)
{
Expand Down Expand Up @@ -165,6 +140,28 @@ client_get_appid(Client *c)
return c->surface.xdg->toplevel->app_id;
}

static inline void
client_get_clip(Client *c, struct wlr_box *clip)
{
#ifdef XWAYLAND
if (client_is_x11(c)) {
*clip = (struct wlr_box){
.x = 0,
.y = 0,
.width = c->geom.width - c->bw,
.height = c->geom.height - c->bw};
return;
}
#endif

*clip = (struct wlr_box){
.x = c->surface.xdg->pending.geometry.x,
.y = c->surface.xdg->pending.geometry.y,
.width = c->geom.width - c->bw,
.height = c->geom.height - c->bw};

}

static inline void
client_get_geometry(Client *c, struct wlr_box *geom)
{
Expand All @@ -190,7 +187,6 @@ client_get_parent(Client *c)
#endif
if (c->surface.xdg->toplevel->parent)
toplevel_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface, &p, NULL);

return p;
}

Expand All @@ -207,25 +203,36 @@ client_get_title(Client *c)
static inline int
client_is_float_type(Client *c)
{
struct wlr_box min = {0}, max = {0};
client_get_size_hints(c, &max, &min);
struct wlr_xdg_toplevel *toplevel;
struct wlr_xdg_toplevel_state state;

#ifdef XWAYLAND
if (client_is_x11(c)) {
struct wlr_xwayland_surface *surface = c->surface.xwayland;
xcb_size_hints_t *size_hints;
if (surface->modal)
return 1;

for (size_t i = 0; i < surface->window_type_len; i++)
if (surface->window_type[i] == netatom[NetWMWindowTypeDialog]
|| surface->window_type[i] == netatom[NetWMWindowTypeSplash]
|| surface->window_type[i] == netatom[NetWMWindowTypeToolbar]
|| surface->window_type[i] == netatom[NetWMWindowTypeUtility])
if (surface->window_type[i] == netatom[NetWMWindowTypeDialog] ||
surface->window_type[i] == netatom[NetWMWindowTypeSplash] ||
surface->window_type[i] == netatom[NetWMWindowTypeToolbar] ||
surface->window_type[i] == netatom[NetWMWindowTypeUtility])
return 1;

size_hints = surface->size_hints;
return size_hints && size_hints->min_width > 0 && size_hints->min_height > 0
&& (size_hints->max_width == size_hints->min_width
|| size_hints->max_height == size_hints->min_height);
}
#endif
return ((min.width > 0 || min.height > 0 || max.width > 0 || max.height > 0)
&& (min.width == max.width || min.height == max.height));

toplevel = c->surface.xdg->toplevel;
state = toplevel->current;
return (state.min_width != 0 && state.min_height != 0
&& (state.min_width == state.max_width
|| state.min_height == state.max_height))
|| toplevel->parent;
}

static inline int
Expand Down
19 changes: 6 additions & 13 deletions dwl.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,19 +399,9 @@ static xcb_atom_t netatom[NetLast];
void
applybounds(Client *c, struct wlr_box *bbox)
{
if (!c->isfullscreen) {
struct wlr_box min = {0}, max = {0};
client_get_size_hints(c, &max, &min);
/* try to set size hints */
c->geom.width = MAX(min.width + (2 * (int)c->bw), c->geom.width);
c->geom.height = MAX(min.height + (2 * (int)c->bw), c->geom.height);
/* Some clients set their max size to INT_MAX, which does not violate the
* protocol but it's unnecesary, as they can set their max size to zero. */
if (max.width > 0 && !(2 * c->bw > INT_MAX - max.width)) /* Checks for overflow */
c->geom.width = MIN(max.width + (2 * c->bw), c->geom.width);
if (max.height > 0 && !(2 * c->bw > INT_MAX - max.height)) /* Checks for overflow */
c->geom.height = MIN(max.height + (2 * c->bw), c->geom.height);
}
/* set minimum possible */
c->geom.width = MAX(1, c->geom.width);
c->geom.height = MAX(1, c->geom.height);

if (c->geom.x >= bbox->x + bbox->width)
c->geom.x = bbox->x + bbox->width - c->geom.width;
Expand Down Expand Up @@ -1919,6 +1909,7 @@ void
resize(Client *c, struct wlr_box geo, int interact)
{
struct wlr_box *bbox = interact ? &sgeom : &c->mon->w;
struct wlr_box clip;
client_set_bounds(c, geo.width, geo.height);
c->geom = geo;
applybounds(c, bbox);
Expand All @@ -1937,6 +1928,8 @@ resize(Client *c, struct wlr_box geo, int interact)
/* this is a no-op if size hasn't changed */
c->resize = client_set_size(c, c->geom.width - 2 * c->bw,
c->geom.height - 2 * c->bw);
client_get_clip(c, &clip);
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
}

void
Expand Down