diff --git a/README.md b/README.md index 5ea88f985..dc106b0ed 100644 --- a/README.md +++ b/README.md @@ -182,6 +182,7 @@ information on what to include when reporting a bug. - Added `GLFW_OSMESA_CONTEXT_API` for creating OpenGL contexts with [OSMesa](https://www.mesa3d.org/osmesa.html) (#281) - Added `GenerateMappings.cmake` script for updating gamepad mappings +- Added `GLFW_MULTI` key/button state for handling of double-click/multi-press - Made `glfwCreateWindowSurface` emit an error when the window has a context (#1194,#1205) - Deprecated window parameter of clipboard string functions @@ -202,6 +203,7 @@ information on what to include when reporting a bug. - Bugfix: The gamma ramp generated by `glfwSetGamma` did not use the monitor ramp size (#1387,#1388) - [Win32] Added system error strings to relevant GLFW error descriptions (#733) +- [Win32] Added 'WM_NBUTTONDBLCLK' message support - [Win32] Moved to `WM_INPUT` for disabled cursor mode motion input (#125) - [Win32] Removed XInput circular deadzone from joystick axis data (#1045) - [Win32] Bugfix: Undecorated windows could not be iconified by the user (#861) @@ -415,6 +417,7 @@ skills. - Jeff Molofee - Alexander Monakov - Pierre Morel + - Romain Moret - Jon Morton - Pierre Moulon - Martins Mozeiko diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 35a781c93..f6ac05c11 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -309,6 +309,13 @@ extern "C" { * @ingroup input */ #define GLFW_REPEAT 2 +/*! @brief The key or mouse button was pressed multiple times (e.g. double-click). + * + * The key or mouse button was pressed multiple times (e.g. double-click). + * + * @ingroup input + */ +#define GLFW_MULTI 3 /*! @} */ /*! @defgroup hat_state Joystick hat states diff --git a/src/win32_window.c b/src/win32_window.c index afcdc9ee2..88ae43d17 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -761,14 +761,21 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, case WM_RBUTTONUP: case WM_MBUTTONUP: case WM_XBUTTONUP: + case WM_LBUTTONDBLCLK: + case WM_RBUTTONDBLCLK: + case WM_MBUTTONDBLCLK: + case WM_XBUTTONDBLCLK: { int i, button, action; - if (uMsg == WM_LBUTTONDOWN || uMsg == WM_LBUTTONUP) + if (uMsg == WM_LBUTTONDOWN || uMsg == WM_LBUTTONUP || + uMsg == WM_LBUTTONDBLCLK) button = GLFW_MOUSE_BUTTON_LEFT; - else if (uMsg == WM_RBUTTONDOWN || uMsg == WM_RBUTTONUP) + else if (uMsg == WM_RBUTTONDOWN || uMsg == WM_RBUTTONUP || + uMsg == WM_RBUTTONDBLCLK) button = GLFW_MOUSE_BUTTON_RIGHT; - else if (uMsg == WM_MBUTTONDOWN || uMsg == WM_MBUTTONUP) + else if (uMsg == WM_MBUTTONDOWN || uMsg == WM_MBUTTONUP || + uMsg == WM_MBUTTONDBLCLK) button = GLFW_MOUSE_BUTTON_MIDDLE; else if (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) button = GLFW_MOUSE_BUTTON_4; @@ -780,12 +787,20 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, { action = GLFW_PRESS; } - else + else if (uMsg == WM_LBUTTONUP || uMsg == WM_RBUTTONUP || + uMsg == WM_MBUTTONUP || uMsg == WM_XBUTTONUP) + { action = GLFW_RELEASE; + } + else + { + action = GLFW_MULTI; + } for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++) { - if (window->mouseButtons[i] == GLFW_PRESS) + if (window->mouseButtons[i] == GLFW_PRESS || + window->mouseButtons[i] == GLFW_MULTI) break; } @@ -796,14 +811,17 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++) { - if (window->mouseButtons[i] == GLFW_PRESS) + if (window->mouseButtons[i] == GLFW_PRESS || + window->mouseButtons[i] == GLFW_MULTI) break; } if (i > GLFW_MOUSE_BUTTON_LAST) ReleaseCapture(); - if (uMsg == WM_XBUTTONDOWN || uMsg == WM_XBUTTONUP) + if (uMsg == WM_XBUTTONDOWN || + uMsg == WM_XBUTTONUP || + uMsg == WM_XBUTTONDBLCLK) return TRUE; return 0; @@ -1299,7 +1317,7 @@ GLFWbool _glfwRegisterWindowClassWin32(void) ZeroMemory(&wc, sizeof(wc)); wc.cbSize = sizeof(wc); - wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; + wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS; wc.lpfnWndProc = (WNDPROC) windowProc; wc.hInstance = GetModuleHandleW(NULL); wc.hCursor = LoadCursorW(NULL, IDC_ARROW); diff --git a/src/window.c b/src/window.c index 24e60054d..06edcef5b 100644 --- a/src/window.c +++ b/src/window.c @@ -60,7 +60,8 @@ void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused) for (button = 0; button <= GLFW_MOUSE_BUTTON_LAST; button++) { - if (window->mouseButtons[button] == GLFW_PRESS) + if (window->mouseButtons[button] == GLFW_PRESS || + window->mouseButtons[button] == GLFW_MULTI) _glfwInputMouseClick(window, button, GLFW_RELEASE, 0); } } diff --git a/tests/events.c b/tests/events.c index 5a0fde04a..cd8d72362 100644 --- a/tests/events.c +++ b/tests/events.c @@ -203,6 +203,8 @@ static const char* get_action_name(int action) return "released"; case GLFW_REPEAT: return "repeated"; + case GLFW_MULTI: + return "multi"; } return "caused unknown action";