diff options
Diffstat (limited to 'swaynag/swaynag.c')
-rw-r--r-- | swaynag/swaynag.c | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/swaynag/swaynag.c b/swaynag/swaynag.c index 5620155d..6ea739e3 100644 --- a/swaynag/swaynag.c +++ b/swaynag/swaynag.c @@ -153,8 +153,15 @@ static void update_cursor(struct swaynag_seat *seat) { } pointer->cursor_theme = wl_cursor_theme_load( cursor_theme, cursor_size * swaynag->scale, swaynag->shm); - struct wl_cursor *cursor = - wl_cursor_theme_get_cursor(pointer->cursor_theme, "left_ptr"); + if (!pointer->cursor_theme) { + sway_log(SWAY_ERROR, "Failed to load cursor theme"); + return; + } + struct wl_cursor *cursor = wl_cursor_theme_get_cursor(pointer->cursor_theme, "default"); + if (!cursor) { + sway_log(SWAY_ERROR, "Failed to get default cursor from theme"); + return; + } pointer->cursor_image = cursor->images[0]; wl_surface_set_buffer_scale(pointer->cursor_surface, swaynag->scale); @@ -182,11 +189,22 @@ static void wl_pointer_enter(void *data, struct wl_pointer *wl_pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t surface_x, wl_fixed_t surface_y) { struct swaynag_seat *seat = data; + struct swaynag_pointer *pointer = &seat->pointer; pointer->x = wl_fixed_to_int(surface_x); pointer->y = wl_fixed_to_int(surface_y); - pointer->serial = serial; - update_cursor(seat); + + if (seat->swaynag->cursor_shape_manager) { + struct wp_cursor_shape_device_v1 *device = + wp_cursor_shape_manager_v1_get_pointer( + seat->swaynag->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_motion(void *data, struct wl_pointer *wl_pointer, @@ -378,6 +396,9 @@ static void handle_global(void *data, struct wl_registry *registry, } else if (strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) { swaynag->layer_shell = wl_registry_bind( registry, name, &zwlr_layer_shell_v1_interface, 1); + } else if (strcmp(interface, wp_cursor_shape_manager_v1_interface.name) == 0) { + swaynag->cursor_shape_manager = wl_registry_bind( + registry, name, &wp_cursor_shape_manager_v1_interface, 1); } } @@ -456,7 +477,9 @@ void swaynag_setup(struct swaynag *swaynag) { exit(EXIT_FAILURE); } - swaynag_setup_cursors(swaynag); + if (!swaynag->cursor_shape_manager) { + swaynag_setup_cursors(swaynag); + } swaynag->surface = wl_compositor_create_surface(swaynag->compositor); assert(swaynag->surface); @@ -483,10 +506,6 @@ void swaynag_run(struct swaynag *swaynag) { && wl_display_dispatch(swaynag->display) != -1) { // This is intentionally left blank } - - if (swaynag->display) { - wl_display_disconnect(swaynag->display); - } } void swaynag_destroy(struct swaynag *swaynag) { @@ -501,6 +520,7 @@ void swaynag_destroy(struct swaynag *swaynag) { } list_free(swaynag->buttons); free(swaynag->details.message); + free(swaynag->details.details_text); free(swaynag->details.button_up.text); free(swaynag->details.button_down.text); @@ -541,4 +561,8 @@ void swaynag_destroy(struct swaynag *swaynag) { if (swaynag->shm) { wl_shm_destroy(swaynag->shm); } + + if (swaynag->display) { + wl_display_disconnect(swaynag->display); + } } |