From a39a46c908011de913b142dbd1dd427eb7fbca0a Mon Sep 17 00:00:00 2001 From: Ben Jargowsky Date: Thu, 15 Dec 2022 17:34:03 -0500 Subject: Check width and height are not negative in client_set_bounds() --- client.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client.h') diff --git a/client.h b/client.h index dbf018f..06c2073 100644 --- a/client.h +++ b/client.h @@ -141,7 +141,7 @@ client_set_bounds(Client *c, int32_t width, int32_t height) return 0; #endif if (c->surface.xdg->client->shell->version >= - XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION) + XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION && width >= 0 && height >= 0) return wlr_xdg_toplevel_set_bounds(c->surface.xdg->toplevel, width, height); return 0; } -- cgit v1.2.3 From 7eaa01ac1f074511ae1013326172d51c6fdf8866 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Tue, 6 Dec 2022 14:47:55 -0600 Subject: Revert "Revert "fix flickering when resizing/spawning windows"" This reverts commit 4a32293548667e68cd9a103e22368b8db1754deb. --- client.h | 15 +++++++++++++++ dwl.c | 29 ++++++----------------------- 2 files changed, 21 insertions(+), 23 deletions(-) (limited to 'client.h') diff --git a/client.h b/client.h index 06c2073..064e093 100644 --- a/client.h +++ b/client.h @@ -240,6 +240,21 @@ client_is_mapped(Client *c) return c->surface.xdg->mapped; } +static inline int +client_is_rendered_on_mon(Client *c, Monitor *m) +{ + /* This is needed for when you don't want to check formal assignment, + * but rather actual displaying of the pixels. + * Usually VISIBLEON suffices and is also faster. */ + struct wlr_surface_output *s; + if (!c->scene->node.enabled) + return 0; + wl_list_for_each(s, &client_surface(c)->current_outputs, link) + if (s->output == m->wlr_output) + return 1; + return 0; +} + static inline int client_is_unmanaged(Client *c) { diff --git a/dwl.c b/dwl.c index 196c34d..8a21342 100644 --- a/dwl.c +++ b/dwl.c @@ -185,7 +185,6 @@ struct Monitor { unsigned int tagset[2]; double mfact; int nmaster; - int un_map; /* If a map/unmap happened on this monitor, then this should be true */ }; typedef struct { @@ -1531,8 +1530,6 @@ mapnotify(struct wl_listener *listener, void *data) } printstatus(); - c->mon->un_map = 1; - unset_fullscreen: m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y); wl_list_for_each(w, &clients, link) @@ -1834,30 +1831,19 @@ rendermon(struct wl_listener *listener, void *data) * generally at the output's refresh rate (e.g. 60Hz). */ Monitor *m = wl_container_of(listener, m, frame); Client *c; - int skip = 0; struct timespec now; - clock_gettime(CLOCK_MONOTONIC, &now); - /* Render if no XDG clients have an outstanding resize and are visible on * this monitor. */ - /* Checking m->un_map for every client is not optimal but works */ - wl_list_for_each(c, &clients, link) { - if ((c->resize && m->un_map) || (c->type == XDGShell - && (c->surface.xdg->pending.geometry.width != - c->surface.xdg->current.geometry.width - || c->surface.xdg->pending.geometry.height != - c->surface.xdg->current.geometry.height))) { - /* Lie */ - wlr_surface_send_frame_done(client_surface(c), &now); - skip = 1; - } - } - if (!skip && !wlr_scene_output_commit(m->scene_output)) + wl_list_for_each(c, &clients, link) + if (client_is_rendered_on_mon(c, m) && (!c->isfloating && c->resize)) + goto skip; + if (!wlr_scene_output_commit(m->scene_output)) return; +skip: /* Let clients know a frame has been rendered */ + clock_gettime(CLOCK_MONOTONIC, &now); wlr_scene_output_send_frame_done(m->scene_output, &now); - m->un_map = 0; } void @@ -2425,9 +2411,6 @@ unmapnotify(struct wl_listener *listener, void *data) grabc = NULL; } - if (c->mon) - c->mon->un_map = 1; - if (client_is_unmanaged(c)) { if (c == exclusive_focus) exclusive_focus = NULL; -- cgit v1.2.3 From 6ca011430a18980f12f7314cdeeff36051268a67 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Wed, 21 Dec 2022 14:28:27 -0600 Subject: do not skip frames if a client is stopped and have a pending resize --- client.h | 26 ++++++++++++++++++++++++++ dwl.c | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) (limited to 'client.h') diff --git a/client.h b/client.h index 064e093..295e8ff 100644 --- a/client.h +++ b/client.h @@ -255,6 +255,32 @@ client_is_rendered_on_mon(Client *c, Monitor *m) return 0; } +static inline int +client_is_stopped(Client *c) +{ + int pid; + siginfo_t in = {0}; +#ifdef XWAYLAND + if (client_is_x11(c)) + return 0; +#endif + + wl_client_get_credentials(c->surface.xdg->client->client, &pid, NULL, NULL); + if (waitid(P_PID, pid, &in, WNOHANG|WCONTINUED|WSTOPPED|WNOWAIT) < 0) { + /* This process is not our child process, while is very unluckely that + * it is stopped, in order to do not skip frames assume that it is. */ + if (errno == ECHILD) + return 1; + } else if (in.si_pid) { + if (in.si_code == CLD_STOPPED || in.si_code == CLD_TRAPPED) + return 1; + if (in.si_code == CLD_CONTINUED) + return 0; + } + + return 0; +} + static inline int client_is_unmanaged(Client *c) { diff --git a/dwl.c b/dwl.c index 8a21342..43603db 100644 --- a/dwl.c +++ b/dwl.c @@ -1836,7 +1836,7 @@ rendermon(struct wl_listener *listener, void *data) /* Render if no XDG clients have an outstanding resize and are visible on * this monitor. */ wl_list_for_each(c, &clients, link) - if (client_is_rendered_on_mon(c, m) && (!c->isfloating && c->resize)) + if (client_is_rendered_on_mon(c, m) && (!c->isfloating && c->resize) && !client_is_stopped(c)) goto skip; if (!wlr_scene_output_commit(m->scene_output)) return; -- cgit v1.2.3 From be854cab35bc090ab3f6fbad3a0f93013294226d Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Wed, 14 Dec 2022 23:21:58 -0600 Subject: do not try to resize if size wouldn't change --- client.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'client.h') diff --git a/client.h b/client.h index 295e8ff..5a45edc 100644 --- a/client.h +++ b/client.h @@ -345,6 +345,9 @@ client_set_size(Client *c, uint32_t width, uint32_t height) return 0; } #endif + if (width == c->surface.xdg->toplevel->current.width + && height ==c->surface.xdg->toplevel->current.height) + return 0; return wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, width, height); } -- cgit v1.2.3