diff options
-rw-r--r-- | include/swaybar/bar.h | 2 | ||||
-rw-r--r-- | swaybar/bar.c | 21 | ||||
-rw-r--r-- | swaybar/input.c | 15 |
3 files changed, 28 insertions, 10 deletions
diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index 3ad0bdf3..197d2190 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h | |||
@@ -4,6 +4,7 @@ | |||
4 | #include "config.h" | 4 | #include "config.h" |
5 | #include "input.h" | 5 | #include "input.h" |
6 | #include "pool-buffer.h" | 6 | #include "pool-buffer.h" |
7 | #include "cursor-shape-v1-client-protocol.h" | ||
7 | #include "wlr-layer-shell-unstable-v1-client-protocol.h" | 8 | #include "wlr-layer-shell-unstable-v1-client-protocol.h" |
8 | #include "xdg-output-unstable-v1-client-protocol.h" | 9 | #include "xdg-output-unstable-v1-client-protocol.h" |
9 | 10 | ||
@@ -30,6 +31,7 @@ struct swaybar { | |||
30 | struct wl_compositor *compositor; | 31 | struct wl_compositor *compositor; |
31 | struct zwlr_layer_shell_v1 *layer_shell; | 32 | struct zwlr_layer_shell_v1 *layer_shell; |
32 | struct zxdg_output_manager_v1 *xdg_output_manager; | 33 | struct zxdg_output_manager_v1 *xdg_output_manager; |
34 | struct wp_cursor_shape_manager_v1 *cursor_shape_manager; | ||
33 | struct wl_shm *shm; | 35 | struct wl_shm *shm; |
34 | 36 | ||
35 | struct swaybar_config *config; | 37 | struct swaybar_config *config; |
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, | |||
362 | } else if (strcmp(interface, zxdg_output_manager_v1_interface.name) == 0) { | 362 | } else if (strcmp(interface, zxdg_output_manager_v1_interface.name) == 0) { |
363 | bar->xdg_output_manager = wl_registry_bind(registry, name, | 363 | bar->xdg_output_manager = wl_registry_bind(registry, name, |
364 | &zxdg_output_manager_v1_interface, 2); | 364 | &zxdg_output_manager_v1_interface, 2); |
365 | } else if (strcmp(interface, wp_cursor_shape_manager_v1_interface.name) == 0) { | ||
366 | bar->cursor_shape_manager = wl_registry_bind(registry, name, | ||
367 | &wp_cursor_shape_manager_v1_interface, 1); | ||
365 | } | 368 | } |
366 | } | 369 | } |
367 | 370 | ||
@@ -425,15 +428,17 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) { | |||
425 | // Second roundtrip for xdg-output | 428 | // Second roundtrip for xdg-output |
426 | wl_display_roundtrip(bar->display); | 429 | wl_display_roundtrip(bar->display); |
427 | 430 | ||
428 | struct swaybar_seat *seat; | 431 | if (!bar->cursor_shape_manager) { |
429 | wl_list_for_each(seat, &bar->seats, link) { | 432 | struct swaybar_seat *seat; |
430 | struct swaybar_pointer *pointer = &seat->pointer; | 433 | wl_list_for_each(seat, &bar->seats, link) { |
431 | if (!pointer) { | 434 | struct swaybar_pointer *pointer = &seat->pointer; |
432 | continue; | 435 | if (!pointer) { |
436 | continue; | ||
437 | } | ||
438 | pointer->cursor_surface = | ||
439 | wl_compositor_create_surface(bar->compositor); | ||
440 | assert(pointer->cursor_surface); | ||
433 | } | 441 | } |
434 | pointer->cursor_surface = | ||
435 | wl_compositor_create_surface(bar->compositor); | ||
436 | assert(pointer->cursor_surface); | ||
437 | } | 442 | } |
438 | 443 | ||
439 | if (bar->config->status_command) { | 444 | 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, | |||
111 | struct swaybar_pointer *pointer = &seat->pointer; | 111 | struct swaybar_pointer *pointer = &seat->pointer; |
112 | seat->pointer.x = wl_fixed_to_double(surface_x); | 112 | seat->pointer.x = wl_fixed_to_double(surface_x); |
113 | seat->pointer.y = wl_fixed_to_double(surface_y); | 113 | seat->pointer.y = wl_fixed_to_double(surface_y); |
114 | pointer->serial = serial; | 114 | |
115 | struct swaybar_output *output; | 115 | struct swaybar_output *output; |
116 | wl_list_for_each(output, &seat->bar->outputs, link) { | 116 | wl_list_for_each(output, &seat->bar->outputs, link) { |
117 | if (output->surface == surface) { | 117 | if (output->surface == surface) { |
@@ -119,7 +119,18 @@ static void wl_pointer_enter(void *data, struct wl_pointer *wl_pointer, | |||
119 | break; | 119 | break; |
120 | } | 120 | } |
121 | } | 121 | } |
122 | update_cursor(seat); | 122 | |
123 | if (seat->bar->cursor_shape_manager) { | ||
124 | struct wp_cursor_shape_device_v1 *device = | ||
125 | wp_cursor_shape_manager_v1_get_pointer( | ||
126 | seat->bar->cursor_shape_manager, wl_pointer); | ||
127 | wp_cursor_shape_device_v1_set_shape(device, serial, | ||
128 | WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DEFAULT); | ||
129 | wp_cursor_shape_device_v1_destroy(device); | ||
130 | } else { | ||
131 | pointer->serial = serial; | ||
132 | update_cursor(seat); | ||
133 | } | ||
123 | } | 134 | } |
124 | 135 | ||
125 | static void wl_pointer_leave(void *data, struct wl_pointer *wl_pointer, | 136 | static void wl_pointer_leave(void *data, struct wl_pointer *wl_pointer, |