[Bf-blender-cvs] [2e81f2c01ab] blender-v2.92-release: Revert Wintab High Frequency Input.

Nicholas Rishel noreply at git.blender.org
Tue Feb 16 08:07:40 CET 2021


Commit: 2e81f2c01abd21fdbc79625f3f7a0778103fa199
Author: Nicholas Rishel
Date:   Mon Feb 15 22:47:52 2021 -0800
Branches: blender-v2.92-release
https://developer.blender.org/rB2e81f2c01abd21fdbc79625f3f7a0778103fa199

Revert Wintab High Frequency Input.

This revert removes handling of cursor move and button press events
during Wintab's WT_PACKET event, instead storing pressure and tilt
information to be combined with Window's WM_MOUSEMOVE events.

This also reverts dynamic enabling and disabling of Wintab, dependent
on the chosen Tablet API. If the Tablet API is not explictly Windows
Ink during startup, Wintab is loaded and enabled.

Left in place is a fallback to Windows Ink when the Tablet API is set
to Automatic and no Wintab devices are present. This allows devices
with Wintab installed but not active to fallback to Windows Ink.

Using position provided by Wintab was found to have too many
regressions to include in Blender 2.93. The primary source of
regressions was tablets which mapped coordinates incorrectly on multi-
monitor and scaled displays. This resulted in an offset between what
the driver controlled Win32 cursor position and the Wintab reported
position. A special case of this included tablets set to mouse mode,
where Wintab reported absolute position while the system cursor moved
as a relative mouse with mouse acceleration.

===================================================================

M	intern/ghost/intern/GHOST_System.h
M	intern/ghost/intern/GHOST_SystemWin32.cpp
M	intern/ghost/intern/GHOST_SystemWin32.h
M	intern/ghost/intern/GHOST_WindowWin32.cpp
M	intern/ghost/intern/GHOST_WindowWin32.h
M	source/blender/makesrna/intern/rna_userdef.c

===================================================================

diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h
index 279f90b9641..2a7123b293e 100644
--- a/intern/ghost/intern/GHOST_System.h
+++ b/intern/ghost/intern/GHOST_System.h
@@ -239,7 +239,7 @@ class GHOST_System : public GHOST_ISystem {
    * Set which tablet API to use. Only affects Windows, other platforms have a single API.
    * \param api: Enum indicating which API to use.
    */
-  virtual void setTabletAPI(GHOST_TTabletAPI api);
+  void setTabletAPI(GHOST_TTabletAPI api);
   GHOST_TTabletAPI getTabletAPI(void);
 
 #ifdef WITH_INPUT_NDOF
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index 718ace9db4a..c86b332d228 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -237,11 +237,6 @@ GHOST_SystemWin32::~GHOST_SystemWin32()
   toggleConsole(1);
 }
 
-GHOST_TUns64 GHOST_SystemWin32::millisSinceStart(__int64 ms) const
-{
-  return (GHOST_TUns64)(ms - m_start * 1000 / m_freq);
-}
-
 GHOST_TUns64 GHOST_SystemWin32::performanceCounterToMillis(__int64 perf_ticks) const
 {
   // Calculate the time passed since system initialization.
@@ -955,101 +950,25 @@ GHOST_EventButton *GHOST_SystemWin32::processButtonEvent(GHOST_TEventType type,
 {
   GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
 
-  GHOST_TabletData td = window->m_tabletInRange ? window->getLastTabletData() :
-                                                  GHOST_TABLET_DATA_NONE;
+  GHOST_TabletData td = GHOST_TABLET_DATA_NONE;
 
-  /* Move mouse to button event position. */
-  if (!window->m_tabletInRange) {
-    processCursorEvent(window);
-  }
-  else {
-    /* Tablet should be hadling inbetween mouse moves, only move to event position. */
+  if (window->m_tabletInRange) {
+    td = window->getTabletData();
+
+    /* Check if tablet cursor position is in sync with Win32 cursor position, if not then move
+     * cursor to position where button event occurred. */
     DWORD msgPos = ::GetMessagePos();
     int msgPosX = GET_X_LPARAM(msgPos);
     int msgPosY = GET_Y_LPARAM(msgPos);
-    system->pushEvent(new GHOST_EventCursor(
-        ::GetMessageTime(), GHOST_kEventCursorMove, window, msgPosX, msgPosY, td));
+    if (msgPosX != system->m_mousePosX || msgPosY != system->m_mousePosY) {
+      system->pushEvent(new GHOST_EventCursor(
+          ::GetMessageTime(), GHOST_kEventCursorMove, window, msgPosX, msgPosY, td));
+    }
   }
 
-  window->updateMouseCapture(type == GHOST_kEventButtonDown ? MousePressed : MouseReleased);
   return new GHOST_EventButton(system->getMilliSeconds(), type, window, mask, td);
 }
 
-void GHOST_SystemWin32::processWintabEvent(GHOST_WindowWin32 *window)
-{
-  GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
-
-  std::vector<GHOST_WintabInfoWin32> wintabInfo;
-  if (!window->getWintabInfo(wintabInfo)) {
-    return;
-  }
-
-  for (auto info : wintabInfo) {
-    switch (info.type) {
-      case GHOST_kEventCursorMove: {
-        system->pushEvent(new GHOST_EventCursor(
-            info.time, GHOST_kEventCursorMove, window, info.x, info.y, info.tabletData));
-        break;
-      }
-      case GHOST_kEventButtonDown: {
-        system->pushEvent(new GHOST_EventCursor(
-            info.time, GHOST_kEventCursorMove, window, info.x, info.y, info.tabletData));
-
-        UINT message;
-        switch (info.button) {
-          case GHOST_kButtonMaskLeft:
-            message = WM_LBUTTONDOWN;
-            break;
-          case GHOST_kButtonMaskRight:
-            message = WM_RBUTTONDOWN;
-            break;
-          case GHOST_kButtonMaskMiddle:
-            message = WM_MBUTTONDOWN;
-            break;
-          default:
-            continue;
-        }
-
-        MSG msg;
-        if (PeekMessage(&msg, window->getHWND(), message, message, PM_REMOVE | PM_NOYIELD) &&
-            WM_QUIT != msg.message) {
-          window->updateMouseCapture(MousePressed);
-          system->pushEvent(
-              new GHOST_EventButton(info.time, info.type, window, info.button, info.tabletData));
-        }
-        break;
-      }
-      case GHOST_kEventButtonUp: {
-        UINT message;
-        switch (info.button) {
-          case GHOST_kButtonMaskLeft:
-            message = WM_LBUTTONUP;
-            break;
-          case GHOST_kButtonMaskRight:
-            message = WM_RBUTTONUP;
-            break;
-          case GHOST_kButtonMaskMiddle:
-            message = WM_MBUTTONUP;
-            break;
-          default:
-            continue;
-        }
-
-        MSG msg;
-        if (PeekMessage(&msg, window->getHWND(), message, message, PM_REMOVE | PM_NOYIELD) &&
-            WM_QUIT != msg.message) {
-          window->updateMouseCapture(MouseReleased);
-          system->pushEvent(
-              new GHOST_EventButton(info.time, info.type, window, info.button, info.tabletData));
-        }
-        break;
-      }
-      default:
-        break;
-    }
-  }
-}
-
 void GHOST_SystemWin32::processPointerEvent(
     UINT type, GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam, bool &eventHandled)
 {
@@ -1129,12 +1048,15 @@ void GHOST_SystemWin32::processPointerEvent(
 
 void GHOST_SystemWin32::processCursorEvent(GHOST_WindowWin32 *window)
 {
-  /* Cursor moves handled by tablets while active. */
-  if (window->m_tabletInRange) {
+  if (window->m_tabletInRange && window->useTabletAPI(GHOST_kTabletNative)) {
+    /* Tablet input handled in WM_POINTER* events. WM_MOUSEMOVE events in response to tablet
+     * input aren't normally generated when using WM_POINTER events, but manually moving the
+     * system cursor as we do in WM_POINTER handling does. */
     return;
   }
 
   GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
+  GHOST_TabletData td = window->getTabletData();
 
   DWORD msgPos = ::GetMessagePos();
   LONG msgTime = ::GetMessageTime();
@@ -1185,13 +1107,13 @@ void GHOST_SystemWin32::processCursorEvent(GHOST_WindowWin32 *window)
                                             window,
                                             points[i].x + x_accum,
                                             points[i].y + y_accum,
-                                            GHOST_TABLET_DATA_NONE));
+                                            td));
   }
 
   DWORD lastTimestamp = points[0].time;
 
   /* Check if we need to wrap the cursor. */
-  if (window->getCursorGrabModeIsWarp()) {
+  if (window->getCursorGrabModeIsWarp() && !window->m_tabletInRange) {
     /* Wrap based on current cursor position in case Win32 mouse move queue is out of order due to
      * prior wrap. */
     POINT point;
@@ -1334,23 +1256,6 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RA
   return event;
 }
 
-GHOST_Event *GHOST_SystemWin32::processWindowSizeEvent(GHOST_WindowWin32 *window)
-{
-  GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
-  GHOST_Event *sizeEvent = new GHOST_Event(
-      system->getMilliSeconds(), GHOST_kEventWindowSize, window);
-
-  /* We get WM_SIZE before we fully init. Do not dispatch before we are continuously resizing. */
-  if (window->m_inLiveResize) {
-    system->pushEvent(sizeEvent);
-    system->dispatchEvents();
-    return NULL;
-  }
-  else {
-    return sizeEvent;
-  }
-}
-
 GHOST_Event *GHOST_SystemWin32::processWindowEvent(GHOST_TEventType type,
                                                    GHOST_WindowWin32 *window)
 {
@@ -1358,6 +1263,7 @@ GHOST_Event *GHOST_SystemWin32::processWindowEvent(GHOST_TEventType type,
 
   if (type == GHOST_kEventWindowActivate) {
     system->getWindowManager()->setActiveWindow(window);
+    window->bringTabletContextToFront();
   }
 
   return new GHOST_Event(system->getMilliSeconds(), type, window);
@@ -1385,18 +1291,6 @@ GHOST_TSuccess GHOST_SystemWin32::pushDragDropEvent(GHOST_TEventType eventType,
       system->getMilliSeconds(), eventType, draggedObjectType, window, mouseX, mouseY, data));
 }
 
-void GHOST_SystemWin32::setTabletAPI(GHOST_TTabletAPI api)
-{
-  GHOST_System::setTabletAPI(api);
-
-  GHOST_WindowManager *wm = getWindowManager();
-
-  for (GHOST_IWindow *win : wm->getWindows()) {
-    GHOST_WindowWin32 *windowWin32 = (GHOST_WindowWin32 *)win;
-    windowWin32->setWintabEnabled(windowWin32->useTabletAPI(GHOST_kTabletWintab));
-  }
-}
-
 void GHOST_SystemWin32::processMinMaxInfo(MINMAXINFO *minmax)
 {
   minmax->ptMinTrackSize.x = 320;
@@ -1636,30 +1530,16 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
         ////////////////////////////////////////////////////////////////////////
         // Wintab events, processed
         ////////////////////////////////////////////////////////////////////////
-        case WT_INFOCHANGE: {
+        case WT_INFOCHANGE:
           window->processWintabInfoChangeEvent(lParam);
           eventHandled = true;
           break;
-        }
-        case WT_CSRCHANGE:
-          window->updateWintabCursorInfo();
-          eventHandled = true;
-          break;
-        case WT_PROXIMITY: {
-          if (window->useTabletAPI(GHOST_kTabletWintab)) {
-            if (LOWORD(lParam)) {
-              window->m_tabletInRange = true;
-            }
-            else {
-              window->processWintabLeave();
-            }
-          }
-          eventHandled = true;
-          break;
-        }
         case WT_PACKET:
-          processWintabEvent(window);
-          eventHandled = true;
+          window->processWin32TabletEvent(wParam, lParam);
+          break;
+        case WT_CSRCHANGE:
+        case WT_PROXIMITY:
+          window->processWin32TabletInitEvent();
           break;
         ////////////////////////////////////////////////////////////////////////
         // Pointer events, processed
@@ -1675,53 +1555,52 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
         // Mouse events, processed
         ////////////////////////////////////////////////////////////////////////
         case WM_LBUTTONDOWN:
+          window->updateMouseCapture(MousePressed);
           event = processButtonEvent(GHOST_kEventButtonDown, window, GHOST_kButtonMaskLeft);
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list