From 057d50af8cd54647933021ae20e975a54ecf4408 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Thu, 23 Nov 2023 10:56:01 -0600 Subject: pass wl_display to wlr_output_layout_create (wlroots!4310) References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4310 --- dwl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dwl.c b/dwl.c index 69da91d..de336b7 100644 --- a/dwl.c +++ b/dwl.c @@ -631,7 +631,6 @@ cleanup(void) waitpid(child_pid, NULL, 0); } wlr_xcursor_manager_destroy(cursor_mgr); - wlr_output_layout_destroy(output_layout); wl_display_destroy(dpy); /* Destroy after the wayland display (when the monitors are already destroyed) to avoid destroying them with an invalid scene output. */ @@ -2232,7 +2231,7 @@ setup(void) /* Creates an output layout, which a wlroots utility for working with an * arrangement of screens in a physical layout. */ - output_layout = wlr_output_layout_create(); + output_layout = wlr_output_layout_create(dpy); LISTEN_STATIC(&output_layout->events.change, updatemons); wlr_xdg_output_manager_v1_create(dpy, output_layout); -- cgit v1.2.3 From 3fe3581a5986be10e0736ea6c8ded59c7f44db5f Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Thu, 23 Nov 2023 14:19:10 -0600 Subject: chase wlr_layer_shell_v1.new_surface changes (wlroots!4265) References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4265 --- dwl.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/dwl.c b/dwl.c index de336b7..7b13087 100644 --- a/dwl.c +++ b/dwl.c @@ -707,7 +707,17 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data) LayerSurface *l = wl_container_of(listener, l, surface_commit); struct wlr_layer_surface_v1 *layer_surface = l->layer_surface; struct wlr_scene_tree *scene_layer = layers[layermap[layer_surface->current.layer]]; + struct wlr_layer_surface_v1_state old_state; + if (l->layer_surface->initial_commit) { + /* Temporarily set the layer's current state to pending + * so that we can easily arrange it */ + old_state = l->layer_surface->current; + l->layer_surface->current = l->layer_surface->pending; + arrangelayers(l->mon); + l->layer_surface->current = old_state; + return; + } if (layer_surface->current.committed == 0 && l->mapped == layer_surface->surface->mapped) return; @@ -794,7 +804,6 @@ createlayersurface(struct wl_listener *listener, void *data) LayerSurface *l; struct wlr_surface *surface = layer_surface->surface; struct wlr_scene_tree *scene_layer = layers[layermap[layer_surface->pending.layer]]; - struct wlr_layer_surface_v1_state old_state; if (!layer_surface->output && !(layer_surface->output = selmon ? selmon->wlr_output : NULL)) { @@ -819,15 +828,6 @@ createlayersurface(struct wl_listener *listener, void *data) wl_list_insert(&l->mon->layers[layer_surface->pending.layer],&l->link); wlr_surface_send_enter(surface, layer_surface->output); - - /* Temporarily set the layer's current state to pending - * so that we can easily arrange it - */ - old_state = layer_surface->current; - layer_surface->current = layer_surface->pending; - l->mapped = 1; - arrangelayers(l->mon); - layer_surface->current = old_state; } void @@ -1484,7 +1484,6 @@ locksession(struct wl_listener *listener, void *data) void maplayersurfacenotify(struct wl_listener *listener, void *data) { - LayerSurface *l = wl_container_of(listener, l, map); motionnotify(0); } -- cgit v1.2.3 From 70c5fcc23d3702544c978e81b8f067de596f06d2 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Thu, 23 Nov 2023 14:06:45 -0600 Subject: chase xdg-shell events update (wlroots!4345) References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4345 --- dwl.c | 80 ++++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/dwl.c b/dwl.c index 7b13087..aa3f1b9 100644 --- a/dwl.c +++ b/dwl.c @@ -251,6 +251,7 @@ static void createlocksurface(struct wl_listener *listener, void *data); static void createmon(struct wl_listener *listener, void *data); static void createnotify(struct wl_listener *listener, void *data); static void createpointer(struct wlr_pointer *pointer); +static void createpopup(struct wl_listener *listener, void *data); static void cursorframe(struct wl_listener *listener, void *data); static void destroydragicon(struct wl_listener *listener, void *data); static void destroyidleinhibitor(struct wl_listener *listener, void *data); @@ -739,6 +740,9 @@ commitnotify(struct wl_listener *listener, void *data) { Client *c = wl_container_of(listener, c, commit); + if (c->surface.xdg->initial_commit) + wlr_xdg_toplevel_set_wm_capabilities(c->surface.xdg->toplevel, WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN); + if (client_surface(c)->mapped) resize(c, c->geom, (c->isfloating && !c->isfullscreen)); @@ -926,49 +930,22 @@ createmon(struct wl_listener *listener, void *data) void createnotify(struct wl_listener *listener, void *data) { - /* This event is raised when wlr_xdg_shell receives a new xdg surface from a - * client, either a toplevel (application window) or popup, - * or when wlr_layer_shell receives a new popup from a layer. - * If you want to do something tricky with popups you should check if - * its parent is wlr_xdg_shell or wlr_layer_shell */ - struct wlr_xdg_surface *xdg_surface = data; + /* This event is raised when a client creates a new toplevel (application window). */ + struct wlr_xdg_toplevel *toplevel = data; Client *c = NULL; - LayerSurface *l = NULL; - - if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP) { - struct wlr_box box; - int type = toplevel_from_wlr_surface(xdg_surface->surface, &c, &l); - if (!xdg_surface->popup->parent || type < 0) - return; - xdg_surface->surface->data = wlr_scene_xdg_surface_create( - xdg_surface->popup->parent->data, xdg_surface); - if ((l && !l->mon) || (c && !c->mon)) - return; - box = type == LayerShell ? l->mon->m : c->mon->w; - box.x -= (type == LayerShell ? l->geom.x : c->geom.x); - box.y -= (type == LayerShell ? l->geom.y : c->geom.y); - wlr_xdg_popup_unconstrain_from_box(xdg_surface->popup, &box); - return; - } else if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_NONE) - return; /* Allocate a Client for this surface */ - c = xdg_surface->data = ecalloc(1, sizeof(*c)); - c->surface.xdg = xdg_surface; + c = toplevel->base->data = ecalloc(1, sizeof(*c)); + c->surface.xdg = toplevel->base; c->bw = borderpx; - wlr_xdg_toplevel_set_wm_capabilities(xdg_surface->toplevel, - WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN); - - LISTEN(&xdg_surface->surface->events.commit, &c->commit, commitnotify); - LISTEN(&xdg_surface->surface->events.map, &c->map, mapnotify); - LISTEN(&xdg_surface->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); - LISTEN(&xdg_surface->toplevel->events.request_maximize, &c->maximize, - maximizenotify); + LISTEN(&toplevel->base->surface->events.commit, &c->commit, commitnotify); + LISTEN(&toplevel->base->surface->events.map, &c->map, mapnotify); + LISTEN(&toplevel->base->surface->events.unmap, &c->unmap, unmapnotify); + LISTEN(&toplevel->events.destroy, &c->destroy, destroynotify); + LISTEN(&toplevel->events.request_fullscreen, &c->fullscreen, fullscreennotify); + LISTEN(&toplevel->events.request_maximize, &c->maximize, maximizenotify); + LISTEN(&toplevel->events.set_title, &c->set_title, updatetitle); } void @@ -1015,6 +992,30 @@ createpointer(struct wlr_pointer *pointer) wlr_cursor_attach_input_device(cursor, &pointer->base); } +void +createpopup(struct wl_listener *listener, void *data) +{ + /* This event is raised when a client (either xdg-shell or layer-shell) + * creates a new popup. */ + struct wlr_xdg_popup *popup = data; + LayerSurface *l = NULL; + Client *c = NULL; + struct wlr_box box; + + int type = toplevel_from_wlr_surface(popup->base->surface, &c, &l); + if (!popup->parent || type < 0) + return; + popup->base->surface->data = wlr_scene_xdg_surface_create( + popup->parent->data, popup->base); + if ((l && !l->mon) || (c && !c->mon)) + return; + box = type == LayerShell ? l->mon->m : c->mon->w; + box.x -= (type == LayerShell ? l->geom.x : c->geom.x); + box.y -= (type == LayerShell ? l->geom.y : c->geom.y); + /* FIXME: this send a configure event to a uninitialized wlr_xdg_surface */ + wlr_xdg_popup_unconstrain_from_box(popup, &box); +} + void cursorframe(struct wl_listener *listener, void *data) { @@ -2249,7 +2250,8 @@ setup(void) wl_list_init(&fstack); xdg_shell = wlr_xdg_shell_create(dpy, 6); - LISTEN_STATIC(&xdg_shell->events.new_surface, createnotify); + LISTEN_STATIC(&xdg_shell->events.new_toplevel, createnotify); + LISTEN_STATIC(&xdg_shell->events.new_popup, createpopup); layer_shell = wlr_layer_shell_v1_create(dpy, 3); LISTEN_STATIC(&layer_shell->events.new_surface, createlayersurface); -- cgit v1.2.3 From 05c263de45f9f4ab2262e6bba111e7b95c153556 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Wed, 27 Dec 2023 11:45:36 -0600 Subject: only create wlr_presentation (wlroots!4482) References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4482 --- dwl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dwl.c b/dwl.c index ec2b1c1..d0ac38a 100644 --- a/dwl.c +++ b/dwl.c @@ -2231,6 +2231,7 @@ setup(void) wlr_viewporter_create(dpy); wlr_single_pixel_buffer_manager_v1_create(dpy); wlr_fractional_scale_manager_v1_create(dpy, 1); + wlr_presentation_create(dpy, backend); /* Initializes the interface used to implement urgency hints */ activation = wlr_xdg_activation_v1_create(dpy); @@ -2385,8 +2386,6 @@ setup(void) LISTEN_STATIC(&output_mgr->events.apply, outputmgrapply); LISTEN_STATIC(&output_mgr->events.test, outputmgrtest); - wlr_scene_set_presentation(scene, wlr_presentation_create(dpy, backend)); - /* Make sure XWayland clients don't connect to the parent X server, * e.g when running in the x11 backend or the wayland backend and the * compositor has Xwayland support */ -- cgit v1.2.3 From c222468887b25fa21c34c02ae605d002de218d1c Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Fri, 5 Jan 2024 10:01:16 -0600 Subject: don't send configure events to uninitialized xdg-popups --- dwl.c | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/dwl.c b/dwl.c index d0ac38a..5ab5a0a 100644 --- a/dwl.c +++ b/dwl.c @@ -245,6 +245,7 @@ static void cleanupmon(struct wl_listener *listener, void *data); static void closemon(Monitor *m); static void commitlayersurfacenotify(struct wl_listener *listener, void *data); static void commitnotify(struct wl_listener *listener, void *data); +static void commitpopup(struct wl_listener *listener, void *data); static void createdecoration(struct wl_listener *listener, void *data); static void createidleinhibitor(struct wl_listener *listener, void *data); static void createkeyboard(struct wlr_keyboard *keyboard); @@ -753,6 +754,33 @@ commitnotify(struct wl_listener *listener, void *data) c->resize = 0; } +void +commitpopup(struct wl_listener *listener, void *data) +{ + struct wlr_surface *surface = data; + struct wlr_xdg_popup *popup = wlr_xdg_popup_try_from_wlr_surface(surface); + LayerSurface *l = NULL; + Client *c = NULL; + struct wlr_box box; + int type = -1; + + if (!popup->base->initial_commit) + return; + + type = toplevel_from_wlr_surface(popup->base->surface, &c, &l); + if (!popup->parent || type < 0) + return; + popup->base->surface->data = wlr_scene_xdg_surface_create( + popup->parent->data, popup->base); + if ((l && !l->mon) || (c && !c->mon)) + return; + box = type == LayerShell ? l->mon->m : c->mon->w; + box.x -= (type == LayerShell ? l->geom.x : c->geom.x); + box.y -= (type == LayerShell ? l->geom.y : c->geom.y); + wlr_xdg_popup_unconstrain_from_box(popup, &box); + wl_list_remove(&listener->link); +} + void createdecoration(struct wl_listener *listener, void *data) { @@ -989,22 +1017,7 @@ createpopup(struct wl_listener *listener, void *data) /* This event is raised when a client (either xdg-shell or layer-shell) * creates a new popup. */ struct wlr_xdg_popup *popup = data; - LayerSurface *l = NULL; - Client *c = NULL; - struct wlr_box box; - - int type = toplevel_from_wlr_surface(popup->base->surface, &c, &l); - if (!popup->parent || type < 0) - return; - popup->base->surface->data = wlr_scene_xdg_surface_create( - popup->parent->data, popup->base); - if ((l && !l->mon) || (c && !c->mon)) - return; - box = type == LayerShell ? l->mon->m : c->mon->w; - box.x -= (type == LayerShell ? l->geom.x : c->geom.x); - box.y -= (type == LayerShell ? l->geom.y : c->geom.y); - /* FIXME: this send a configure event to a uninitialized wlr_xdg_surface */ - wlr_xdg_popup_unconstrain_from_box(popup, &box); + LISTEN_STATIC(&popup->base->surface->events.commit, commitpopup); } void -- cgit v1.2.3 From 668022bc906fc7ba4d2092d260fbd10304fec29f Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Fri, 5 Jan 2024 11:12:34 -0600 Subject: don't send configure events to uninitialized xdg-toplevels --- dwl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dwl.c b/dwl.c index 5ab5a0a..7fb1b88 100644 --- a/dwl.c +++ b/dwl.c @@ -1578,8 +1578,9 @@ maximizenotify(struct wl_listener *listener, void *data) * protocol version * wlr_xdg_surface_schedule_configure() is used to send an empty reply. */ Client *c = wl_container_of(listener, c, maximize); - if (wl_resource_get_version(c->surface.xdg->toplevel->resource) - < XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION) + if (c->surface.xdg->initialized + && wl_resource_get_version(c->surface.xdg->toplevel->resource) + < XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION) wlr_xdg_surface_schedule_configure(c->surface.xdg); } -- cgit v1.2.3 From facbe57fcbe74d27809eefdfe6aaac5150fbb954 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Fri, 5 Jan 2024 11:16:16 -0600 Subject: drop wl_drm (wlroots!4397) References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4397 --- dwl.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/dwl.c b/dwl.c index 7fb1b88..c992cbf 100644 --- a/dwl.c +++ b/dwl.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -2216,11 +2215,9 @@ setup(void) * with wlr_scene. */ wlr_renderer_init_wl_shm(drw, dpy); - if (wlr_renderer_get_dmabuf_texture_formats(drw)) { - wlr_drm_create(dpy, drw); + if (wlr_renderer_get_dmabuf_texture_formats(drw)) wlr_scene_set_linux_dmabuf_v1(scene, wlr_linux_dmabuf_v1_create_with_renderer(dpy, 4, drw)); - } /* Autocreates an allocator for us. * The allocator is the bridge between the renderer and the backend. It -- cgit v1.2.3 From f136aa088ab0f439c151b34fb1465abd85ca97ff Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Wed, 24 Jan 2024 12:09:55 -0600 Subject: Revert "drop wl_drm (wlroots!4397)" There still a lot software that uses this protocol This reverts commit facbe57fcbe74d27809eefdfe6aaac5150fbb954. --- dwl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dwl.c b/dwl.c index b899dbb..6d29ec0 100644 --- a/dwl.c +++ b/dwl.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -2216,9 +2217,11 @@ setup(void) * with wlr_scene. */ wlr_renderer_init_wl_shm(drw, dpy); - if (wlr_renderer_get_dmabuf_texture_formats(drw)) + if (wlr_renderer_get_dmabuf_texture_formats(drw)) { + wlr_drm_create(dpy, drw); wlr_scene_set_linux_dmabuf_v1(scene, wlr_linux_dmabuf_v1_create_with_renderer(dpy, 4, drw)); + } /* Autocreates an allocator for us. * The allocator is the bridge between the renderer and the backend. It -- cgit v1.2.3 From b3f33e91479d795436b2c6937d58754eaf18192e Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Wed, 24 Jan 2024 12:10:54 -0600 Subject: add support for axis_relative_direction event (wlroots!4003) References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4003 --- dwl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwl.c b/dwl.c index 6d29ec0..a4e4983 100644 --- a/dwl.c +++ b/dwl.c @@ -549,7 +549,7 @@ axisnotify(struct wl_listener *listener, void *data) /* Notify the client with pointer focus of the axis event. */ wlr_seat_pointer_notify_axis(seat, event->time_msec, event->orientation, event->delta, - event->delta_discrete, event->source); + event->delta_discrete, event->source, event->relative_direction); } void -- cgit v1.2.3 From 4043fc3093a73174cb63653ba9e742b4738f2ee5 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Wed, 24 Jan 2024 12:12:09 -0600 Subject: do not arrange monitor if it's disabled (wlroots!4520) This causes us to send negative values to xdg-configures (e.g a bug in our end) References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4520 --- dwl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dwl.c b/dwl.c index a4e4983..b70d818 100644 --- a/dwl.c +++ b/dwl.c @@ -460,6 +460,10 @@ void arrange(Monitor *m) { Client *c; + + if (!m->wlr_output->enabled) + return; + wl_list_for_each(c, &clients, link) { if (c->mon == m) { wlr_scene_node_set_enabled(&c->scene->node, VISIBLEON(c, m)); -- cgit v1.2.3 From 5fec98b17ac398070ca05ba12fab7c22ea56a753 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Thu, 25 Jan 2024 11:11:40 -0600 Subject: pass wl_event_loop to wlr_backend_autocreate (wlroots!4443) References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4443 --- dwl.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dwl.c b/dwl.c index b70d818..95a6e82 100644 --- a/dwl.c +++ b/dwl.c @@ -341,6 +341,7 @@ static pid_t child_pid = -1; static int locked; static void *exclusive_focus; static struct wl_display *dpy; +static struct wl_event_loop *event_loop; static struct wlr_backend *backend; static struct wlr_scene *scene; static struct wlr_scene_tree *layers[NUM_LAYERS]; @@ -653,6 +654,10 @@ cleanup(void) wl_event_source_remove(kb_group.key_repeat_source); wl_event_source_remove(vkb_group.key_repeat_source); + /* 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 */ + wlr_backend_destroy(backend); + wl_display_destroy(dpy); /* Destroy after the wayland display (when the monitors are already destroyed) to avoid destroying them with an invalid scene output. */ @@ -2191,12 +2196,13 @@ 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(); + event_loop = wl_display_get_event_loop(dpy); /* 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 * if an X11 server is running. */ - if (!(backend = wlr_backend_autocreate(dpy, &session))) + if (!(backend = wlr_backend_autocreate(event_loop, &session))) die("couldn't create backend"); /* Initialize the scene graph used to lay out windows */ @@ -2389,10 +2395,8 @@ setup(void) LISTEN(&vkb_group.wlr_group->keyboard.events.key, &vkb_group.key, keypress); LISTEN(&vkb_group.wlr_group->keyboard.events.modifiers, &vkb_group.modifiers, keypressmod); - kb_group.key_repeat_source = wl_event_loop_add_timer( - wl_display_get_event_loop(dpy), keyrepeat, &kb_group); - vkb_group.key_repeat_source = wl_event_loop_add_timer( - wl_display_get_event_loop(dpy), keyrepeat, &vkb_group); + kb_group.key_repeat_source = wl_event_loop_add_timer(event_loop, keyrepeat, &kb_group); + vkb_group.key_repeat_source = wl_event_loop_add_timer(event_loop, keyrepeat, &vkb_group); /* A seat can only have one keyboard, but this is a limitation of the * Wayland protocol - not wlroots. We assign all connected keyboards to the -- cgit v1.2.3 From c215e8a3e1dae6c3f4789dd404d6266c39d9d2dd Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Tue, 6 Feb 2024 20:30:40 -0600 Subject: send initial configure to xdg-toplevels (wlroots!4396) We still need to fix xdg-popups References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4396 --- dwl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dwl.c b/dwl.c index e9cf506..ac5b19d 100644 --- a/dwl.c +++ b/dwl.c @@ -756,8 +756,11 @@ commitnotify(struct wl_listener *listener, void *data) { Client *c = wl_container_of(listener, c, commit); - if (c->surface.xdg->initial_commit) + if (c->surface.xdg->initial_commit) { wlr_xdg_toplevel_set_wm_capabilities(c->surface.xdg->toplevel, WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN); + wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, 0, 0); + return; + } if (client_surface(c)->mapped && c->mon) resize(c, c->geom, (c->isfloating && !c->isfullscreen)); -- cgit v1.2.3 From 7b3eb7050186d477889b78afa36079fdb7a8ea3b Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Tue, 6 Feb 2024 20:37:36 -0600 Subject: misc fixes to xdg-toplevel-decoration --- dwl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dwl.c b/dwl.c index ac5b19d..e8557ce 100644 --- a/dwl.c +++ b/dwl.c @@ -759,6 +759,8 @@ commitnotify(struct wl_listener *listener, void *data) if (c->surface.xdg->initial_commit) { wlr_xdg_toplevel_set_wm_capabilities(c->surface.xdg->toplevel, WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN); wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, 0, 0); + if (c->decoration) + requestdecorationmode(&c->set_decoration_mode, c->decoration); return; } @@ -1052,6 +1054,7 @@ void destroydecoration(struct wl_listener *listener, void *data) { Client *c = wl_container_of(listener, c, destroy_decoration); + c->decoration = NULL; wl_list_remove(&c->destroy_decoration.link); wl_list_remove(&c->set_decoration_mode.link); @@ -1929,8 +1932,9 @@ void requestdecorationmode(struct wl_listener *listener, void *data) { Client *c = wl_container_of(listener, c, set_decoration_mode); - wlr_xdg_toplevel_decoration_v1_set_mode(c->decoration, - WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); + if (c->surface.xdg->initialized) + wlr_xdg_toplevel_decoration_v1_set_mode(c->decoration, + WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); } void -- cgit v1.2.3 From a0117eea76ce5ca5e6660f5a6f0057e29f268d41 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Thu, 29 Feb 2024 14:05:09 -0600 Subject: use enums from the wayland protocol (wlroots!4575) References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4575 --- dwl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dwl.c b/dwl.c index e8557ce..dfb3a27 100644 --- a/dwl.c +++ b/dwl.c @@ -571,7 +571,7 @@ buttonpress(struct wl_listener *listener, void *data) wlr_idle_notifier_v1_notify_activity(idle_notifier, seat); switch (event->state) { - case WLR_BUTTON_PRESSED: + case WL_POINTER_BUTTON_STATE_PRESSED: cursor_mode = CurPressed; held_grab = seat->pointer_state.focused_surface; if (locked) @@ -592,7 +592,7 @@ buttonpress(struct wl_listener *listener, void *data) } } break; - case WLR_BUTTON_RELEASED: + case WL_POINTER_BUTTON_STATE_RELEASED: held_grab = NULL; /* If you released any buttons, we exit interactive move/resize mode. */ /* TODO should reset to the pointer focus's current setcursor */ -- cgit v1.2.3 From bb734816627b3bad7ea231bfb454777a1c5177ed Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Sun, 21 Apr 2024 15:53:59 -0600 Subject: use wlr_renderer_get_texture_formats (wlroots!4644) References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4644 --- dwl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwl.c b/dwl.c index 1ebc3d4..589b187 100644 --- a/dwl.c +++ b/dwl.c @@ -2341,7 +2341,7 @@ setup(void) * with wlr_scene. */ wlr_renderer_init_wl_shm(drw, dpy); - if (wlr_renderer_get_dmabuf_texture_formats(drw)) { + if (wlr_renderer_get_texture_formats(drw, WLR_BUFFER_CAP_DMABUF)) { wlr_drm_create(dpy, drw); wlr_scene_set_linux_dmabuf_v1(scene, wlr_linux_dmabuf_v1_create_with_renderer(dpy, 4, drw)); -- cgit v1.2.3 From 3b1f0a8a88d0b535c76d2f0e919fd68e3a4c3b89 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Tue, 30 Apr 2024 12:36:10 -0600 Subject: add support for alpha-modifier-v1 (wlroots!4616) References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4616 --- dwl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dwl.c b/dwl.c index 589b187..06db9f4 100644 --- a/dwl.c +++ b/dwl.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -2371,6 +2372,7 @@ setup(void) wlr_single_pixel_buffer_manager_v1_create(dpy); wlr_fractional_scale_manager_v1_create(dpy, 1); wlr_presentation_create(dpy, backend); + wlr_alpha_modifier_v1_create(dpy); /* Initializes the interface used to implement urgency hints */ activation = wlr_xdg_activation_v1_create(dpy); -- cgit v1.2.3 From bf81a128ecddaa63a904c2b08b80ed03619e0eb3 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Mon, 27 May 2024 23:10:40 -0600 Subject: wlroots now allows parallel installs --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a67fdd3..82f23b3 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ DWLDEVCFLAGS = -g -pedantic -Wall -Wextra -Wdeclaration-after-statement -Wno-unu -Werror=strict-prototypes -Werror=implicit -Werror=return-type -Werror=incompatible-pointer-types -Wfloat-conversion # CFLAGS / LDFLAGS -PKGS = wlroots wayland-server xkbcommon libinput $(XLIBS) +PKGS = wlroots-0.18 wayland-server xkbcommon libinput $(XLIBS) DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS) LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(LIBS) -- cgit v1.2.3 From 57b5e41063d27087d3a651b28f1ae6c7d9e2a6da Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Thu, 30 May 2024 15:00:05 -0600 Subject: use enum headers when possible --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 82f23b3..29f24b4 100644 --- a/Makefile +++ b/Makefile @@ -26,13 +26,13 @@ WAYLAND_SCANNER = `$(PKG_CONFIG) --variable=wayland_scanner wayland-scanner` WAYLAND_PROTOCOLS = `$(PKG_CONFIG) --variable=pkgdatadir wayland-protocols` cursor-shape-v1-protocol.h: - $(WAYLAND_SCANNER) server-header \ + $(WAYLAND_SCANNER) enum-header \ $(WAYLAND_PROTOCOLS)/staging/cursor-shape/cursor-shape-v1.xml $@ pointer-constraints-unstable-v1-protocol.h: - $(WAYLAND_SCANNER) server-header \ + $(WAYLAND_SCANNER) enum-header \ $(WAYLAND_PROTOCOLS)/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml $@ wlr-layer-shell-unstable-v1-protocol.h: - $(WAYLAND_SCANNER) server-header \ + $(WAYLAND_SCANNER) enum-header \ protocols/wlr-layer-shell-unstable-v1.xml $@ xdg-shell-protocol.h: $(WAYLAND_SCANNER) server-header \ -- cgit v1.2.3 From a8403d7b4d54e30699424586784cc0265b29d08d Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Fri, 3 May 2024 11:03:18 -0600 Subject: handle gpu resets Fixes: https://codeberg.org/dwl/dwl/issues/601 --- dwl.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/dwl.c b/dwl.c index 9890a6c..7b61ba2 100644 --- a/dwl.c +++ b/dwl.c @@ -289,6 +289,7 @@ static void focusmon(const Arg *arg); static void focusstack(const Arg *arg); static Client *focustop(Monitor *m); static void fullscreennotify(struct wl_listener *listener, void *data); +static void gpureset(struct wl_listener *listener, void *data); static void handlesig(int signo); static void incnmaster(const Arg *arg); static void inputdevice(struct wl_listener *listener, void *data); @@ -1454,6 +1455,30 @@ fullscreennotify(struct wl_listener *listener, void *data) setfullscreen(c, client_wants_fullscreen(c)); } +void +gpureset(struct wl_listener *listener, void *data) +{ + struct wlr_renderer *old_drw = drw; + struct wlr_allocator *old_alloc = alloc; + struct Monitor *m; + if (!(drw = wlr_renderer_autocreate(backend))) + die("couldn't recreate renderer"); + + if (!(alloc = wlr_allocator_autocreate(backend, drw))) + die("couldn't recreate allocator"); + + LISTEN_STATIC(&drw->events.lost, gpureset); + + wlr_compositor_set_renderer(compositor, drw); + + wl_list_for_each(m, &mons, link) { + wlr_output_init_render(m->wlr_output, alloc, drw); + } + + wlr_allocator_destroy(old_alloc); + wlr_renderer_destroy(old_drw); +} + void handlesig(int signo) { @@ -2394,6 +2419,7 @@ setup(void) * supports for shared memory, this configures that for clients. */ if (!(drw = wlr_renderer_autocreate(backend))) die("couldn't create renderer"); + LISTEN_STATIC(&drw->events.lost, gpureset); /* Create shm, drm and linux_dmabuf interfaces by ourselves. * The simplest way is call: -- cgit v1.2.3 From 12b44421c84367a67461f81cacf13297ae673c20 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Sat, 13 Jul 2024 20:23:04 -0600 Subject: bump to linux-dmabuf version 5 --- dwl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwl.c b/dwl.c index 39b2d31..70d99ca 100644 --- a/dwl.c +++ b/dwl.c @@ -2468,7 +2468,7 @@ setup(void) if (wlr_renderer_get_texture_formats(drw, WLR_BUFFER_CAP_DMABUF)) { wlr_drm_create(dpy, drw); wlr_scene_set_linux_dmabuf_v1(scene, - wlr_linux_dmabuf_v1_create_with_renderer(dpy, 4, drw)); + wlr_linux_dmabuf_v1_create_with_renderer(dpy, 5, drw)); } /* Autocreates an allocator for us. -- cgit v1.2.3