From 79dcc0d3271395fe1258d818718209254d846b1b Mon Sep 17 00:00:00 2001 From: Tobias Bengfort Date: Sat, 4 Sep 2021 13:46:58 +0200 Subject: reset cursor mode when grabc is unmapped --- dwl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dwl.c b/dwl.c index 2c1634b..c798685 100644 --- a/dwl.c +++ b/dwl.c @@ -2292,6 +2292,10 @@ unmapnotify(struct wl_listener *listener, void *data) { /* Called when the surface is unmapped, and should no longer be shown. */ Client *c = wl_container_of(listener, c, unmap); + if (c == grabc) { + cursor_mode = CurNormal; + grabc = NULL; + } wl_list_remove(&c->link); if (client_is_unmanaged(c)) return; -- cgit v1.2.3 From ebfefa84bad5a930df4df85b150c27f1d4fe6de6 Mon Sep 17 00:00:00 2001 From: Humm Date: Wed, 13 Oct 2021 23:11:40 +0200 Subject: -s: close unused fds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dup2 doesn’t close fds, it only duplicates them. The old ones weren’t closed, causing problems (like dwl blocking due to the child process never reading from the reading end, even if stdin has been closed). --- dwl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dwl.c b/dwl.c index 6303c25..f84460f 100644 --- a/dwl.c +++ b/dwl.c @@ -1823,11 +1823,13 @@ run(char *startup_cmd) EBARF("startup: fork"); if (startup_pid == 0) { dup2(piperw[0], STDIN_FILENO); + close(piperw[0]); close(piperw[1]); execl("/bin/sh", "/bin/sh", "-c", startup_cmd, NULL); EBARF("startup: execl"); } dup2(piperw[1], STDOUT_FILENO); + close(piperw[1]); close(piperw[0]); } /* If nobody is reading the status output, don't terminate */ -- cgit v1.2.3 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 317175da08aedf80f0bfaf71849feea531872a88 Mon Sep 17 00:00:00 2001 From: A Frederick Christensen Date: Fri, 31 Dec 2021 14:51:50 -0600 Subject: Newly launched or closed clients ALWAYS generate status update Prior to this change, if a client whose tag(s) are not currently selected is launched or killed, no update to status was printed and status bars being fed by printstatus() did not update newly active or newly inactive (but unselected) tags. --- dwl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dwl.c b/dwl.c index 8683462..fcd7700 100644 --- a/dwl.c +++ b/dwl.c @@ -1320,6 +1320,7 @@ mapnotify(struct wl_listener *listener, void *data) /* Set initial monitor, tags, floating status, and focus */ applyrules(c); + printstatus(); } void @@ -2290,6 +2291,7 @@ unmapnotify(struct wl_listener *listener, void *data) setmon(c, NULL, 0); wl_list_remove(&c->flink); wl_list_remove(&c->slink); + printstatus(); } void -- cgit v1.2.3 From f587b2fd2c9f5967b9e8ca99fe70fbc80fb6c220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arma=C3=ABl=20Gu=C3=A9neau?= Date: Sat, 8 Jan 2022 17:41:45 +0100 Subject: fix client_set_tiled, which was ignoring its "edges" argument --- client.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client.h b/client.h index 4fd1863..a6b3723 100644 --- a/client.h +++ b/client.h @@ -156,8 +156,7 @@ client_set_tiled(Client *c, uint32_t edges) if (client_is_x11(c)) return; #endif - wlr_xdg_toplevel_set_tiled(c->surface.xdg, WLR_EDGE_TOP | - WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT); + wlr_xdg_toplevel_set_tiled(c->surface.xdg, edges); } static inline struct wlr_surface * -- cgit v1.2.3 From ac896a7df4bac35d43579b450f1e4eeabe7a9d44 Mon Sep 17 00:00:00 2001 From: A Frederick Christensen Date: Tue, 1 Feb 2022 18:58:32 -0600 Subject: Shift+6 generates XKB_KEY_asciicircum --- config.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index 089aa37..738a3ca 100644 --- a/config.def.h +++ b/config.def.h @@ -96,7 +96,7 @@ static const Key keys[] = { TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2), TAGKEYS( XKB_KEY_4, XKB_KEY_dollar, 3), TAGKEYS( XKB_KEY_5, XKB_KEY_percent, 4), - TAGKEYS( XKB_KEY_6, XKB_KEY_caret, 5), + TAGKEYS( XKB_KEY_6, XKB_KEY_asciicircum, 5), TAGKEYS( XKB_KEY_7, XKB_KEY_ampersand, 6), TAGKEYS( XKB_KEY_8, XKB_KEY_asterisk, 7), TAGKEYS( XKB_KEY_9, XKB_KEY_parenleft, 8), -- cgit v1.2.3 From b0098d9d095509e4999965d261fe4282040a187a Mon Sep 17 00:00:00 2001 From: Nihal Jere Date: Tue, 22 Feb 2022 23:03:26 -0600 Subject: die on allocation failure --- dwl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dwl.c b/dwl.c index 36a3871..1b9260b 100644 --- a/dwl.c +++ b/dwl.c @@ -787,6 +787,8 @@ createkeyboard(struct wlr_input_device *device) struct xkb_context *context; struct xkb_keymap *keymap; Keyboard *kb = device->data = calloc(1, sizeof(*kb)); + if (!kb) + EBARF("createkeyboard: calloc"); kb->device = device; /* Prepare an XKB keymap and assign it to the keyboard. */ @@ -818,6 +820,8 @@ createmon(struct wl_listener *listener, void *data) struct wlr_output *wlr_output = data; const MonitorRule *r; Monitor *m = wlr_output->data = calloc(1, sizeof(*m)); + if (!m) + EBARF("createmon: calloc"); m->wlr_output = wlr_output; wlr_output_init_render(wlr_output, alloc, drw); @@ -891,6 +895,8 @@ createnotify(struct wl_listener *listener, void *data) /* Allocate a Client for this surface */ c = xdg_surface->data = calloc(1, sizeof(*c)); + if (!c) + EBARF("createnotify: calloc"); c->surface.xdg = xdg_surface; c->bw = borderpx; @@ -917,6 +923,8 @@ createlayersurface(struct wl_listener *listener, void *data) } layersurface = calloc(1, sizeof(LayerSurface)); + if (!layersurface) + EBARF("layersurface: calloc"); LISTEN(&wlr_layer_surface->surface->events.commit, &layersurface->surface_commit, commitlayersurfacenotify); LISTEN(&wlr_layer_surface->events.destroy, &layersurface->destroy, @@ -2478,6 +2486,8 @@ createnotifyx11(struct wl_listener *listener, void *data) /* Allocate a Client for this surface */ c = xwayland_surface->data = calloc(1, sizeof(*c)); + if (!c) + EBARF("createnotifyx11: calloc"); c->surface.xwayland = xwayland_surface; c->type = xwayland_surface->override_redirect ? X11Unmanaged : X11Managed; c->bw = borderpx; -- cgit v1.2.3 From d1ff1e6f75d9c53c953957b5c0a64e0bcb40008b Mon Sep 17 00:00:00 2001 From: Leonardo Hernandez Hernandez Date: Tue, 28 Sep 2021 18:08:52 -0500 Subject: remove typedef `Decoration` --- dwl.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/dwl.c b/dwl.c index 36a3871..9f6a2e7 100644 --- a/dwl.c +++ b/dwl.c @@ -119,11 +119,6 @@ typedef struct { int isfullscreen; } Client; -typedef struct { - struct wl_listener request_mode; - struct wl_listener destroy; -} Decoration; - typedef struct { uint32_t mod; xkb_keysym_t keysym; -- cgit v1.2.3 From 3e6d584de107a3d555d652b55bf5227d03f2f957 Mon Sep 17 00:00:00 2001 From: Leonardo Hernandez Hernandez Date: Tue, 2 Nov 2021 17:09:54 -0600 Subject: update URL to wlroots project (GitHub->GitLab) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 79a7d8f..1389803 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Join us on our [Discord server](https://discord.gg/jJxZnrGPWN)! -dwl is a compact, hackable compositor for Wayland based on [wlroots](https://github.com/swaywm/wlroots). It is intended to fill the same space in the Wayland world that dwm does in X11, primarily in terms of philosophy, and secondarily in terms of functionality. Like dwm, dwl is: +dwl is a compact, hackable compositor for Wayland based on [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots/). It is intended to fill the same space in the Wayland world that dwm does in X11, primarily in terms of philosophy, and secondarily in terms of functionality. Like dwm, dwl is: - Easy to understand, hack on, and extend with patches - One C source file (or a very small number) configurable via `config.h` -- cgit v1.2.3 From 8cace1921823e250041f7d85d939960f33824451 Mon Sep 17 00:00:00 2001 From: Leonardo Hernandez Hernandez Date: Thu, 4 Nov 2021 08:19:13 -0600 Subject: fix crash when the last monitor is disconnected --- dwl.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/dwl.c b/dwl.c index 0619ff1..67a3cd5 100644 --- a/dwl.c +++ b/dwl.c @@ -57,7 +57,7 @@ #define MAX(A, B) ((A) > (B) ? (A) : (B)) #define MIN(A, B) ((A) < (B) ? (A) : (B)) #define CLEANMASK(mask) (mask & ~WLR_MODIFIER_CAPS) -#define VISIBLEON(C, M) ((C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags])) +#define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags])) #define LENGTH(X) (sizeof X / sizeof X[0]) #define END(A) ((A) + LENGTH(A)) #define TAGMASK ((1 << LENGTH(tags)) - 1) @@ -720,10 +720,11 @@ cleanupmon(struct wl_listener *listener, void *data) wl_list_remove(&m->link); wlr_output_layout_remove(output_layout, m->wlr_output); - nmons = wl_list_length(&mons); - do // don't switch to disabled mons - selmon = wl_container_of(mons.prev, selmon, link); - while (!selmon->wlr_output->enabled && i++ < nmons); + if ((nmons = wl_list_length(&mons))) + do // don't switch to disabled mons + selmon = wl_container_of(mons.prev, selmon, link); + while (!selmon->wlr_output->enabled && i++ < nmons); + focusclient(focustop(selmon), 1); closemon(m); free(m); @@ -860,6 +861,16 @@ createmon(struct wl_listener *listener, void *data) wlr_output_layout_add(output_layout, wlr_output, r->x, r->y); sgeom = *wlr_output_layout_get_box(output_layout, NULL); + /* If length == 1 we need update selmon. + * Maybe it will change in run(). */ + if (wl_list_length(&mons) == 1) { + Client *c; + selmon = m; + /* If there is any client, set c->mon to this monitor */ + wl_list_for_each(c, &clients, link) + setmon(c, m, c->tags); + } + /* When adding monitors, the geometries of all monitors must be updated */ wl_list_for_each(m, &mons, link) { /* The first monitor in the list is the most recently added */ -- cgit v1.2.3 From f673305e86bea5804fa8c68ffa43f120e7d9f9fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= Date: Thu, 10 Mar 2022 11:37:11 -0600 Subject: replace tabs by spaces in alignment --- config.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index 738a3ca..8408659 100644 --- a/config.def.h +++ b/config.def.h @@ -84,7 +84,7 @@ static const Key keys[] = { { MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XKB_KEY_space, setlayout, {0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} }, - { MODKEY, XKB_KEY_e, togglefullscreen, {0} }, + { MODKEY, XKB_KEY_e, togglefullscreen, {0} }, { MODKEY, XKB_KEY_0, view, {.ui = ~0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} }, { MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} }, -- cgit v1.2.3 From 5d9c9a9a685bb026b35032ab8cbc0575785a74ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= Date: Thu, 10 Mar 2022 14:34:36 -0600 Subject: don't warn about unused result Closes: #186 --- config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.mk b/config.mk index cd4e821..d1b161e 100644 --- a/config.mk +++ b/config.mk @@ -2,7 +2,7 @@ PREFIX = /usr/local # Default compile flags (overridable by environment) -CFLAGS ?= -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare -Wno-unused-function -Wno-unused-variable -Wdeclaration-after-statement +CFLAGS ?= -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare -Wno-unused-function -Wno-unused-variable -Wno-unused-result -Wdeclaration-after-statement # Uncomment to build XWayland support #CFLAGS += -DXWAYLAND -- cgit v1.2.3 From 05a473335ea4c69569d9ad34298b4f42a555e6e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= Date: Thu, 10 Mar 2022 14:48:14 -0600 Subject: use wlr_box for previous geom --- dwl.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/dwl.c b/dwl.c index 67a3cd5..ba150fa 100644 --- a/dwl.c +++ b/dwl.c @@ -101,7 +101,7 @@ typedef struct { struct wl_listener destroy; struct wl_listener set_title; struct wl_listener fullscreen; - struct wlr_box geom; /* layout-relative, includes border */ + struct wlr_box geom, prev; /* layout-relative, includes border */ Monitor *mon; #ifdef XWAYLAND unsigned int type; @@ -112,10 +112,6 @@ typedef struct { unsigned int tags; int isfloating, isurgent; uint32_t resize; /* configure serial of a pending resize */ - int prevx; - int prevy; - int prevwidth; - int prevheight; int isfullscreen; } Client; @@ -1035,15 +1031,12 @@ setfullscreen(Client *c, int fullscreen) client_set_fullscreen(c, fullscreen); if (fullscreen) { - c->prevx = c->geom.x; - c->prevy = c->geom.y; - c->prevheight = c->geom.height; - c->prevwidth = c->geom.width; + c->prev = c->geom; resize(c, c->mon->m.x, c->mon->m.y, c->mon->m.width, c->mon->m.height, 0); } else { /* restore previous size instead of arrange for floating windows since * client positions are set by the user and cannot be recalculated */ - resize(c, c->prevx, c->prevy, c->prevwidth, c->prevheight, 0); + resize(c, c->prev.x, c->prev.y, c->prev.width, c->prev.height, 0); arrange(c->mon); } } -- cgit v1.2.3 From 0e5d7124de4e7ba0baa080547fcfee41b1d5174d Mon Sep 17 00:00:00 2001 From: Leonardo Hernandez Hernandez Date: Wed, 26 Jan 2022 00:54:00 -0600 Subject: use loop to call arrangelayer zwlr_layer_shell_v1_layer are ordered by bottom-most first so we can just use a loop from 3 to 0 --- dwl.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/dwl.c b/dwl.c index 9991c95..cd9e74d 100644 --- a/dwl.c +++ b/dwl.c @@ -560,6 +560,7 @@ arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int void arrangelayers(Monitor *m) { + int i; struct wlr_box usable_area = m->m; uint32_t layers_above_shell[] = { ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY, @@ -568,30 +569,18 @@ arrangelayers(Monitor *m) LayerSurface *layersurface; struct wlr_keyboard *kb = wlr_seat_get_keyboard(seat); - // Arrange exclusive surfaces from top->bottom - arrangelayer(m, &m->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], - &usable_area, 1); - arrangelayer(m, &m->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP], - &usable_area, 1); - arrangelayer(m, &m->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM], - &usable_area, 1); - arrangelayer(m, &m->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], - &usable_area, 1); + /* Arrange exclusive surfaces from top->bottom */ + for (i = 3; i >= 0; i--) + arrangelayer(m, &m->layers[i], &usable_area, 1); if (memcmp(&usable_area, &m->w, sizeof(struct wlr_box))) { m->w = usable_area; arrange(m); } - // Arrange non-exlusive surfaces from top->bottom - arrangelayer(m, &m->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], - &usable_area, 0); - arrangelayer(m, &m->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP], - &usable_area, 0); - arrangelayer(m, &m->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM], - &usable_area, 0); - arrangelayer(m, &m->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], - &usable_area, 0); + /* Arrange non-exlusive surfaces from top->bottom */ + for (i = 3; i >= 0; i--) + arrangelayer(m, &m->layers[i], &usable_area, 0); // Find topmost keyboard interactive layer, if such a layer exists for (size_t i = 0; i < LENGTH(layers_above_shell); i++) { -- cgit v1.2.3 From 4d26d302200f20294b97d01e49a9a4a7f0b189d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= Date: Fri, 11 Mar 2022 18:52:22 -0600 Subject: suckless style: don't use '//' for comments --- dwl.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/dwl.c b/dwl.c index cd9e74d..47b5187 100644 --- a/dwl.c +++ b/dwl.c @@ -164,7 +164,7 @@ struct Monitor { struct wl_listener destroy; struct wlr_box m; /* monitor area, layout-relative */ struct wlr_box w; /* window area, layout-relative */ - struct wl_list layers[4]; // LayerSurface::link + struct wl_list layers[4]; /* LayerSurface::link */ const Layout *lt[2]; unsigned int seltags; unsigned int sellt; @@ -394,7 +394,7 @@ applyexclusive(struct wlr_box *usable_area, int32_t margin_top, int32_t margin_right, int32_t margin_bottom, int32_t margin_left) { Edge edges[] = { - { // Top + { /* Top */ .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP, .anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | @@ -403,7 +403,7 @@ applyexclusive(struct wlr_box *usable_area, .negative_axis = &usable_area->height, .margin = margin_top, }, - { // Bottom + { /* Bottom */ .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM, .anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | @@ -412,7 +412,7 @@ applyexclusive(struct wlr_box *usable_area, .negative_axis = &usable_area->height, .margin = margin_bottom, }, - { // Left + { /* Left */ .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT, .anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | @@ -421,7 +421,7 @@ applyexclusive(struct wlr_box *usable_area, .negative_axis = &usable_area->width, .margin = margin_left, }, - { // Right + { /* Right */ .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT, .anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | @@ -504,7 +504,7 @@ arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int bounds = state->exclusive_zone == -1 ? full_area : *usable_area; - // Horizontal axis + /* Horizontal axis */ if ((state->anchor & both_horiz) && box.width == 0) { box.x = bounds.x; box.width = bounds.width; @@ -515,7 +515,7 @@ arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int } else { box.x = bounds.x + ((bounds.width / 2) - (box.width / 2)); } - // Vertical axis + /* Vertical axis */ if ((state->anchor & both_vert) && box.height == 0) { box.y = bounds.y; box.height = bounds.height; @@ -526,7 +526,7 @@ arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int } else { box.y = bounds.y + ((bounds.height / 2) - (box.height / 2)); } - // Margin + /* Margin */ if ((state->anchor & both_horiz) == both_horiz) { box.x += state->margin.left; box.width -= state->margin.left + state->margin.right; @@ -582,13 +582,13 @@ arrangelayers(Monitor *m) for (i = 3; i >= 0; i--) arrangelayer(m, &m->layers[i], &usable_area, 0); - // Find topmost keyboard interactive layer, if such a layer exists + /* Find topmost keyboard interactive layer, if such a layer exists */ for (size_t i = 0; i < LENGTH(layers_above_shell); i++) { wl_list_for_each_reverse(layersurface, &m->layers[layers_above_shell[i]], link) { if (layersurface->layer_surface->current.keyboard_interactive && layersurface->layer_surface->mapped) { - // Deactivate the focused client. + /* Deactivate the focused client. */ focusclient(NULL, 0); wlr_seat_keyboard_notify_enter(seat, layersurface->layer_surface->surface, kb->keycodes, kb->num_keycodes, &kb->modifiers); @@ -706,7 +706,7 @@ cleanupmon(struct wl_listener *listener, void *data) wlr_output_layout_remove(output_layout, m->wlr_output); if ((nmons = wl_list_length(&mons))) - do // don't switch to disabled mons + do /* don't switch to disabled mons */ selmon = wl_container_of(mons.prev, selmon, link); while (!selmon->wlr_output->enabled && i++ < nmons); @@ -718,7 +718,7 @@ cleanupmon(struct wl_listener *listener, void *data) void closemon(Monitor *m) { - // move closed monitor's clients to the focused one + /* move closed monitor's clients to the focused one */ Client *c; wl_list_for_each(c, &clients, link) { @@ -932,8 +932,9 @@ createlayersurface(struct wl_listener *listener, void *data) wl_list_insert(&m->layers[wlr_layer_surface->pending.layer], &layersurface->link); - // Temporarily set the layer's current state to pending - // so that we can easily arrange it + /* Temporarily set the layer's current state to pending + * so that we can easily arrange it + */ old_state = wlr_layer_surface->current; wlr_layer_surface->current = wlr_layer_surface->pending; arrangelayers(m); @@ -1352,7 +1353,7 @@ motionnotify(uint32_t time) struct wlr_surface *surface = NULL; Client *c = NULL; - // time is 0 in internal calls meant to restore pointer focus. + /* time is 0 in internal calls meant to restore pointer focus. */ if (time) { wlr_idle_notify_activity(idle, seat); @@ -2607,8 +2608,7 @@ main(int argc, char *argv[]) if (optind < argc) goto usage; - // Wayland requires XDG_RUNTIME_DIR for creating its communications - // socket + /* Wayland requires XDG_RUNTIME_DIR for creating its communications socket */ if (!getenv("XDG_RUNTIME_DIR")) BARF("XDG_RUNTIME_DIR must be set"); setup(); -- cgit v1.2.3 From 08020d61b7ed2c13a544c7c3f051754088475a2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= Date: Fri, 11 Mar 2022 23:02:37 -0600 Subject: more style fixes --- dwl.c | 45 +++++++++++++++++---------------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/dwl.c b/dwl.c index 47b5187..65244e7 100644 --- a/dwl.c +++ b/dwl.c @@ -623,7 +623,7 @@ buttonpress(struct wl_listener *listener, void *data) wlr_idle_notify_activity(idle, seat); switch (event->state) { - case WLR_BUTTON_PRESSED:; + case WLR_BUTTON_PRESSED: /* Change focus if the button was _pressed_ over a client */ if ((c = xytoclient(cursor->x, cursor->y))) focusclient(c, 1); @@ -642,8 +642,7 @@ buttonpress(struct wl_listener *listener, void *data) /* If you released any buttons, we exit interactive move/resize mode. */ /* TODO should reset to the pointer focus's current setcursor */ if (cursor_mode != CurNormal) { - wlr_xcursor_manager_set_cursor_image(cursor_mgr, - "left_ptr", cursor); + wlr_xcursor_manager_set_cursor_image(cursor_mgr, "left_ptr", cursor); cursor_mode = CurNormal; /* Drop the window off on its new monitor */ selmon = xytomon(cursor->x, cursor->y); @@ -1278,16 +1277,16 @@ void killclient(const Arg *arg) { Client *sel = selclient(); - if (!sel) - return; - client_send_close(sel); + if (sel) + client_send_close(sel); } void maplayersurfacenotify(struct wl_listener *listener, void *data) { LayerSurface *layersurface = wl_container_of(listener, layersurface, map); - wlr_surface_send_enter(layersurface->layer_surface->surface, layersurface->layer_surface->output); + wlr_surface_send_enter(layersurface->layer_surface->surface, + layersurface->layer_surface->output); motionnotify(0); } @@ -1406,8 +1405,7 @@ motionnotify(uint32_t time) * default. This is what makes the cursor image appear when you move it * off of a client or over its border. */ if (!surface && time) - wlr_xcursor_manager_set_cursor_image(cursor_mgr, - "left_ptr", cursor); + wlr_xcursor_manager_set_cursor_image(cursor_mgr, "left_ptr", cursor); pointerfocus(c, surface, sx, sy, time); } @@ -1423,8 +1421,7 @@ motionrelative(struct wl_listener *listener, void *data) * special configuration applied for the specific input device which * generated the event. You can pass NULL for the device if you want to move * the cursor around without any input. */ - wlr_cursor_move(cursor, event->device, - event->delta_x, event->delta_y); + wlr_cursor_move(cursor, event->device, event->delta_x, event->delta_y); motionnotify(event->time_msec); } @@ -1644,8 +1641,7 @@ render(struct wlr_surface *surface, int sx, int sy, void *data) * compositor. */ transform = wlr_output_transform_invert(surface->current.transform); - wlr_matrix_project_box(matrix, &obox, transform, 0, - output->transform_matrix); + wlr_matrix_project_box(matrix, &obox, transform, 0, output->transform_matrix); /* This takes our matrix, the texture, and an alpha, and performs the actual * rendering on the GPU. */ @@ -1678,8 +1674,7 @@ renderclients(Monitor *m, struct timespec *now) surface = client_surface(c); ox = c->geom.x, oy = c->geom.y; - wlr_output_layout_output_coords(output_layout, m->wlr_output, - &ox, &oy); + wlr_output_layout_output_coords(output_layout, m->wlr_output, &ox, &oy); if (c->bw) { w = surface->current.width; @@ -1695,8 +1690,7 @@ renderclients(Monitor *m, struct timespec *now) color = (c == sel) ? focuscolor : bordercolor; for (i = 0; i < 4; i++) { scalebox(&borders[i], m->wlr_output->scale); - wlr_render_rect(drw, &borders[i], color, - m->wlr_output->transform_matrix); + wlr_render_rect(drw, &borders[i], color, m->wlr_output->transform_matrix); } } @@ -2113,12 +2107,9 @@ setup(void) wl_signal_add(&virtual_keyboard_mgr->events.new_virtual_keyboard, &new_virtual_keyboard); seat = wlr_seat_create(dpy, "seat0"); - wl_signal_add(&seat->events.request_set_cursor, - &request_cursor); - wl_signal_add(&seat->events.request_set_selection, - &request_set_sel); - wl_signal_add(&seat->events.request_set_primary_selection, - &request_set_psel); + wl_signal_add(&seat->events.request_set_cursor, &request_cursor); + wl_signal_add(&seat->events.request_set_selection, &request_set_sel); + wl_signal_add(&seat->events.request_set_primary_selection, &request_set_psel); output_mgr = wlr_output_manager_v1_create(dpy); wl_signal_add(&output_mgr->events.apply, &output_mgr_apply); @@ -2226,10 +2217,9 @@ void togglefloating(const Arg *arg) { Client *sel = selclient(); - if (!sel) - return; /* return if fullscreen */ - setfloating(sel, !sel->isfloating /* || sel->isfixed */); + if (sel && !sel->isfullscreen) + setfloating(sel, !sel->isfloating); } void @@ -2491,8 +2481,7 @@ createnotifyx11(struct wl_listener *listener, void *data) /* Listen to the various events it can emit */ LISTEN(&xwayland_surface->events.map, &c->map, mapnotify); LISTEN(&xwayland_surface->events.unmap, &c->unmap, unmapnotify); - LISTEN(&xwayland_surface->events.request_activate, &c->activate, - activatex11); + LISTEN(&xwayland_surface->events.request_activate, &c->activate, activatex11); LISTEN(&xwayland_surface->events.request_configure, &c->configure, configurex11); LISTEN(&xwayland_surface->events.set_title, &c->set_title, updatetitle); -- cgit v1.2.3 From 2cd0b3173d2ba7078347a8172b497d12fa592549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= Date: Sun, 13 Mar 2022 15:16:06 -0600 Subject: print status about floating and fullscreen --- dwl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dwl.c b/dwl.c index 65244e7..1388acb 100644 --- a/dwl.c +++ b/dwl.c @@ -1036,6 +1036,7 @@ setfullscreen(Client *c, int fullscreen) resize(c, c->prev.x, c->prev.y, c->prev.width, c->prev.height, 0); arrange(c->mon); } + printstatus(); } void @@ -1568,10 +1569,14 @@ printstatus(void) urg |= c->tags; } if ((c = focustop(m))) { - printf("%s title %s\n", m->wlr_output->name, client_get_title(focustop(m))); + printf("%s title %s\n", m->wlr_output->name, client_get_title(c)); + printf("%s fullscreen %u\n", m->wlr_output->name, c->isfullscreen); + printf("%s floating %u\n", m->wlr_output->name, c->isfloating); sel = c->tags; } else { printf("%s title \n", m->wlr_output->name); + printf("%s fullscreen \n", m->wlr_output->name); + printf("%s floating \n", m->wlr_output->name); sel = 0; } @@ -1902,6 +1907,7 @@ setfloating(Client *c, int floating) { c->isfloating = floating; arrange(c->mon); + printstatus(); } void -- cgit v1.2.3 From ebff6e38a02086bd6078a444641a83cb226f9995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= Date: Sun, 13 Mar 2022 17:11:52 -0600 Subject: always call arrange() on setfullscreen() also don't count full screen clients on tile() --- dwl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dwl.c b/dwl.c index 1388acb..20e7c5c 100644 --- a/dwl.c +++ b/dwl.c @@ -1034,8 +1034,8 @@ setfullscreen(Client *c, int fullscreen) /* restore previous size instead of arrange for floating windows since * client positions are set by the user and cannot be recalculated */ resize(c, c->prev.x, c->prev.y, c->prev.width, c->prev.height, 0); - arrange(c->mon); } + arrange(c->mon); printstatus(); } @@ -2193,7 +2193,7 @@ tile(Monitor *m) Client *c; wl_list_for_each(c, &clients, link) - if (VISIBLEON(c, m) && !c->isfloating) + if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen) n++; if (n == 0) return; -- cgit v1.2.3 From 43228bd493f53f996a645156f0505b63e79a4f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= 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 From 2768af5a9bfd7cb5f874a8d61f4bc9a1188b82fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= Date: Wed, 16 Mar 2022 21:42:45 -0600 Subject: make sure configure and activate listeners are removed from list --- dwl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dwl.c b/dwl.c index 3c57c23..09ddc9a 100644 --- a/dwl.c +++ b/dwl.c @@ -1004,9 +1004,10 @@ destroynotify(struct wl_listener *listener, void *data) wl_list_remove(&c->set_title.link); wl_list_remove(&c->fullscreen.link); #ifdef XWAYLAND - if (c->type == X11Managed) + if (c->type != XDGShell) { + wl_list_remove(&c->configure.link); wl_list_remove(&c->activate.link); - else if (c->type == XDGShell) + } else #endif wl_list_remove(&c->commit.link); free(c); -- cgit v1.2.3