From 03e167dbb70fbc967e310f95200bcd63f43cac72 Mon Sep 17 00:00:00 2001 From: Raphael Robatsch Date: Sat, 13 Nov 2021 17:22:52 +0100 Subject: fullscreennotify: don't crash if called before map SDL2 calls xdg_toplevel.unset_fullscreen() before the surface is mapped. This causes a segfault in dwl because setfullscreen() expects the surface to be mapped already. Therefore, delay the setfullscreen call until the surface is mapped. --- dwl.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dwl.c b/dwl.c index 6303c25..f99fc9a 100644 --- a/dwl.c +++ b/dwl.c @@ -1042,7 +1042,13 @@ void fullscreennotify(struct wl_listener *listener, void *data) { Client *c = wl_container_of(listener, c, fullscreen); - setfullscreen(c, !c->isfullscreen); + struct wlr_xdg_toplevel_set_fullscreen_event *event = data; + if (!c->mon) { + /* if the client is not mapped yet, let mapnotify() call setfullscreen() */ + c->isfullscreen = event->fullscreen; + return; + } + setfullscreen(c, event->fullscreen); } Monitor * @@ -1316,6 +1322,9 @@ mapnotify(struct wl_listener *listener, void *data) /* Set initial monitor, tags, floating status, and focus */ applyrules(c); + + if (c->isfullscreen) + setfullscreen(c, 1); } void -- cgit v1.2.3 From 43228bd493f53f996a645156f0505b63e79a4f72 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Sun, 13 Mar 2022 20:54:44 -0600 Subject: don't use fullscreen event in fullscreennotify() --- client.h | 10 ++++++++++ dwl.c | 7 ++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/client.h b/client.h index 56e3089..f955688 100644 --- a/client.h +++ b/client.h @@ -95,6 +95,16 @@ client_is_float_type(Client *c) return 0; } +static inline int +client_wants_fullscreen(Client *c) +{ +#ifdef XWAYLAND + if (client_is_x11(c)) + return c->surface.xwayland->fullscreen; +#endif + return c->surface.xdg->toplevel->requested.fullscreen; +} + static inline int client_is_unmanaged(Client *c) { diff --git a/dwl.c b/dwl.c index f99fc9a..612f3d7 100644 --- a/dwl.c +++ b/dwl.c @@ -1042,13 +1042,14 @@ void fullscreennotify(struct wl_listener *listener, void *data) { Client *c = wl_container_of(listener, c, fullscreen); - struct wlr_xdg_toplevel_set_fullscreen_event *event = data; + int fullscreen = client_wants_fullscreen(c); + if (!c->mon) { /* if the client is not mapped yet, let mapnotify() call setfullscreen() */ - c->isfullscreen = event->fullscreen; + c->isfullscreen = fullscreen; return; } - setfullscreen(c, event->fullscreen); + setfullscreen(c, fullscreen); } Monitor * -- cgit v1.2.3