From ac6074f4fdb8cc263c877f08e16a5805d3bb22d2 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Wed, 24 Jan 2024 22:47:50 +0100 Subject: [PATCH 1/2] implement the virtual pointer protocol This is used by programs like warpd. --- dwl.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/dwl.c b/dwl.c index 239f7d7..76ed8aa 100644 --- a/dwl.c +++ b/dwl.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -328,6 +329,7 @@ static void updatetitle(struct wl_listener *listener, void *data); static void urgent(struct wl_listener *listener, void *data); static void view(const Arg *arg); static void virtualkeyboard(struct wl_listener *listener, void *data); +static void virtualpointer(struct wl_listener *listener, void *data); static Monitor *xytomon(double x, double y); static void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc, LayerSurface **pl, double *nx, double *ny); @@ -361,6 +363,7 @@ static struct wlr_layer_shell_v1 *layer_shell; static struct wlr_output_manager_v1 *output_mgr; static struct wlr_gamma_control_manager_v1 *gamma_control_mgr; static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr; +static struct wlr_virtual_pointer_manager_v1 *virtual_pointer_mgr; static struct wlr_cursor_shape_manager_v1 *cursor_shape_mgr; static struct wlr_cursor *cursor; @@ -2330,6 +2333,9 @@ setup(void) LISTEN_STATIC(&backend->events.new_input, inputdevice); virtual_keyboard_mgr = wlr_virtual_keyboard_manager_v1_create(dpy); LISTEN_STATIC(&virtual_keyboard_mgr->events.new_virtual_keyboard, virtualkeyboard); + virtual_pointer_mgr = wlr_virtual_pointer_manager_v1_create(dpy); + LISTEN_STATIC(&virtual_pointer_mgr->events.new_virtual_pointer, virtualpointer); + seat = wlr_seat_create(dpy, "seat0"); LISTEN_STATIC(&seat->events.request_set_cursor, setcursor); LISTEN_STATIC(&seat->events.request_set_selection, setsel); @@ -2731,6 +2737,17 @@ virtualkeyboard(struct wl_listener *listener, void *data) wlr_keyboard_group_add_keyboard(vkb_group.wlr_group, &keyboard->keyboard); } +void +virtualpointer(struct wl_listener *listener, void *data) +{ + struct wlr_virtual_pointer_v1_new_pointer_event *event = data; + struct wlr_pointer pointer = event->new_pointer->pointer; + + wlr_cursor_attach_input_device(cursor, &pointer.base); + if (event->suggested_output) + wlr_cursor_map_input_to_output(cursor, &pointer.base, event->suggested_output); +} + Monitor * xytomon(double x, double y) { From 863634a61cd953ea82d5fd1e4fa4d04e8b48a23f Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Thu, 25 Jan 2024 09:04:14 +0100 Subject: [PATCH 2/2] configure xwayland surfaces without monitors For wine clients often configurex11() is called before mapnotify() and therefore c->mon is NULL. configurex11 just returns early in that case, letting these clients stay in the wrong size. For example only the top left part of winecfg and wine uninstaller is drawn, or confirmation dialogs like when closing wine notepad are too big. Fix this by configuring their surfaces like before 88d386b. --- dwl.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dwl.c b/dwl.c index 76ed8aa..c8283b7 100644 --- a/dwl.c +++ b/dwl.c @@ -2844,8 +2844,12 @@ configurex11(struct wl_listener *listener, void *data) { Client *c = wl_container_of(listener, c, configure); struct wlr_xwayland_surface_configure_event *event = data; - if (!c->mon) + /* TODO: figure out if there is another way to do this */ + if (!c->mon) { + wlr_xwayland_surface_configure(c->surface.xwayland, + event->x, event->y, event->width, event->height); return; + } if (c->isfloating || client_is_unmanaged(c)) resize(c, (struct wlr_box){.x = event->x, .y = event->y, .width = event->width, .height = event->height}, 0);