dwl

My patch set and modifications to dwl
git clone git://git.ethandl.dev/dwl
Log | Files | Refs | README | LICENSE

commit 620da43933f2b192735d8e71196f89271007ce60
parent 8eb6fe8e9e9e72801e149ef497c68f1df33f9e36
Author: Devin J. Pohly <djpohly@gmail.com>
Date:   Wed, 19 Aug 2020 00:32:57 -0500

cleanup function to match dwm

Diffstat:
Mdwl.c | 37++++++++++++++++++++-----------------
1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/dwl.c b/dwl.c @@ -179,6 +179,7 @@ static void arrange(Monitor *m); static void axisnotify(struct wl_listener *listener, void *data); static void buttonpress(struct wl_listener *listener, void *data); static void chvt(const Arg *arg); +static void cleanup(void); static void cleanupkeyboard(struct wl_listener *listener, void *data); static void cleanupmon(struct wl_listener *listener, void *data); static void commitnotify(struct wl_listener *listener, void *data); @@ -435,6 +436,20 @@ chvt(const Arg *arg) } void +cleanup(void) +{ +#ifdef XWAYLAND + wlr_xwayland_destroy(xwayland); +#endif + wl_display_destroy_clients(dpy); + wl_display_destroy(dpy); + + wlr_xcursor_manager_destroy(cursor_mgr); + wlr_cursor_destroy(cursor); + wlr_output_layout_destroy(output_layout); +} + +void cleanupkeyboard(struct wl_listener *listener, void *data) { struct wlr_input_device *device = data; @@ -1447,6 +1462,10 @@ setsel(struct wl_listener *listener, void *data) void setup(void) { + /* The Wayland display is managed by libwayland. It handles accepting + * clients from the Unix socket, manging Wayland globals, and so on. */ + dpy = wl_display_create(); + /* clean up child processes immediately */ sigchld(0); @@ -1912,25 +1931,9 @@ main(int argc, char *argv[]) // socket if (!getenv("XDG_RUNTIME_DIR")) BARF("XDG_RUNTIME_DIR must be set"); - - /* The Wayland display is managed by libwayland. It handles accepting - * clients from the Unix socket, manging Wayland globals, and so on. */ - dpy = wl_display_create(); - setup(); run(startup_cmd); - - /* Once wl_display_run returns, we shut down the server. */ -#ifdef XWAYLAND - wlr_xwayland_destroy(xwayland); -#endif - wl_display_destroy_clients(dpy); - wl_display_destroy(dpy); - - wlr_xcursor_manager_destroy(cursor_mgr); - wlr_cursor_destroy(cursor); - wlr_output_layout_destroy(output_layout); - + cleanup(); return EXIT_SUCCESS; usage: