From de57f6c315f0ad70b68e083ae9a1822e43f01586 Mon Sep 17 00:00:00 2001 From: A Frederick Christensen Date: Sat, 7 Jun 2025 00:25:30 -0500 Subject: Cleanup comments --- dwl.c | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) (limited to 'dwl.c') diff --git a/dwl.c b/dwl.c index 4816159..775dadf 100644 --- a/dwl.c +++ b/dwl.c @@ -609,8 +609,8 @@ axisnotify(struct wl_listener *listener, void *data) * for example when you move the scroll wheel. */ struct wlr_pointer_axis_event *event = data; wlr_idle_notifier_v1_notify_activity(idle_notifier, seat); - /* TODO: allow usage of scroll whell for mousebindings, it can be implemented - * checking the event's orientation and the delta of the event */ + /* TODO: allow usage of scroll wheel for mousebindings, it can be implemented + * by checking the event's orientation and the delta of the event */ /* Notify the client with pointer focus of the axis event. */ wlr_seat_pointer_notify_axis(seat, event->time_msec, event->orientation, event->delta, @@ -712,8 +712,8 @@ cleanup(void) destroykeyboardgroup(&kb_group->destroy, NULL); - /* If it's not destroyed manually it will cause a use-after-free of wlr_seat. - * Destroy it until it's fixed in the wlroots side */ + /* If it's not destroyed manually, it will cause a use-after-free of wlr_seat. + * Destroy it until it's fixed on the wlroots side */ wlr_backend_destroy(backend); wl_display_destroy(dpy); @@ -858,7 +858,7 @@ commitnotify(struct wl_listener *listener, void *data) /* * Get the monitor this client will be rendered on * Note that if the user set a rule in which the client is placed on - * a different monitor based on its title this will likely select + * a different monitor based on its title, this will likely select * a wrong monitor. */ applyrules(c); @@ -1212,7 +1212,7 @@ cursorconstrain(struct wlr_pointer_constraint_v1 *constraint) void cursorframe(struct wl_listener *listener, void *data) { - /* This event is forwarded by the cursor when a pointer emits an frame + /* This event is forwarded by the cursor when a pointer emits a frame * event. Frame events are sent after regular pointer events to group * multiple events together. For instance, two axis events may happen at the * same time, in which case a frame event won't be sent in between. */ @@ -1508,7 +1508,7 @@ focusstack(const Arg *arg) focusclient(c, 1); } -/* We probably should change the name of this, it sounds like +/* We probably should change the name of this: it sounds like it * will focus the topmost client of this mon, when actually will * only return that client */ Client * @@ -1780,8 +1780,8 @@ mapnotify(struct wl_listener *listener, void *data) /* Set initial monitor, tags, floating status, and focus: * we always consider floating, clients that have parent and thus - * we set the same tags and monitor than its parent, if not - * try to apply rules for them */ + * we set the same tags and monitor as its parent. + * If there is no parent, apply rules */ if ((p = client_get_parent(c))) { c->isfloating = 1; setmon(c, p->mon, p->tags); @@ -1841,8 +1841,7 @@ motionabsolute(struct wl_listener *listener, void *data) * motion event, from 0..1 on each axis. This happens, for example, when * wlroots is running under a Wayland window rather than KMS+DRM, and you * move the mouse over the window. You could enter the window from any edge, - * so we have to warp the mouse there. There is also some hardware which - * emits these events. */ + * so we have to warp the mouse there. Also, some hardware emits these events. */ struct wlr_pointer_motion_absolute_event *event = data; double lx, ly, dx, dy; @@ -2027,9 +2026,9 @@ apply_or_test: ok &= test ? wlr_output_test_state(wlr_output, &state) : wlr_output_commit_state(wlr_output, &state); - /* Don't move monitors if position wouldn't change, this to avoid - * wlroots marking the output as manually configured. - * wlr_output_layout_add does not like disabled outputs */ + /* Don't move monitors if position wouldn't change. This avoids + * wlroots marking the output as manually configured. + * wlr_output_layout_add does not like disabled outputs */ if (!test && wlr_output->enabled && (m->m.x != config_head->state.x || m->m.y != config_head->state.y)) wlr_output_layout_add(output_layout, wlr_output, config_head->state.x, config_head->state.y); @@ -2266,8 +2265,10 @@ run(char *startup_cmd) close(piperw[0]); } - /* Mark stdout as non-blocking to avoid people who does not close stdin - * nor consumes it in their startup script getting dwl frozen */ + /* Mark stdout as non-blocking to avoid the startup script + * causing dwl to freeze when a user neither closes stdin + * nor consumes standard input in his startup script */ + if (fd_set_nonblock(STDOUT_FILENO) < 0) close(STDOUT_FILENO); @@ -2278,7 +2279,7 @@ run(char *startup_cmd) selmon = xytomon(cursor->x, cursor->y); /* TODO hack to get cursor to display in its initial location (100, 100) - * instead of (0, 0) and then jumping. still may not be fully + * instead of (0, 0) and then jumping. Still may not be fully * initialized, as the image/coordinates are not transformed for the * monitor when displayed here */ wlr_cursor_warp_closest(cursor, NULL, cursor->x, cursor->y); @@ -2301,7 +2302,7 @@ setcursor(struct wl_listener *listener, void *data) * event, which will result in the client requesting set the cursor surface */ if (cursor_mode != CurNormal && cursor_mode != CurPressed) return; - /* This can be sent by any client, so we check to make sure this one is + /* This can be sent by any client, so we check to make sure this one * actually has pointer focus first. If so, we can tell the cursor to * use the provided surface as the cursor image. It will set the * hardware cursor on the output that it's currently on and continue to @@ -2317,7 +2318,7 @@ setcursorshape(struct wl_listener *listener, void *data) struct wlr_cursor_shape_manager_v1_request_set_shape_event *event = data; if (cursor_mode != CurNormal && cursor_mode != CurPressed) return; - /* This can be sent by any client, so we check to make sure this one is + /* This can be sent by any client, so we check to make sure this one * actually has pointer focus first. If so, we can tell the cursor to * use the provided cursor shape. */ if (event->seat_client == seat->pointer_state.focused_client) @@ -2420,7 +2421,7 @@ setpsel(struct wl_listener *listener, void *data) { /* This event is raised by the seat when a client wants to set the selection, * usually when the user copies something. wlroots allows compositors to - * ignore such requests if they so choose, but in dwl we always honor + * ignore such requests if they so choose, but in dwl we always honor them */ struct wlr_seat_request_set_primary_selection_event *event = data; wlr_seat_set_primary_selection(seat, event->source, event->serial); @@ -2431,7 +2432,7 @@ setsel(struct wl_listener *listener, void *data) { /* This event is raised by the seat when a client wants to set the selection, * usually when the user copies something. wlroots allows compositors to - * ignore such requests if they so choose, but in dwl we always honor + * ignore such requests if they so choose, but in dwl we always honor them */ struct wlr_seat_request_set_selection_event *event = data; wlr_seat_set_selection(seat, event->source, event->serial); @@ -2478,9 +2479,9 @@ setup(void) wl_signal_add(&drw->events.lost, &gpu_reset); /* Create shm, drm and linux_dmabuf interfaces by ourselves. - * The simplest way is call: + * The simplest way is to call: * wlr_renderer_init_wl_display(drw); - * but we need to create manually the linux_dmabuf interface to integrate it + * but we need to create the linux_dmabuf interface manually to integrate it * with wlr_scene. */ wlr_renderer_init_wl_shm(drw, dpy); @@ -2529,7 +2530,7 @@ setup(void) power_mgr = wlr_output_power_manager_v1_create(dpy); wl_signal_add(&power_mgr->events.set_mode, &output_power_mgr_set_mode); - /* Creates an output layout, which a wlroots utility for working with an + /* Creates an output layout, which is a wlroots utility for working with an * arrangement of screens in a physical layout. */ output_layout = wlr_output_layout_create(dpy); wl_signal_add(&output_layout->events.change, &layout_change); -- cgit v1.3 From d1880b44223701c91b51b319fc69a0f63044f861 Mon Sep 17 00:00:00 2001 From: Nikita Ivanov Date: Tue, 4 Feb 2025 20:51:06 +0100 Subject: Fix crash disabling monitor with locked surface --- dwl.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'dwl.c') diff --git a/dwl.c b/dwl.c index 775dadf..5beef8b 100644 --- a/dwl.c +++ b/dwl.c @@ -739,6 +739,8 @@ cleanupmon(struct wl_listener *listener, void *data) wl_list_remove(&m->frame.link); wl_list_remove(&m->link); wl_list_remove(&m->request_state.link); + if (m->lock_surface) + destroylocksurface(&m->destroy_lock_surface, NULL); m->wlr_output->data = NULL; wlr_output_layout_remove(output_layout, m->wlr_output); wlr_scene_output_destroy(m->scene_output); -- cgit v1.3 From 02f8744a486713bfac41661e7c5590ec11ec8989 Mon Sep 17 00:00:00 2001 From: kilpilainen <> Date: Thu, 27 Mar 2025 16:07:45 +0200 Subject: Use `all-scroll` instead of `fleur` xcursor shape for window dragging When there are no xcursor themes available, Wayland uses its own built-in shapes [1]. Wayland (and thus to extend wlroots) is based on the XDG's cursor spec [2], which itself is based on CSS' [3][4], neither of which define `fleur` shape. So dwl, without any external themes, falls back to `default` shape when dragging a window. There is `all-scroll` shape that is being symlinked to (or vice versa) by `move`, `dnd-move`, `grabbed` and `fleur` shapes by various themes. Since `all-scroll` is being symlinked to anyway, and has been part of all relevant specs as the shape for this use case for a very long time now, use it instead. [1] https://gitlab.freedesktop.org/wayland/wayland/-/blob/main/cursor/cursor-data.h#L559 [2] https://www.freedesktop.org/wiki/Specifications/cursor-spec [3] https://drafts.csswg.org/css-ui/#cursor [4] https://developer.mozilla.org/en-US/docs/Web/CSS/cursor --- dwl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'dwl.c') diff --git a/dwl.c b/dwl.c index 5beef8b..76b7755 100644 --- a/dwl.c +++ b/dwl.c @@ -1965,7 +1965,7 @@ moveresize(const Arg *arg) case CurMove: grabcx = (int)round(cursor->x) - grabc->geom.x; grabcy = (int)round(cursor->y) - grabc->geom.y; - wlr_cursor_set_xcursor(cursor, cursor_mgr, "fleur"); + wlr_cursor_set_xcursor(cursor, cursor_mgr, "all-scroll"); break; case CurResize: /* Doesn't work for X11 output - the next absolute motion event -- cgit v1.3 From ea263a0ed50d62033ca305fe7a4c5c36fddb4755 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Sat, 14 Jun 2025 22:27:25 +0200 Subject: float sub-windows matching a rule Currently when a rule that doesn't make windows floating matches, even sub-windows of float type get tiled rather than just the main window. This is inconsistent with dwm and other compositors. Fix this by making these windows floating after applying rules. Fixes #1142. --- dwl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'dwl.c') diff --git a/dwl.c b/dwl.c index 76b7755..12f441e 100644 --- a/dwl.c +++ b/dwl.c @@ -483,7 +483,6 @@ applyrules(Client *c) const Rule *r; Monitor *mon = selmon, *m; - c->isfloating = client_is_float_type(c); appid = client_get_appid(c); title = client_get_title(c); @@ -499,6 +498,8 @@ applyrules(Client *c) } } } + + c->isfloating |= client_is_float_type(c); setmon(c, mon, newtags); } -- cgit v1.3 From b28674e0ca4a9ecc92cb0607498e3db2df3d4c00 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Tue, 14 Jan 2025 12:34:20 -0600 Subject: add support for ext-image-copy-capture-v1 and ext-image-capture-source-v1 (wlroots!4545) References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4545 --- Makefile | 4 ++++ dwl.c | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'dwl.c') diff --git a/Makefile b/Makefile index 578194f..3981fbb 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,7 @@ all: dwl dwl: dwl.o util.o $(CC) dwl.o util.o $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ dwl.o: dwl.c client.h config.h config.mk cursor-shape-v1-protocol.h \ + ext-image-copy-capture-v1-protocol.h \ pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h \ wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h util.o: util.c util.h @@ -33,6 +34,9 @@ WAYLAND_PROTOCOLS = `$(PKG_CONFIG) --variable=pkgdatadir wayland-protocols` cursor-shape-v1-protocol.h: $(WAYLAND_SCANNER) enum-header \ $(WAYLAND_PROTOCOLS)/staging/cursor-shape/cursor-shape-v1.xml $@ +ext-image-copy-capture-v1-protocol.h: + $(WAYLAND_SCANNER) enum-header \ + $(WAYLAND_PROTOCOLS)/staging/ext-image-copy-capture/ext-image-copy-capture-v1.xml $@ pointer-constraints-unstable-v1-protocol.h: $(WAYLAND_SCANNER) enum-header \ $(WAYLAND_PROTOCOLS)/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml $@ diff --git a/dwl.c b/dwl.c index 12f441e..1dad6ac 100644 --- a/dwl.c +++ b/dwl.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include #include #include @@ -2516,6 +2518,8 @@ setup(void) wlr_data_device_manager_create(dpy); wlr_export_dmabuf_manager_v1_create(dpy); wlr_screencopy_manager_v1_create(dpy); + wlr_ext_image_copy_capture_manager_v1_create(dpy, 1); + wlr_ext_output_image_capture_source_manager_v1_create(dpy, 1); wlr_data_control_manager_v1_create(dpy); wlr_primary_selection_v1_device_manager_create(dpy); wlr_viewporter_create(dpy); -- cgit v1.3 From ab4cb6e28365cf8754d6d3bdd293c05abfc27e26 Mon Sep 17 00:00:00 2001 From: A Frederick Christensen Date: Mon, 4 Aug 2025 16:27:34 -0500 Subject: Revert "add support for ext-image-copy-capture-v1 and ext-image-capture-source-v1 (wlroots!4545)" This reverts commit b28674e0ca4a9ecc92cb0607498e3db2df3d4c00. This PR is not yet finalized. (Screen freezes). --- Makefile | 4 ---- dwl.c | 4 ---- 2 files changed, 8 deletions(-) (limited to 'dwl.c') diff --git a/Makefile b/Makefile index 3981fbb..578194f 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,6 @@ all: dwl dwl: dwl.o util.o $(CC) dwl.o util.o $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ dwl.o: dwl.c client.h config.h config.mk cursor-shape-v1-protocol.h \ - ext-image-copy-capture-v1-protocol.h \ pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h \ wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h util.o: util.c util.h @@ -34,9 +33,6 @@ WAYLAND_PROTOCOLS = `$(PKG_CONFIG) --variable=pkgdatadir wayland-protocols` cursor-shape-v1-protocol.h: $(WAYLAND_SCANNER) enum-header \ $(WAYLAND_PROTOCOLS)/staging/cursor-shape/cursor-shape-v1.xml $@ -ext-image-copy-capture-v1-protocol.h: - $(WAYLAND_SCANNER) enum-header \ - $(WAYLAND_PROTOCOLS)/staging/ext-image-copy-capture/ext-image-copy-capture-v1.xml $@ pointer-constraints-unstable-v1-protocol.h: $(WAYLAND_SCANNER) enum-header \ $(WAYLAND_PROTOCOLS)/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml $@ diff --git a/dwl.c b/dwl.c index 1dad6ac..12f441e 100644 --- a/dwl.c +++ b/dwl.c @@ -24,8 +24,6 @@ #include #include #include -#include -#include #include #include #include @@ -2518,8 +2516,6 @@ setup(void) wlr_data_device_manager_create(dpy); wlr_export_dmabuf_manager_v1_create(dpy); wlr_screencopy_manager_v1_create(dpy); - wlr_ext_image_copy_capture_manager_v1_create(dpy, 1); - wlr_ext_output_image_capture_source_manager_v1_create(dpy, 1); wlr_data_control_manager_v1_create(dpy); wlr_primary_selection_v1_device_manager_create(dpy); wlr_viewporter_create(dpy); -- cgit v1.3