aboutsummaryrefslogtreecommitdiffstats
path: root/swaynag/swaynag.c
diff options
context:
space:
mode:
authorLibravatar Alexander Orzechowski <alex@ozal.ski>2023-07-29 16:17:48 -0400
committerLibravatar Simon Ser <contact@emersion.fr>2023-07-31 10:34:11 +0200
commitdf8aad9c5ab70ad646ec1742cc57473c6908a1be (patch)
treebc5d5e65af07577a9d7dd4e73f7cc508d009c110 /swaynag/swaynag.c
parentswaybar: Implement wp_cursor_shape_v1 (diff)
downloadsway-df8aad9c5ab70ad646ec1742cc57473c6908a1be.tar.gz
sway-df8aad9c5ab70ad646ec1742cc57473c6908a1be.tar.zst
sway-df8aad9c5ab70ad646ec1742cc57473c6908a1be.zip
swaynag: Implement wp_cursor_shape_v1
Diffstat (limited to 'swaynag/swaynag.c')
-rw-r--r--swaynag/swaynag.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/swaynag/swaynag.c b/swaynag/swaynag.c
index b45485f7..6ea739e3 100644
--- a/swaynag/swaynag.c
+++ b/swaynag/swaynag.c
@@ -157,8 +157,7 @@ static void update_cursor(struct swaynag_seat *seat) {
157 sway_log(SWAY_ERROR, "Failed to load cursor theme"); 157 sway_log(SWAY_ERROR, "Failed to load cursor theme");
158 return; 158 return;
159 } 159 }
160 struct wl_cursor *cursor = 160 struct wl_cursor *cursor = wl_cursor_theme_get_cursor(pointer->cursor_theme, "default");
161 wl_cursor_theme_get_cursor(pointer->cursor_theme, "default");
162 if (!cursor) { 161 if (!cursor) {
163 sway_log(SWAY_ERROR, "Failed to get default cursor from theme"); 162 sway_log(SWAY_ERROR, "Failed to get default cursor from theme");
164 return; 163 return;
@@ -190,11 +189,22 @@ static void wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
190 uint32_t serial, struct wl_surface *surface, 189 uint32_t serial, struct wl_surface *surface,
191 wl_fixed_t surface_x, wl_fixed_t surface_y) { 190 wl_fixed_t surface_x, wl_fixed_t surface_y) {
192 struct swaynag_seat *seat = data; 191 struct swaynag_seat *seat = data;
192
193 struct swaynag_pointer *pointer = &seat->pointer; 193 struct swaynag_pointer *pointer = &seat->pointer;
194 pointer->x = wl_fixed_to_int(surface_x); 194 pointer->x = wl_fixed_to_int(surface_x);
195 pointer->y = wl_fixed_to_int(surface_y); 195 pointer->y = wl_fixed_to_int(surface_y);
196 pointer->serial = serial; 196
197 update_cursor(seat); 197 if (seat->swaynag->cursor_shape_manager) {
198 struct wp_cursor_shape_device_v1 *device =
199 wp_cursor_shape_manager_v1_get_pointer(
200 seat->swaynag->cursor_shape_manager, wl_pointer);
201 wp_cursor_shape_device_v1_set_shape(device, serial,
202 WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DEFAULT);
203 wp_cursor_shape_device_v1_destroy(device);
204 } else {
205 pointer->serial = serial;
206 update_cursor(seat);
207 }
198} 208}
199 209
200static void wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, 210static void wl_pointer_motion(void *data, struct wl_pointer *wl_pointer,
@@ -386,6 +396,9 @@ static void handle_global(void *data, struct wl_registry *registry,
386 } else if (strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) { 396 } else if (strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) {
387 swaynag->layer_shell = wl_registry_bind( 397 swaynag->layer_shell = wl_registry_bind(
388 registry, name, &zwlr_layer_shell_v1_interface, 1); 398 registry, name, &zwlr_layer_shell_v1_interface, 1);
399 } else if (strcmp(interface, wp_cursor_shape_manager_v1_interface.name) == 0) {
400 swaynag->cursor_shape_manager = wl_registry_bind(
401 registry, name, &wp_cursor_shape_manager_v1_interface, 1);
389 } 402 }
390} 403}
391 404
@@ -464,7 +477,9 @@ void swaynag_setup(struct swaynag *swaynag) {
464 exit(EXIT_FAILURE); 477 exit(EXIT_FAILURE);
465 } 478 }
466 479
467 swaynag_setup_cursors(swaynag); 480 if (!swaynag->cursor_shape_manager) {
481 swaynag_setup_cursors(swaynag);
482 }
468 483
469 swaynag->surface = wl_compositor_create_surface(swaynag->compositor); 484 swaynag->surface = wl_compositor_create_surface(swaynag->compositor);
470 assert(swaynag->surface); 485 assert(swaynag->surface);