From 7c84f254532efda46fdbcaebcf13d62d70193ff0 Mon Sep 17 00:00:00 2001 From: Nicholas Rishel Date: Sat, 11 Apr 2020 21:42:51 -0700 Subject: Fix T75566 Button events now include tabletdata, so move is unnecessary. Generate mouse button events when the system has an event but Wintab did not find a correlated event. Only filter mouse button events, not Win32 Pointer events. Signed-off-by: Nicholas Rishel Maniphest Tasks: T75566 Differential Revision: https://developer.blender.org/D7404 --- intern/ghost/GHOST_Types.h | 3 ++- intern/ghost/intern/GHOST_SystemWin32.cpp | 44 ++++++++++++++++++------------- intern/ghost/intern/GHOST_SystemWin32.h | 13 ++++++--- 3 files changed, 37 insertions(+), 23 deletions(-) (limited to 'intern') diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index 5f0516ae121..e74f80781e4 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -162,7 +162,8 @@ typedef enum { } GHOST_TDrawingContextType; typedef enum { - GHOST_kButtonMaskLeft = 0, + GHOST_kButtonMaskNone, + GHOST_kButtonMaskLeft, GHOST_kButtonMaskMiddle, GHOST_kButtonMaskRight, GHOST_kButtonMaskButton4, diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index ddf5ac14ef3..703c0e42385 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -945,18 +945,11 @@ GHOST_EventButton *GHOST_SystemWin32::processButtonEvent(GHOST_TEventType type, * leave event might have fired before the Windows mouse up event, thus there are still tablet * events to grab. The described behavior was observed in a Wacom Bamboo CTE-450. */ - if (window->m_tabletInRange || window->wintabSysButPressed()) { - if (window->useTabletAPI(GHOST_kTabletWintab) && processWintabEvents(type, window)) { - // Wintab processing only handles in-contact events. - return NULL; - } - else if (window->useTabletAPI(GHOST_kTabletNative)) { - // Win32 Pointer processing handles input while in-range and in-contact events. - return NULL; - } - - // If using Wintab and this was a button down event but no button event was queued while - // processing Wintab packets, fall through to create a button event. + if (window->useTabletAPI(GHOST_kTabletWintab) && + (window->m_tabletInRange || window->wintabSysButPressed()) && + processWintabEvents(type, window, mask, window->getMousePressed())) { + // Wintab processing only handles in-contact events. + return NULL; } return new GHOST_EventButton( @@ -964,7 +957,9 @@ GHOST_EventButton *GHOST_SystemWin32::processButtonEvent(GHOST_TEventType type, } GHOST_TSuccess GHOST_SystemWin32::processWintabEvents(GHOST_TEventType type, - GHOST_WindowWin32 *window) + GHOST_WindowWin32 *window, + GHOST_TButtonMask mask, + bool mousePressed) { GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem(); @@ -974,7 +969,7 @@ GHOST_TSuccess GHOST_SystemWin32::processWintabEvents(GHOST_TEventType type, * to a modifier key (shift, alt, ctrl) or a system event (scroll, etc.) and thus it is not * possible to determine if a mouse click event should occur. */ - if (!window->getMousePressed() && !window->wintabSysButPressed()) { + if (!mousePressed && !window->wintabSysButPressed()) { return GHOST_kFailure; } @@ -997,6 +992,8 @@ GHOST_TSuccess GHOST_SystemWin32::processWintabEvents(GHOST_TEventType type, } } + bool unhandledButton = type != GHOST_kEventCursorMove; + for (; wtiIter != wintabInfo.end(); wtiIter++) { auto info = *wtiIter; @@ -1010,9 +1007,10 @@ GHOST_TSuccess GHOST_SystemWin32::processWintabEvents(GHOST_TEventType type, * don't duplicate the prior button down as it interrupts drawing immediately after * changing a window. */ - if (type == GHOST_kEventButtonDown) { + if (type == GHOST_kEventButtonDown && mask == info.button) { system->pushEvent( new GHOST_EventButton(info.time, info.type, window, info.button, info.tabletData)); + unhandledButton = false; } window->updateWintabSysBut(MousePressed); break; @@ -1022,8 +1020,11 @@ GHOST_TSuccess GHOST_SystemWin32::processWintabEvents(GHOST_TEventType type, info.time, GHOST_kEventCursorMove, window, info.x, info.y, info.tabletData)); break; case GHOST_kEventButtonUp: - system->pushEvent( - new GHOST_EventButton(info.time, info.type, window, info.button, info.tabletData)); + if (type == GHOST_kEventButtonUp && mask == info.button) { + system->pushEvent( + new GHOST_EventButton(info.time, info.type, window, info.button, info.tabletData)); + unhandledButton = false; + } window->updateWintabSysBut(MouseReleased); break; default: @@ -1031,6 +1032,12 @@ GHOST_TSuccess GHOST_SystemWin32::processWintabEvents(GHOST_TEventType type, } } + // No Wintab button found correlating to the system button event, handle it too. + if (unhandledButton) { + system->pushEvent(new GHOST_EventButton( + system->getMilliSeconds(), type, window, mask, GHOST_TABLET_DATA_NONE)); + } + return GHOST_kSuccess; } @@ -1121,7 +1128,8 @@ GHOST_EventCursor *GHOST_SystemWin32::processCursorEvent(GHOST_WindowWin32 *wind if (window->m_tabletInRange || window->wintabSysButPressed()) { if (window->useTabletAPI(GHOST_kTabletWintab) && - processWintabEvents(GHOST_kEventCursorMove, window)) { + processWintabEvents( + GHOST_kEventCursorMove, window, GHOST_kButtonMaskNone, window->getMousePressed())) { return NULL; } else if (window->useTabletAPI(GHOST_kTabletNative)) { diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h index 06582d74918..68aef3e3b30 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.h +++ b/intern/ghost/intern/GHOST_SystemWin32.h @@ -320,10 +320,15 @@ class GHOST_SystemWin32 : public GHOST_System { /** * Creates tablet events from Wintab events. - * \param type The type of pointer event - * \param window The window receiving the event (the active window). - */ - static GHOST_TSuccess processWintabEvents(GHOST_TEventType type, GHOST_WindowWin32 *window); + * \param type The type of pointer event + * \param window The window receiving the event (the active window). + * \param mask The button mask of the calling event. + * \param mousePressed Whether the mouse is currently pressed + */ + static GHOST_TSuccess processWintabEvents(GHOST_TEventType type, + GHOST_WindowWin32 *window, + GHOST_TButtonMask mask, + bool mousePressed); /** * Creates tablet events from pointer events. -- cgit v1.2.3