From e253beaa2b499b1972081cf9931e91ea21badd70 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Wed, 15 Apr 2015 18:18:42 +0200 Subject: [PATCH] wayland: Implement glfwGetCursorPos Closes #499. --- src/wl_init.c | 5 +++++ src/wl_platform.h | 1 + src/wl_window.c | 6 ++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index 0269ee34..8cf40ff9 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -86,6 +86,11 @@ static void pointerHandleMotion(void* data, "Wayland: GLFW_CURSOR_DISABLED not supported"); return; } + else + { + window->wl.cursorPosX = wl_fixed_to_double(sx); + window->wl.cursorPosY = wl_fixed_to_double(sy); + } _glfwInputCursorMotion(window, wl_fixed_to_double(sx), diff --git a/src/wl_platform.h b/src/wl_platform.h index 66736b56..4c813d4d 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -66,6 +66,7 @@ typedef struct _GLFWwindowWayland struct wl_shell_surface* shell_surface; struct wl_callback* callback; _GLFWcursor* currentCursor; + double cursorPosX, cursorPosY; } _GLFWwindowWayland; diff --git a/src/wl_window.c b/src/wl_window.c index 3492aed5..a6d1b866 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -379,8 +379,10 @@ void _glfwPlatformPostEmptyEvent(void) void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos) { - // TODO - fprintf(stderr, "_glfwPlatformGetCursorPos not implemented yet\n"); + if (xpos) + *xpos = window->wl.cursorX; + if (ypos) + *ypos = window->wl.cursorY; } void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)