1
0
mirror of https://codeberg.org/vyivel/dulcepan/ synced 2025-03-12 10:49:15 +02:00

seat: set default cursor on enter

Fixes: https://codeberg.org/vyivel/dulcepan/issues/5
This commit is contained in:
Kirill Primak 2024-06-20 08:28:50 +03:00
parent 4ffc074c10
commit afb4bf1a39
4 changed files with 17 additions and 0 deletions

View File

@ -14,8 +14,10 @@ wayland_scanner_client = generator(
) )
client_protocols = [ client_protocols = [
wl_protocol_dir / 'stable/tablet/tablet-v2.xml', # cursor-shape dependency
wl_protocol_dir / 'stable/viewporter/viewporter.xml', wl_protocol_dir / 'stable/viewporter/viewporter.xml',
wl_protocol_dir / 'stable/xdg-shell/xdg-shell.xml', # layer-shell dependency wl_protocol_dir / 'stable/xdg-shell/xdg-shell.xml', # layer-shell dependency
wl_protocol_dir / 'staging/cursor-shape/cursor-shape-v1.xml',
'wlr-layer-shell-unstable-v1.xml', 'wlr-layer-shell-unstable-v1.xml',
'wlr-screencopy-unstable-v1.xml', 'wlr-screencopy-unstable-v1.xml',
] ]

View File

@ -76,6 +76,8 @@ struct dp_seat {
struct xkb_keymap *xkb_keymap; struct xkb_keymap *xkb_keymap;
struct xkb_state *xkb_state; struct xkb_state *xkb_state;
struct wp_cursor_shape_device_v1 *cursor_shape_device;
// The output the pointer is on // The output the pointer is on
struct dp_output *ptr_output; struct dp_output *ptr_output;
// In buffer space // In buffer space
@ -121,6 +123,7 @@ struct dp_state {
struct wl_shm *shm; struct wl_shm *shm;
struct zwlr_layer_shell_v1 *layer_shell; struct zwlr_layer_shell_v1 *layer_shell;
struct zwlr_screencopy_manager_v1 *screencopy_manager; struct zwlr_screencopy_manager_v1 *screencopy_manager;
struct wp_cursor_shape_manager_v1 *cursor_shape_manager;
bool initialized; bool initialized;

View File

@ -5,6 +5,7 @@
#include <wayland-client-protocol.h> #include <wayland-client-protocol.h>
#include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon.h>
#include "cursor-shape-v1-protocol.h"
#include "dulcepan.h" #include "dulcepan.h"
#include "viewporter-protocol.h" #include "viewporter-protocol.h"
#include "wlr-layer-shell-unstable-v1-protocol.h" #include "wlr-layer-shell-unstable-v1-protocol.h"
@ -28,6 +29,9 @@ static void registry_handle_global(void *data, struct wl_registry *registry, uin
} else if (strcmp(interface, zwlr_screencopy_manager_v1_interface.name) == 0) { } else if (strcmp(interface, zwlr_screencopy_manager_v1_interface.name) == 0) {
state->screencopy_manager = state->screencopy_manager =
wl_registry_bind(registry, name, &zwlr_screencopy_manager_v1_interface, 1); wl_registry_bind(registry, name, &zwlr_screencopy_manager_v1_interface, 1);
} else if (strcmp(interface, wp_cursor_shape_manager_v1_interface.name) == 0) {
state->cursor_shape_manager =
wl_registry_bind(registry, name, &wp_cursor_shape_manager_v1_interface, 1);
} else if (strcmp(interface, wl_output_interface.name) == 0) { } else if (strcmp(interface, wl_output_interface.name) == 0) {
if (state->initialized) { if (state->initialized) {
dp_log_fatal("An output was added after initialization"); dp_log_fatal("An output was added after initialization");
@ -85,6 +89,8 @@ static void run(struct dp_state *state) {
dp_log_fatal("The compositor has no zwlr_layer_shell_v1"); dp_log_fatal("The compositor has no zwlr_layer_shell_v1");
} else if (state->screencopy_manager == NULL) { } else if (state->screencopy_manager == NULL) {
dp_log_fatal("The compositor has no zwlr_screencopy_manager_v1"); 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)) { if (wl_list_empty(&state->outputs)) {

View File

@ -6,6 +6,7 @@
#include <wayland-client-protocol.h> #include <wayland-client-protocol.h>
#include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon.h>
#include "cursor-shape-v1-protocol.h"
#include "dulcepan.h" #include "dulcepan.h"
static void keyboard_handle_keymap(void *data, struct wl_keyboard *wl_keyboard, static void keyboard_handle_keymap(void *data, struct wl_keyboard *wl_keyboard,
@ -98,6 +99,8 @@ static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer, uint
seat->ptr_output = wl_surface_get_user_data(surface); seat->ptr_output = wl_surface_get_user_data(surface);
assert(seat->ptr_output != NULL); assert(seat->ptr_output != NULL);
save_position(seat, sx, sy); save_position(seat, sx, sy);
wp_cursor_shape_device_v1_set_shape(
seat->cursor_shape_device, serial, WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DEFAULT);
} }
static void pointer_handle_leave( static void pointer_handle_leave(
@ -172,6 +175,8 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat, uint32
if ((caps & WL_SEAT_CAPABILITY_POINTER) != 0 && seat->pointer == NULL) { if ((caps & WL_SEAT_CAPABILITY_POINTER) != 0 && seat->pointer == NULL) {
seat->pointer = wl_seat_get_pointer(wl_seat); seat->pointer = wl_seat_get_pointer(wl_seat);
wl_pointer_add_listener(seat->pointer, &pointer_listener, 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);
} }
} }
@ -206,6 +211,7 @@ void dp_seat_destroy(struct dp_seat *seat) {
} }
if (seat->pointer != NULL) { if (seat->pointer != NULL) {
wl_pointer_release(seat->pointer); wl_pointer_release(seat->pointer);
wp_cursor_shape_device_v1_destroy(seat->cursor_shape_device);
} }
xkb_keymap_unref(seat->xkb_keymap); xkb_keymap_unref(seat->xkb_keymap);