set preferred scale after the first commit (XDGshell)

This commit is contained in:
Leonardo Hernández Hernández 2024-06-05 00:43:14 -06:00
parent 46ae075430
commit 76bdf9c92e
No known key found for this signature in database
GPG Key ID: E538897EE11B9624

20
dwl.c
View File

@ -476,6 +476,7 @@ applyrules(Client *c)
} }
} }
} }
setmon(c, mon, newtags); setmon(c, mon, newtags);
} }
@ -775,6 +776,19 @@ commitnotify(struct wl_listener *listener, void *data)
{ {
Client *c = wl_container_of(listener, c, commit); 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) if (client_surface(c)->mapped && c->mon)
resize(c, c->geom, (c->isfloating && !c->isfullscreen)); 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 *bbox;
struct wlr_box clip; struct wlr_box clip;
if (!c->mon) if (!c->mon || !c->scene)
return; return;
bbox = interact ? &sgeom : &c->mon->w; bbox = interact ? &sgeom : &c->mon->w;
@ -2250,7 +2264,7 @@ setfloating(Client *c, int floating)
Client *p = client_get_parent(c); Client *p = client_get_parent(c);
c->isfloating = floating; c->isfloating = floating;
/* If in floating layout do not change the client's layer */ /* 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; return;
wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen || wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen ||
(p && p->isfullscreen) ? LyrFS (p && p->isfullscreen) ? LyrFS
@ -2263,7 +2277,7 @@ void
setfullscreen(Client *c, int fullscreen) setfullscreen(Client *c, int fullscreen)
{ {
c->isfullscreen = fullscreen; c->isfullscreen = fullscreen;
if (!c->mon) if (!c->mon || !client_surface(c)->mapped)
return; return;
c->bw = fullscreen ? 0 : borderpx; c->bw = fullscreen ? 0 : borderpx;
client_set_fullscreen(c, fullscreen); client_set_fullscreen(c, fullscreen);