diff --git a/src/dulcepan.h b/src/dulcepan.h index 821cba6..073d860 100644 --- a/src/dulcepan.h +++ b/src/dulcepan.h @@ -173,6 +173,8 @@ struct dp_state { struct wl_shm *shm; struct zwlr_layer_shell_v1 *layer_shell; struct zwlr_screencopy_manager_v1 *screencopy_manager; + + // Optional struct wp_cursor_shape_manager_v1 *cursor_shape_manager; bool initialized; diff --git a/src/main.c b/src/main.c index 37d3afc..2c1799c 100644 --- a/src/main.c +++ b/src/main.c @@ -89,8 +89,6 @@ 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)) { @@ -150,7 +148,10 @@ static void run(struct dp_state *state) { wl_shm_destroy(state->shm); zwlr_layer_shell_v1_destroy(state->layer_shell); zwlr_screencopy_manager_v1_destroy(state->screencopy_manager); - wp_cursor_shape_manager_v1_destroy(state->cursor_shape_manager); + + if (state->cursor_shape_manager) { + wp_cursor_shape_manager_v1_destroy(state->cursor_shape_manager); + } wl_registry_destroy(registry); } diff --git a/src/seat.c b/src/seat.c index fda4d28..6611ab0 100644 --- a/src/seat.c +++ b/src/seat.c @@ -124,8 +124,10 @@ static enum wp_cursor_shape_device_v1_shape get_cursor_shape(struct dp_selection } static void update_cursor(struct dp_seat *seat) { - wp_cursor_shape_device_v1_set_shape(seat->cursor_shape_device, seat->pointer_serial, - get_cursor_shape(&seat->state->selection)); + if (seat->cursor_shape_device != NULL) { + wp_cursor_shape_device_v1_set_shape(seat->cursor_shape_device, seat->pointer_serial, + get_cursor_shape(&seat->state->selection)); + } } static void process_position(struct dp_seat *seat, wl_fixed_t x, wl_fixed_t y) { @@ -224,8 +226,11 @@ 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); + + if (seat->state->cursor_shape_manager != NULL) { + seat->cursor_shape_device = wp_cursor_shape_manager_v1_get_pointer( + seat->state->cursor_shape_manager, seat->pointer); + } } } @@ -260,6 +265,8 @@ void dp_seat_destroy(struct dp_seat *seat) { } if (seat->pointer != NULL) { wl_pointer_release(seat->pointer); + } + if (seat->cursor_shape_device != NULL) { wp_cursor_shape_device_v1_destroy(seat->cursor_shape_device); }