diff --git a/glfw/wl_window.c b/glfw/wl_window.c index 5827d9857..90bcf025f 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -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; } }