From b372d4b55e256b96fe926c512499ed90c460d66f Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Wed, 14 Apr 2021 11:15:26 -0500 Subject: pipe status info into -s command Unlike with X window managers, the display socket in Wayland isn't set up prior to starting the compositor. Because of this, you can't pipe the compositor's output directly into a program which needs access to $WAYLAND_DISPLAY, which is a typical setup for this purpose. Existing scripts have been forced to create a pipe/FIFO or a temporary file as an intermediary. Instead, send the status info directly to stdin of the -s command, which *does* have access to $WAYLAND_DISPLAY. Fixes #103. --- dwl.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'dwl.c') diff --git a/dwl.c b/dwl.c index d463985..f4b9b3a 100644 --- a/dwl.c +++ b/dwl.c @@ -1805,15 +1805,22 @@ run(char *startup_cmd) setenv("WAYLAND_DISPLAY", socket, 1); if (startup_cmd) { + int piperw[2]; + pipe(piperw); startup_pid = fork(); if (startup_pid < 0) EBARF("startup: fork"); if (startup_pid == 0) { - dup2(STDERR_FILENO, STDOUT_FILENO); + dup2(piperw[0], STDIN_FILENO); + close(piperw[1]); execl("/bin/sh", "/bin/sh", "-c", startup_cmd, NULL); EBARF("startup: execl"); } + dup2(piperw[1], STDOUT_FILENO); + close(piperw[0]); } + /* If nobody is reading the status output, don't terminate */ + signal(SIGPIPE, SIG_IGN); /* Run the Wayland event loop. This does not return until you exit the * compositor. Starting the backend rigged up all of the necessary event -- cgit v1.2.3 From 3727f4a7b3d230226f0082581444344d563e0f9c Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Thu, 15 Apr 2021 13:05:05 -0500 Subject: update status info if focused client changes title Fixes #108. --- dwl.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'dwl.c') diff --git a/dwl.c b/dwl.c index d463985..c5308f5 100644 --- a/dwl.c +++ b/dwl.c @@ -96,6 +96,7 @@ typedef struct { struct wl_listener map; struct wl_listener unmap; struct wl_listener destroy; + struct wl_listener set_title; struct wl_listener fullscreen; struct wlr_box geom; /* layout-relative, includes border */ Monitor *mon; @@ -288,6 +289,7 @@ static void unmaplayersurface(LayerSurface *layersurface); static void unmaplayersurfacenotify(struct wl_listener *listener, void *data); static void unmapnotify(struct wl_listener *listener, void *data); static void updatemons(struct wl_listener *listener, void *data); +static void updatetitle(struct wl_listener *listener, void *data); static void view(const Arg *arg); static void virtualkeyboard(struct wl_listener *listener, void *data); static Client *xytoclient(double x, double y); @@ -891,6 +893,7 @@ createnotify(struct wl_listener *listener, void *data) LISTEN(&xdg_surface->events.map, &c->map, mapnotify); LISTEN(&xdg_surface->events.unmap, &c->unmap, unmapnotify); LISTEN(&xdg_surface->events.destroy, &c->destroy, destroynotify); + LISTEN(&xdg_surface->toplevel->events.set_title, &c->set_title, updatetitle); LISTEN(&xdg_surface->toplevel->events.request_fullscreen, &c->fullscreen, fullscreennotify); c->isfullscreen = 0; @@ -994,6 +997,7 @@ destroynotify(struct wl_listener *listener, void *data) wl_list_remove(&c->map.link); wl_list_remove(&c->unmap.link); wl_list_remove(&c->destroy.link); + wl_list_remove(&c->set_title.link); wl_list_remove(&c->fullscreen.link); #ifdef XWAYLAND if (c->type == X11Managed) @@ -2291,6 +2295,14 @@ updatemons(struct wl_listener *listener, void *data) wlr_output_manager_v1_set_configuration(output_mgr, config); } +void +updatetitle(struct wl_listener *listener, void *data) +{ + Client *c = wl_container_of(listener, c, set_title); + if (c == focustop(c->mon)) + printstatus(); +} + void view(const Arg *arg) { @@ -2427,6 +2439,7 @@ createnotifyx11(struct wl_listener *listener, void *data) activatex11); LISTEN(&xwayland_surface->events.request_configure, &c->configure, configurex11); + LISTEN(&xwayland_surface->events.set_title, &c->set_title, updatetitle); LISTEN(&xwayland_surface->events.destroy, &c->destroy, destroynotify); LISTEN(&xwayland_surface->events.request_fullscreen, &c->fullscreen, fullscreennotify); -- cgit v1.2.3 From 93a58abf2955aa01b7c148b85490d443ab017fb7 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sat, 22 May 2021 14:22:37 -0500 Subject: Wait until map to set window's tiled state Workaround for a bug in Chromium where it fails to attach a buffer to the surface. Fixes #119. --- dwl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'dwl.c') diff --git a/dwl.c b/dwl.c index d7e798b..30a64f8 100644 --- a/dwl.c +++ b/dwl.c @@ -885,10 +885,6 @@ createnotify(struct wl_listener *listener, void *data) c->surface.xdg = xdg_surface; c->bw = borderpx; - /* Tell the client not to try anything fancy */ - wlr_xdg_toplevel_set_tiled(c->surface.xdg, WLR_EDGE_TOP | - WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT); - LISTEN(&xdg_surface->surface->events.commit, &c->commit, commitnotify); LISTEN(&xdg_surface->events.map, &c->map, mapnotify); LISTEN(&xdg_surface->events.unmap, &c->unmap, unmapnotify); @@ -1308,6 +1304,10 @@ mapnotify(struct wl_listener *listener, void *data) c->geom.width += 2 * c->bw; c->geom.height += 2 * c->bw; + /* Tell the client not to try anything fancy */ + wlr_xdg_toplevel_set_tiled(c->surface.xdg, WLR_EDGE_TOP | + WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT); + /* Set initial monitor, tags, floating status, and focus */ applyrules(c); } -- cgit v1.2.3 From 9ab5e01d5b3864f151c222d001a8a2152f29b518 Mon Sep 17 00:00:00 2001 From: Sevz17 Date: Sun, 23 May 2021 11:24:32 -0500 Subject: before set tiled verify if client is xdg-shell, then set tile --- dwl.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'dwl.c') diff --git a/dwl.c b/dwl.c index 30a64f8..3a562b9 100644 --- a/dwl.c +++ b/dwl.c @@ -1304,9 +1304,17 @@ mapnotify(struct wl_listener *listener, void *data) c->geom.width += 2 * c->bw; c->geom.height += 2 * c->bw; +#ifdef XWAYLAND + if (c->type == XDGShell) { + /* Tell the client not to try anything fancy */ + wlr_xdg_toplevel_set_tiled(c->surface.xdg, WLR_EDGE_TOP | + WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT); + } +#else /* Tell the client not to try anything fancy */ wlr_xdg_toplevel_set_tiled(c->surface.xdg, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT); +#endif /* Set initial monitor, tags, floating status, and focus */ applyrules(c); -- cgit v1.2.3 From 06ca86009296c1b8753cba259fd797703a281bbd Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sun, 23 May 2021 18:28:13 -0500 Subject: factor xwayland hackiness out into client.h --- dwl.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'dwl.c') diff --git a/dwl.c b/dwl.c index 3a562b9..9188f06 100644 --- a/dwl.c +++ b/dwl.c @@ -1304,17 +1304,8 @@ mapnotify(struct wl_listener *listener, void *data) c->geom.width += 2 * c->bw; c->geom.height += 2 * c->bw; -#ifdef XWAYLAND - if (c->type == XDGShell) { - /* Tell the client not to try anything fancy */ - wlr_xdg_toplevel_set_tiled(c->surface.xdg, WLR_EDGE_TOP | - WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT); - } -#else /* Tell the client not to try anything fancy */ - wlr_xdg_toplevel_set_tiled(c->surface.xdg, WLR_EDGE_TOP | - WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT); -#endif + client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT); /* Set initial monitor, tags, floating status, and focus */ applyrules(c); -- cgit v1.2.3