Also output pointer shape changes when debugging

This commit is contained in:
Kovid Goyal 2024-03-26 09:18:06 +05:30
parent db3a49fc4b
commit 006a047276
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C

18
glfw/wl_window.c vendored
View file

@ -156,9 +156,14 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image, bool is_opaque,
return buffer;
}
static int
typedef struct wayland_cursor_shape {
int which; const char *name;
} wayland_cursor_shape;
static wayland_cursor_shape
glfw_cursor_shape_to_wayland_cursor_shape(GLFWCursorShape g) {
#define C(g, w) case g: return w;
wayland_cursor_shape ans = {-1, ""};
#define C(g, w) case g: ans.which = w; ans.name = #w; return ans;
switch(g) {
/* start glfw to wayland mapping (auto generated by gen-key-constants.py do not edit) */
C(GLFW_DEFAULT_CURSOR, WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DEFAULT);
@ -192,7 +197,7 @@ glfw_cursor_shape_to_wayland_cursor_shape(GLFWCursorShape g) {
C(GLFW_GRAB_CURSOR, WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_GRAB);
C(GLFW_GRABBING_CURSOR, WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_GRABBING);
/* end glfw to wayland mapping */
default: return -1;
default: return ans;
}
#undef C
}
@ -217,9 +222,10 @@ setCursorImage(_GLFWwindow* window, bool on_theme_change) {
_GLFWcursorWayland defaultCursor = {.shape = GLFW_DEFAULT_CURSOR};
_GLFWcursorWayland* cursorWayland = window->cursor ? &window->cursor->wl : &defaultCursor;
if (_glfw.wl.wp_cursor_shape_device_v1) {
int which = glfw_cursor_shape_to_wayland_cursor_shape(cursorWayland->shape);
if (which > -1) {
wp_cursor_shape_device_v1_set_shape(_glfw.wl.wp_cursor_shape_device_v1, _glfw.wl.pointer_enter_serial, (uint32_t)which);
wayland_cursor_shape s = glfw_cursor_shape_to_wayland_cursor_shape(cursorWayland->shape);
if (s.which > -1) {
debug("Changing cursor shape to: %s with serial: %u\n", s.name, _glfw.wl.pointer_enter_serial);
wp_cursor_shape_device_v1_set_shape(_glfw.wl.wp_cursor_shape_device_v1, _glfw.wl.pointer_enter_serial, (uint32_t)s.which);
return;
}
}