From 76bdf9c92e9828aeacd067bcd53c1f656a109b1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= Date: Wed, 5 Jun 2024 00:43:14 -0600 Subject: [PATCH] set preferred scale after the first commit (XDGshell) --- dwl.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/dwl.c b/dwl.c index 521b07a..c029c1f 100644 --- a/dwl.c +++ b/dwl.c @@ -476,6 +476,7 @@ applyrules(Client *c) } } } + setmon(c, mon, newtags); } @@ -775,6 +776,19 @@ commitnotify(struct wl_listener *listener, void *data) { Client *c = wl_container_of(listener, c, commit); + if (c->surface.xdg->initial_commit) { + /* + * Get the monitor this client will be rendered on + * Note that if the user set a rule in which the client is placed on + * a different monitor based on its title this will likely select + * a wrong monitor. + */ + applyrules(c); + wlr_surface_set_preferred_buffer_scale(client_surface(c), CEIL(c->mon->wlr_output->scale)); + wlr_fractional_scale_v1_notify_scale(client_surface(c), c->mon->wlr_output->scale); + setmon(c, NULL, 0); /* Make sure to reapply rules in mapnotify() */ + } + if (client_surface(c)->mapped && c->mon) resize(c, c->geom, (c->isfloating && !c->isfullscreen)); @@ -2130,7 +2144,7 @@ resize(Client *c, struct wlr_box geo, int interact) struct wlr_box *bbox; struct wlr_box clip; - if (!c->mon) + if (!c->mon || !c->scene) return; bbox = interact ? &sgeom : &c->mon->w; @@ -2250,7 +2264,7 @@ setfloating(Client *c, int floating) Client *p = client_get_parent(c); c->isfloating = floating; /* If in floating layout do not change the client's layer */ - if (!c->mon || !c->mon->lt[c->mon->sellt]->arrange) + if (!c->mon || !client_surface(c)->mapped || !c->mon->lt[c->mon->sellt]->arrange) return; wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen || (p && p->isfullscreen) ? LyrFS @@ -2263,7 +2277,7 @@ void setfullscreen(Client *c, int fullscreen) { c->isfullscreen = fullscreen; - if (!c->mon) + if (!c->mon || !client_surface(c)->mapped) return; c->bw = fullscreen ? 0 : borderpx; client_set_fullscreen(c, fullscreen);