diff options
author | Alexander Orzechowski <alex@ozal.ski> | 2023-07-30 16:07:28 -0400 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-07-31 10:34:11 +0200 |
commit | f436de920097963a6c73e250ea4a01b89be31321 (patch) | |
tree | f5957adacfa52e77ac49ff7fda958b5f385a96af /swaybar | |
parent | 6bd11ad0dfb11f8cf7e0ab5330cd2488851c5614 (diff) |
swaybar: Implement wp_cursor_shape_v1
Diffstat (limited to 'swaybar')
-rw-r--r-- | swaybar/bar.c | 21 | ||||
-rw-r--r-- | swaybar/input.c | 15 |
2 files changed, 26 insertions, 10 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c index 5e4ebd97..021fc3bd 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c @@ -362,6 +362,9 @@ static void handle_global(void *data, struct wl_registry *registry, } else if (strcmp(interface, zxdg_output_manager_v1_interface.name) == 0) { bar->xdg_output_manager = wl_registry_bind(registry, name, &zxdg_output_manager_v1_interface, 2); + } else if (strcmp(interface, wp_cursor_shape_manager_v1_interface.name) == 0) { + bar->cursor_shape_manager = wl_registry_bind(registry, name, + &wp_cursor_shape_manager_v1_interface, 1); } } @@ -425,15 +428,17 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) { // Second roundtrip for xdg-output wl_display_roundtrip(bar->display); - struct swaybar_seat *seat; - wl_list_for_each(seat, &bar->seats, link) { - struct swaybar_pointer *pointer = &seat->pointer; - if (!pointer) { - continue; + if (!bar->cursor_shape_manager) { + struct swaybar_seat *seat; + wl_list_for_each(seat, &bar->seats, link) { + struct swaybar_pointer *pointer = &seat->pointer; + if (!pointer) { + continue; + } + pointer->cursor_surface = + wl_compositor_create_surface(bar->compositor); + assert(pointer->cursor_surface); } - pointer->cursor_surface = - wl_compositor_create_surface(bar->compositor); - assert(pointer->cursor_surface); } if (bar->config->status_command) { diff --git a/swaybar/input.c b/swaybar/input.c index 1e6ace00..ada4bc86 100644 --- a/swaybar/input.c +++ b/swaybar/input.c @@ -111,7 +111,7 @@ static void wl_pointer_enter(void *data, struct wl_pointer *wl_pointer, struct swaybar_pointer *pointer = &seat->pointer; seat->pointer.x = wl_fixed_to_double(surface_x); seat->pointer.y = wl_fixed_to_double(surface_y); - pointer->serial = serial; + struct swaybar_output *output; wl_list_for_each(output, &seat->bar->outputs, link) { if (output->surface == surface) { @@ -119,7 +119,18 @@ static void wl_pointer_enter(void *data, struct wl_pointer *wl_pointer, break; } } - update_cursor(seat); + + if (seat->bar->cursor_shape_manager) { + struct wp_cursor_shape_device_v1 *device = + wp_cursor_shape_manager_v1_get_pointer( + seat->bar->cursor_shape_manager, wl_pointer); + wp_cursor_shape_device_v1_set_shape(device, serial, + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DEFAULT); + wp_cursor_shape_device_v1_destroy(device); + } else { + pointer->serial = serial; + update_cursor(seat); + } } static void wl_pointer_leave(void *data, struct wl_pointer *wl_pointer, |