From ffe00e6139e3bb367aaaa2f3f76760e314ca443d Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Tue, 4 Aug 2020 06:03:44 +0200 Subject: [PATCH 01/19] Define SHCMD macro --- config.def.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config.def.h b/config.def.h index 309c2fa..17b1489 100644 --- a/config.def.h +++ b/config.def.h @@ -49,6 +49,8 @@ static const int repeat_delay = 600; { MODKEY|WLR_MODIFIER_SHIFT, SKEY, tag, {.ui = 1 << TAG} }, \ { MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,SKEY,toggletag, {.ui = 1 << TAG} } +#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } + /* commands */ static const char *termcmd[] = { "alacritty", NULL }; From c08ea88c1f08c741637004c032fafac1d75bd36f Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Thu, 6 Aug 2020 15:32:55 +1000 Subject: [PATCH 02/19] #31 independents retain focus while mouse is over them --- dwl.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/dwl.c b/dwl.c index fbdfbe0..813405b 100644 --- a/dwl.c +++ b/dwl.c @@ -224,6 +224,7 @@ static void unmapnotify(struct wl_listener *listener, void *data); static void xwaylandready(struct wl_listener *listener, void *data); static void view(const Arg *arg); static Client *xytoclient(double x, double y); +static Client *xytoindependent(double x, double y); static Monitor *xytomon(double x, double y); static void zoom(const Arg *arg); @@ -677,7 +678,7 @@ focusclient(Client *old, Client *c, int lift) struct wlr_keyboard *kb = wlr_seat_get_keyboard(seat); /* Raise client in stacking order if requested */ - if (c && lift) { + if (c && c->type != X11Unmanaged && lift) { wl_list_remove(&c->slink); wl_list_insert(&stack, &c->slink); } @@ -706,8 +707,10 @@ focusclient(Client *old, Client *c, int lift) kb->keycodes, kb->num_keycodes, &kb->modifiers); /* Put the new client atop the focus stack and select its monitor */ - wl_list_remove(&c->flink); - wl_list_insert(&fstack, &c->flink); + if (c->type != X11Unmanaged) { + wl_list_remove(&c->flink); + wl_list_insert(&fstack, &c->flink); + } selmon = c->mon; /* Activate the new client */ @@ -983,8 +986,14 @@ motionnotify(uint32_t time) return; } + /* Find an independent under the pointer and send the event along. */ + if ((c = xytoindependent(cursor->x, cursor->y))) { + surface = wlr_surface_surface_at(c->surface.xwayland->surface, + cursor->x - c->surface.xwayland->x - c->bw, + cursor->y - c->surface.xwayland->y - c->bw, &sx, &sy); + /* Otherwise, find the client under the pointer and send the event along. */ - if ((c = xytoclient(cursor->x, cursor->y))) { + } else if (!c && (c = xytoclient(cursor->x, cursor->y))) { if (c->type != XDGShell) surface = wlr_surface_surface_at(c->surface.xwayland->surface, cursor->x - c->geom.x - c->bw, @@ -1771,6 +1780,25 @@ xytoclient(double x, double y) return NULL; } +Client * +xytoindependent(double x, double y) +{ + /* Find the topmost visible independent at point (x, y). + * For independents, the most recently created can be used as the "top". + * AMC TODO: factor monitor or owning client visibility in. */ + Client *c; + struct wlr_box geom; + wl_list_for_each_reverse(c, &independents, link) { + geom.x = c->surface.xwayland->x; + geom.y = c->surface.xwayland->y; + geom.width = c->surface.xwayland->width; + geom.height = c->surface.xwayland->height; + if (wlr_box_contains_point(&geom, x, y)) + return c; + } + return NULL; +} + Monitor * xytomon(double x, double y) { From 9d138ac95a4575f61893278791d23bd70d02d286 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Thu, 6 Aug 2020 15:41:04 +1000 Subject: [PATCH 03/19] #31 independents retain focus while mouse is over them --- dwl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwl.c b/dwl.c index 813405b..15c446b 100644 --- a/dwl.c +++ b/dwl.c @@ -993,7 +993,7 @@ motionnotify(uint32_t time) cursor->y - c->surface.xwayland->y - c->bw, &sx, &sy); /* Otherwise, find the client under the pointer and send the event along. */ - } else if (!c && (c = xytoclient(cursor->x, cursor->y))) { + } else if ((c = xytoclient(cursor->x, cursor->y))) { if (c->type != XDGShell) surface = wlr_surface_surface_at(c->surface.xwayland->surface, cursor->x - c->geom.x - c->bw, From 95515682526dc786a9c2a668274a85be46b44d03 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sun, 9 Aug 2020 11:34:19 +1000 Subject: [PATCH 04/19] #31 independents retain focus while mouse is over them --- dwl.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/dwl.c b/dwl.c index 15c446b..f5247b0 100644 --- a/dwl.c +++ b/dwl.c @@ -678,7 +678,7 @@ focusclient(Client *old, Client *c, int lift) struct wlr_keyboard *kb = wlr_seat_get_keyboard(seat); /* Raise client in stacking order if requested */ - if (c && c->type != X11Unmanaged && lift) { + if (c && lift) { wl_list_remove(&c->slink); wl_list_insert(&stack, &c->slink); } @@ -707,10 +707,8 @@ focusclient(Client *old, Client *c, int lift) kb->keycodes, kb->num_keycodes, &kb->modifiers); /* Put the new client atop the focus stack and select its monitor */ - if (c->type != X11Unmanaged) { - wl_list_remove(&c->flink); - wl_list_insert(&fstack, &c->flink); - } + wl_list_remove(&c->flink); + wl_list_insert(&fstack, &c->flink); selmon = c->mon; /* Activate the new client */ @@ -1079,7 +1077,7 @@ pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy, /* Otherwise, let the client know that the mouse cursor has entered one * of its surfaces, and make keyboard focus follow if desired. */ wlr_seat_pointer_notify_enter(seat, surface, sx, sy); - if (sloppyfocus) + if (sloppyfocus && c->type != X11Unmanaged) focusclient(selclient(), c, 0); } From 5b464edf91b748a19cba2aa2c472f2d939f15220 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sun, 9 Aug 2020 11:56:34 +1000 Subject: [PATCH 05/19] #31 independents retain focus while mouse is over them --- dwl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dwl.c b/dwl.c index f5247b0..342ff1e 100644 --- a/dwl.c +++ b/dwl.c @@ -1783,7 +1783,9 @@ xytoindependent(double x, double y) { /* Find the topmost visible independent at point (x, y). * For independents, the most recently created can be used as the "top". - * AMC TODO: factor monitor or owning client visibility in. */ + * We rely on the X11 convention of unmapping unmanaged when the "owning" + * client loses focus, which ensures that unmanaged are only visible on + * the current tag. */ Client *c; struct wlr_box geom; wl_list_for_each_reverse(c, &independents, link) { From 0816b33d333e949437a465b0dcf8461ba4c099a5 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sun, 16 Aug 2020 01:02:01 -0500 Subject: [PATCH 06/19] add comment from dwm --- config.def.h | 1 + 1 file changed, 1 insertion(+) diff --git a/config.def.h b/config.def.h index eff8f59..53021cf 100644 --- a/config.def.h +++ b/config.def.h @@ -51,6 +51,7 @@ static const int repeat_delay = 600; { MODKEY|WLR_MODIFIER_SHIFT, SKEY, tag, {.ui = 1 << TAG} }, \ { MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,SKEY,toggletag, {.ui = 1 << TAG} } +/* helper for spawning shell commands in the pre dwm-5.0 fashion */ #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } /* commands */ From c970d97f8578180beedf87805b400a8f5daa1e42 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sun, 16 Aug 2020 01:14:54 -0500 Subject: [PATCH 07/19] _net_wm not needed outside xwayland --- dwl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwl.c b/dwl.c index 02576fe..338f9e6 100644 --- a/dwl.c +++ b/dwl.c @@ -55,9 +55,9 @@ /* enums */ enum { CurNormal, CurMove, CurResize }; /* cursor */ +#ifdef XWAYLAND enum { NetWMWindowTypeDialog, NetWMWindowTypeSplash, NetWMWindowTypeToolbar, NetWMWindowTypeUtility, NetLast }; /* EWMH atoms */ -#ifdef XWAYLAND enum { XDGShell, X11Managed, X11Unmanaged }; /* client types */ #endif From 41c3f91b03d67a9862ec2b04ac0b8749746611fa Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sun, 16 Aug 2020 11:32:45 -0500 Subject: [PATCH 08/19] wlr_session_change_vt is NULL safe --- dwl.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/dwl.c b/dwl.c index 338f9e6..69ca78e 100644 --- a/dwl.c +++ b/dwl.c @@ -428,10 +428,7 @@ buttonpress(struct wl_listener *listener, void *data) void chvt(const Arg *arg) { - struct wlr_session *s = wlr_backend_get_session(backend); - if (!s) - return; - wlr_session_change_vt(s, arg->ui); + wlr_session_change_vt(wlr_backend_get_session(backend), arg->ui); } void From c0b05eddb8c3cca888f75eab45288802ce592431 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sun, 16 Aug 2020 11:36:38 -0500 Subject: [PATCH 09/19] make this marginally less ugly --- dwl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dwl.c b/dwl.c index 69ca78e..c4af87e 100644 --- a/dwl.c +++ b/dwl.c @@ -977,10 +977,9 @@ motionnotify(uint32_t time) cursor->y - c->surface.xwayland->y - c->bw, &sx, &sy); /* Otherwise, find the client under the pointer and send the event along. */ - } else if ((c = xytoclient(cursor->x, cursor->y))) { -#else - if ((c = xytoclient(cursor->x, cursor->y))) { + } else #endif + if ((c = xytoclient(cursor->x, cursor->y))) { #ifdef XWAYLAND if (c->type != XDGShell) surface = wlr_surface_surface_at(c->surface.xwayland->surface, From d615d3836c8a4091a9fc7f5313e517f04df48601 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Tue, 18 Aug 2020 18:22:44 -0500 Subject: [PATCH 10/19] Use SIGCHLD handler from dwm Fixes #46. --- dwl.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dwl.c b/dwl.c index c4af87e..18c2b33 100644 --- a/dwl.c +++ b/dwl.c @@ -224,6 +224,7 @@ static void setlayout(const Arg *arg); static void setmfact(const Arg *arg); static void setmon(Client *c, Monitor *m, unsigned int newtags); static void setup(void); +static void sigchld(int unused); static void spawn(const Arg *arg); static void tag(const Arg *arg); static void tagmon(const Arg *arg); @@ -1458,6 +1459,9 @@ setsel(struct wl_listener *listener, void *data) void setup(void) { + /* clean up child processes immediately */ + sigchld(0); + /* The backend is a wlroots feature which abstracts the underlying input and * output hardware. The autocreate option will choose the most suitable * backend based on the current environment, such as opening an X11 window @@ -1579,6 +1583,17 @@ setup(void) #endif } +void +sigchld(int unused) +{ + if (signal(SIGCHLD, sigchld) == SIG_ERR) { + perror("can't install SIGCHLD handler"); + exit(EXIT_FAILURE); + } + while (0 < waitpid(-1, NULL, WNOHANG)) + ; +} + void spawn(const Arg *arg) { From 83f60e89b0ce395511a91f3f1944015668730758 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Tue, 18 Aug 2020 19:39:34 -0500 Subject: [PATCH 11/19] add macro for fatal errors dwm lets the OS do cleanup if the program errors out --- dwl.c | 44 ++++++++++++++------------------------------ 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/dwl.c b/dwl.c index 18c2b33..8aa428b 100644 --- a/dwl.c +++ b/dwl.c @@ -40,6 +40,8 @@ #endif /* macros */ +#define BARF(fmt, ...) do { fprintf(stderr, fmt "\n", ##__VA_ARGS__); exit(EXIT_FAILURE); } while (0) +#define EBARF(fmt, ...) BARF(fmt ": %s", ##__VA_ARGS__, strerror(errno)) #define MAX(A, B) ((A) > (B) ? (A) : (B)) #define MIN(A, B) ((A) < (B) ? (A) : (B)) #define CLEANMASK(mask) (mask & ~WLR_MODIFIER_CAPS) @@ -1280,20 +1282,13 @@ run(char *startup_cmd) /* Add a Unix socket to the Wayland display. */ const char *socket = wl_display_add_socket_auto(dpy); - if (!socket) { - perror("startup: display_add_socket_auto"); - wlr_backend_destroy(backend); - exit(EXIT_FAILURE); - } + if (!socket) + BARF("startup: display_add_socket_auto"); /* Start the backend. This will enumerate outputs and inputs, become the DRM * master, etc */ - if (!wlr_backend_start(backend)) { - perror("startup: backend_start"); - wlr_backend_destroy(backend); - wl_display_destroy(dpy); - exit(EXIT_FAILURE); - } + if (!wlr_backend_start(backend)) + BARF("startup: backend_start"); /* Now that outputs are initialized, choose initial selmon based on * cursor position, and set default cursor image */ @@ -1311,16 +1306,11 @@ run(char *startup_cmd) setenv("WAYLAND_DISPLAY", socket, 1); if (startup_cmd) { startup_pid = fork(); - if (startup_pid < 0) { - perror("startup: fork"); - wl_display_destroy(dpy); - exit(EXIT_FAILURE); - } + if (startup_pid < 0) + EBARF("startup: fork"); if (startup_pid == 0) { execl("/bin/sh", "/bin/sh", "-c", startup_cmd, (void *)NULL); - perror("startup: execl"); - wl_display_destroy(dpy); - exit(EXIT_FAILURE); + EBARF("startup: execl"); } } /* Run the Wayland event loop. This does not return until you exit the @@ -1586,10 +1576,8 @@ setup(void) void sigchld(int unused) { - if (signal(SIGCHLD, sigchld) == SIG_ERR) { - perror("can't install SIGCHLD handler"); - exit(EXIT_FAILURE); - } + if (signal(SIGCHLD, sigchld) == SIG_ERR) + EBARF("can't install SIGCHLD handler"); while (0 < waitpid(-1, NULL, WNOHANG)) ; } @@ -1600,9 +1588,7 @@ spawn(const Arg *arg) if (fork() == 0) { setsid(); execvp(((char **)arg->v)[0], (char **)arg->v); - fprintf(stderr, "dwl: execvp %s", ((char **)arg->v)[0]); - perror(" failed"); - exit(EXIT_FAILURE); + EBARF("dwl: execvp %s failed", ((char **)arg->v)[0]); } } @@ -1941,10 +1927,8 @@ main(int argc, char *argv[]) // Wayland requires XDG_RUNTIME_DIR for creating its communications // socket - if (!getenv("XDG_RUNTIME_DIR")) { - fprintf(stderr, "XDG_RUNTIME_DIR must be set\n"); - exit(EXIT_FAILURE); - } + 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. */ From ad9b3bc65d9e4802d2982bf09938783cfb7ee1b3 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Tue, 18 Aug 2020 19:43:42 -0500 Subject: [PATCH 12/19] handle NULL return from backend_autocreate Fixes #44. --- dwl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dwl.c b/dwl.c index 8aa428b..357718f 100644 --- a/dwl.c +++ b/dwl.c @@ -1460,7 +1460,8 @@ setup(void) * backend uses the renderer, for example, to fall back to software cursors * if the backend does not support hardware cursors (some older GPUs * don't). */ - backend = wlr_backend_autocreate(dpy, NULL); + if (!(backend = wlr_backend_autocreate(dpy, NULL))) + BARF("couldn't create backend"); /* If we don't provide a renderer, autocreate makes a GLES2 renderer for us. * The renderer is responsible for defining the various pixel formats it From f13227ebae53840411ba75e320ba09ee2da19b44 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Wed, 19 Aug 2020 00:23:54 -0500 Subject: [PATCH 13/19] only call updatewindowtype for x11 windows --- dwl.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/dwl.c b/dwl.c index 357718f..92414fa 100644 --- a/dwl.c +++ b/dwl.c @@ -331,8 +331,8 @@ applyrules(Client *c) /* rule matching */ c->isfloating = 0; #ifdef XWAYLAND - updatewindowtype(c); if (c->type != XDGShell) { + updatewindowtype(c); appid = c->surface.xwayland->class; title = c->surface.xwayland->title; } else @@ -1842,14 +1842,12 @@ void updatewindowtype(Client *c) { size_t i; - - if (c->type != XDGShell) - for (i = 0; i < c->surface.xwayland->window_type_len; i++) - if (c->surface.xwayland->window_type[i] == netatom[NetWMWindowTypeDialog] || - c->surface.xwayland->window_type[i] == netatom[NetWMWindowTypeSplash] || - c->surface.xwayland->window_type[i] == netatom[NetWMWindowTypeToolbar] || - c->surface.xwayland->window_type[i] == netatom[NetWMWindowTypeUtility]) - c->isfloating = 1; + for (i = 0; i < c->surface.xwayland->window_type_len; i++) + if (c->surface.xwayland->window_type[i] == netatom[NetWMWindowTypeDialog] || + c->surface.xwayland->window_type[i] == netatom[NetWMWindowTypeSplash] || + c->surface.xwayland->window_type[i] == netatom[NetWMWindowTypeToolbar] || + c->surface.xwayland->window_type[i] == netatom[NetWMWindowTypeUtility]) + c->isfloating = 1; } void From f79746c57877cd41c975cd14797cdba4ca6abff5 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Wed, 19 Aug 2020 00:24:57 -0500 Subject: [PATCH 14/19] this is technically barf too I guess? --- dwl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dwl.c b/dwl.c index 92414fa..25a0c2e 100644 --- a/dwl.c +++ b/dwl.c @@ -1950,6 +1950,5 @@ main(int argc, char *argv[]) return EXIT_SUCCESS; usage: - printf("Usage: %s [-qvd] [-s startup command]\n", argv[0]); - return EXIT_FAILURE; + BARF("Usage: %s [-qvd] [-s startup command]", argv[0]); } From 3b1992ca91b9a468019165c985263f5b1cc78c2c Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Wed, 19 Aug 2020 00:30:00 -0500 Subject: [PATCH 15/19] we're not really using the log --- dwl.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/dwl.c b/dwl.c index 25a0c2e..b1d1a39 100644 --- a/dwl.c +++ b/dwl.c @@ -1317,8 +1317,6 @@ run(char *startup_cmd) * compositor. Starting the backend rigged up all of the necessary event * loop configuration to listen to libinput events, DRM events, generate * frame events at the refresh rate, and so on. */ - wlr_log(WLR_INFO, "Running Wayland compositor on WAYLAND_DISPLAY=%s", - socket); wl_display_run(dpy); if (startup_cmd) { @@ -1899,30 +1897,16 @@ int main(int argc, char *argv[]) { char *startup_cmd = NULL; - enum wlr_log_importance loglevel = WLR_ERROR; - int c; - while ((c = getopt(argc, argv, "qvds:h")) != -1) { - switch (c) { - case 'q': - loglevel = WLR_SILENT; - break; - case 'v': - loglevel = WLR_INFO; - break; - case 'd': - loglevel = WLR_DEBUG; - break; - case 's': + + while ((c = getopt(argc, argv, "s:h")) != -1) { + if (c == 's') startup_cmd = optarg; - break; - default: + else goto usage; - } } if (optind < argc) goto usage; - wlr_log_init(loglevel, NULL); // Wayland requires XDG_RUNTIME_DIR for creating its communications // socket From 8eb6fe8e9e9e72801e149ef497c68f1df33f9e36 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Wed, 19 Aug 2020 00:32:32 -0500 Subject: [PATCH 16/19] fix usage to match --- dwl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwl.c b/dwl.c index b1d1a39..fa0a193 100644 --- a/dwl.c +++ b/dwl.c @@ -1934,5 +1934,5 @@ main(int argc, char *argv[]) return EXIT_SUCCESS; usage: - BARF("Usage: %s [-qvd] [-s startup command]", argv[0]); + BARF("Usage: %s [-s startup command]", argv[0]); } From 620da43933f2b192735d8e71196f89271007ce60 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Wed, 19 Aug 2020 00:32:57 -0500 Subject: [PATCH 17/19] cleanup function to match dwm --- dwl.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/dwl.c b/dwl.c index fa0a193..11ea951 100644 --- 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); @@ -434,6 +435,20 @@ chvt(const Arg *arg) wlr_session_change_vt(wlr_backend_get_session(backend), arg->ui); } +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) { @@ -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: From 1c9a0d88222e2f0b1049aec82ba7f5fab2a3dad9 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Sat, 22 Aug 2020 18:09:38 +0200 Subject: [PATCH 18/19] enable gamma control --- dwl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dwl.c b/dwl.c index 11ea951..28a831c 100644 --- a/dwl.c +++ b/dwl.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -1497,6 +1498,7 @@ setup(void) wlr_screencopy_manager_v1_create(dpy); wlr_data_device_manager_create(dpy); wlr_primary_selection_v1_device_manager_create(dpy); + wlr_gamma_control_manager_v1_create(dpy); wlr_viewporter_create(dpy); /* Creates an output layout, which a wlroots utility for working with an From 44ef698d6ef48a41b0df7c4c47d8b880efdbdf33 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sun, 23 Aug 2020 10:01:39 -0500 Subject: [PATCH 19/19] set up interfaces in same order as sway This makes it easier to compare WAYLAND_DEBUG logs when troubleshooting. --- dwl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwl.c b/dwl.c index 28a831c..730e46a 100644 --- a/dwl.c +++ b/dwl.c @@ -1497,8 +1497,8 @@ setup(void) wlr_export_dmabuf_manager_v1_create(dpy); wlr_screencopy_manager_v1_create(dpy); wlr_data_device_manager_create(dpy); - wlr_primary_selection_v1_device_manager_create(dpy); wlr_gamma_control_manager_v1_create(dpy); + wlr_primary_selection_v1_device_manager_create(dpy); wlr_viewporter_create(dpy); /* Creates an output layout, which a wlroots utility for working with an