From d4cbe451fcf0ae0625c0aecceddbbf9a0c33d1c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 15 Aug 2018 12:52:00 +0200 Subject: [PATCH] Win32: Clean up cursor shape translation --- src/win32_window.c | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/src/win32_window.c b/src/win32_window.c index a689bdfe..570abc15 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -396,29 +396,6 @@ static void updateFramebufferTransparency(const _GLFWwindow* window) } } -// Translates a GLFW standard cursor to a resource ID -// -static LPWSTR translateCursorShape(int shape) -{ - switch (shape) - { - case GLFW_ARROW_CURSOR: - return IDC_ARROW; - case GLFW_IBEAM_CURSOR: - return IDC_IBEAM; - case GLFW_CROSSHAIR_CURSOR: - return IDC_CROSS; - case GLFW_HAND_CURSOR: - return IDC_HAND; - case GLFW_HRESIZE_CURSOR: - return IDC_SIZEWE; - case GLFW_VRESIZE_CURSOR: - return IDC_SIZENS; - } - - return NULL; -} - // Retrieves and translates modifier keys // static int getKeyMods(void) @@ -1862,8 +1839,24 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor, int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) { - cursor->win32.handle = - CopyCursor(LoadCursorW(NULL, translateCursorShape(shape))); + LPCWSTR name = NULL; + + if (shape == GLFW_ARROW_CURSOR) + name = IDC_ARROW; + else if (shape == GLFW_IBEAM_CURSOR) + name = IDC_IBEAM; + else if (shape == GLFW_CROSSHAIR_CURSOR) + name = IDC_CROSS; + else if (shape == GLFW_HAND_CURSOR) + name = IDC_HAND; + else if (shape == GLFW_HRESIZE_CURSOR) + name = IDC_SIZEWE; + else if (shape == GLFW_VRESIZE_CURSOR) + name = IDC_SIZENS; + else + return GLFW_FALSE; + + cursor->win32.handle = CopyCursor(LoadCursorW(NULL, name)); if (!cursor->win32.handle) { _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,