diff --git a/protocols/meson.build b/protocols/meson.build index 0a7cc8f..c3df6da 100644 --- a/protocols/meson.build +++ b/protocols/meson.build @@ -14,8 +14,10 @@ wayland_scanner_client = generator( ) client_protocols = [ + wl_protocol_dir / 'stable/tablet/tablet-v2.xml', # cursor-shape dependency wl_protocol_dir / 'stable/viewporter/viewporter.xml', wl_protocol_dir / 'stable/xdg-shell/xdg-shell.xml', # layer-shell dependency + wl_protocol_dir / 'staging/cursor-shape/cursor-shape-v1.xml', 'wlr-layer-shell-unstable-v1.xml', 'wlr-screencopy-unstable-v1.xml', ] diff --git a/src/dulcepan.h b/src/dulcepan.h index 532c4e4..d914a0b 100644 --- a/src/dulcepan.h +++ b/src/dulcepan.h @@ -76,6 +76,8 @@ struct dp_seat { struct xkb_keymap *xkb_keymap; struct xkb_state *xkb_state; + struct wp_cursor_shape_device_v1 *cursor_shape_device; + // The output the pointer is on struct dp_output *ptr_output; // In buffer space @@ -121,6 +123,7 @@ struct dp_state { struct wl_shm *shm; struct zwlr_layer_shell_v1 *layer_shell; struct zwlr_screencopy_manager_v1 *screencopy_manager; + struct wp_cursor_shape_manager_v1 *cursor_shape_manager; bool initialized; diff --git a/src/main.c b/src/main.c index 3548aca..78e6225 100644 --- a/src/main.c +++ b/src/main.c @@ -5,6 +5,7 @@ #include #include +#include "cursor-shape-v1-protocol.h" #include "dulcepan.h" #include "viewporter-protocol.h" #include "wlr-layer-shell-unstable-v1-protocol.h" @@ -28,6 +29,9 @@ static void registry_handle_global(void *data, struct wl_registry *registry, uin } else if (strcmp(interface, zwlr_screencopy_manager_v1_interface.name) == 0) { state->screencopy_manager = wl_registry_bind(registry, name, &zwlr_screencopy_manager_v1_interface, 1); + } else if (strcmp(interface, wp_cursor_shape_manager_v1_interface.name) == 0) { + state->cursor_shape_manager = + wl_registry_bind(registry, name, &wp_cursor_shape_manager_v1_interface, 1); } else if (strcmp(interface, wl_output_interface.name) == 0) { if (state->initialized) { dp_log_fatal("An output was added after initialization"); @@ -85,6 +89,8 @@ static void run(struct dp_state *state) { dp_log_fatal("The compositor has no zwlr_layer_shell_v1"); } else if (state->screencopy_manager == NULL) { dp_log_fatal("The compositor has no zwlr_screencopy_manager_v1"); + } else if (state->cursor_shape_manager == NULL) { + dp_log_fatal("The compositor has no wp_cursor_shape_manager_v1"); } if (wl_list_empty(&state->outputs)) { diff --git a/src/seat.c b/src/seat.c index bccf4fe..a79ba4e 100644 --- a/src/seat.c +++ b/src/seat.c @@ -6,6 +6,7 @@ #include #include +#include "cursor-shape-v1-protocol.h" #include "dulcepan.h" static void keyboard_handle_keymap(void *data, struct wl_keyboard *wl_keyboard, @@ -98,6 +99,8 @@ static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer, uint seat->ptr_output = wl_surface_get_user_data(surface); assert(seat->ptr_output != NULL); save_position(seat, sx, sy); + wp_cursor_shape_device_v1_set_shape( + seat->cursor_shape_device, serial, WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DEFAULT); } static void pointer_handle_leave( @@ -172,6 +175,8 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat, uint32 if ((caps & WL_SEAT_CAPABILITY_POINTER) != 0 && seat->pointer == NULL) { seat->pointer = wl_seat_get_pointer(wl_seat); wl_pointer_add_listener(seat->pointer, &pointer_listener, seat); + seat->cursor_shape_device = wp_cursor_shape_manager_v1_get_pointer( + seat->state->cursor_shape_manager, seat->pointer); } } @@ -206,6 +211,7 @@ void dp_seat_destroy(struct dp_seat *seat) { } if (seat->pointer != NULL) { wl_pointer_release(seat->pointer); + wp_cursor_shape_device_v1_destroy(seat->cursor_shape_device); } xkb_keymap_unref(seat->xkb_keymap);