[Bf-blender-cvs] [14cddad034a] master: Change updateWintab interface to include whether window is visible so that window intitialization can specify whether it will be visible regardless of whether it is yet visible.

Nicholas Rishel noreply at git.blender.org
Sat Oct 31 00:32:26 CET 2020


Commit: 14cddad034ae8b2b176052b75c9161e680688a88
Author: Nicholas Rishel
Date:   Mon May 25 20:26:27 2020 -0700
Branches: master
https://developer.blender.org/rB14cddad034ae8b2b176052b75c9161e680688a88

Change updateWintab interface to include whether window is visible so that
window intitialization can specify whether it will be visible regardless
of whether it is yet visible.

Signed-off-by: Nicholas Rishel <rishel.nick at gmail.com>

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

M	intern/ghost/intern/GHOST_SystemWin32.cpp
M	intern/ghost/intern/GHOST_WindowWin32.cpp
M	intern/ghost/intern/GHOST_WindowWin32.h

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

diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index fb0c5f0507f..a4fdcc24ed8 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -1338,7 +1338,8 @@ void GHOST_SystemWin32::setTabletAPI(GHOST_TTabletAPI api)
 
   for (GHOST_IWindow *win : wm->getWindows()) {
     GHOST_WindowWin32 *windowsWindow = (GHOST_WindowWin32 *)win;
-    windowsWindow->updateWintab(windowsWindow == activeWindow);
+    windowsWindow->updateWintab(windowsWindow == activeWindow,
+                                !::IsIconic(windowsWindow->getHWND()));
   }
 }
 
@@ -1729,7 +1730,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
             if (LOWORD(wParam) == WA_INACTIVE)
               window->lostMouseCapture();
 
-            window->updateWintab(LOWORD(wParam) != WA_INACTIVE);
+            window->updateWintab(LOWORD(wParam) != WA_INACTIVE, !::IsIconic(window->getHWND()));
 
             lResult = ::DefWindowProc(hwnd, msg, wParam, lParam);
             break;
@@ -1789,8 +1790,11 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
             event = processWindowEvent(GHOST_kEventWindowSize, window);
           }
 
+          // Window might be minimized while inactive. When a window is inactive but not minimized,
+          // Wintab is left enabled (to catch the case where a pen is used to activate a window).
+          // When an inactive window is minimized, we need to disable Wintab.
           if (msg == WM_SIZE && wParam == SIZE_MINIMIZED) {
-            window->updateWintab(false);
+            window->updateWintab(false, false);
           }
 
           break;
diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp
index 199d1c98c2c..44340cddc87 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@ -310,7 +310,8 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
       (m_wintab.overlap = (GHOST_WIN32_WTOverlap)::GetProcAddress(m_wintab.handle, "WTOverlap"))) {
     initializeWintab();
     // Determine which tablet API to use and enable it.
-    updateWintab(true);
+    bool enableWintab = state != GHOST_kWindowStateMinimized;
+    updateWintab(enableWintab, enableWintab);
   }
 
   CoCreateInstance(
@@ -326,6 +327,7 @@ GHOST_WindowWin32::~GHOST_WindowWin32()
   }
 
   if (m_wintab.handle) {
+    updateWintab(false, false);
     if (m_wintab.close && m_wintab.context) {
       m_wintab.close(m_wintab.context);
     }
@@ -999,19 +1001,19 @@ GHOST_TSuccess GHOST_WindowWin32::hasCursorShape(GHOST_TStandardCursor cursorSha
   return (getStandardCursor(cursorShape)) ? GHOST_kSuccess : GHOST_kFailure;
 }
 
-void GHOST_WindowWin32::updateWintab(bool active)
+void GHOST_WindowWin32::updateWintab(bool active, bool visible)
 {
   if (m_wintab.enable && m_wintab.overlap && m_wintab.context) {
-    bool useWintab = useTabletAPI(GHOST_kTabletWintab);
-    bool enable = active && useWintab;
+    bool enable = useTabletAPI(GHOST_kTabletWintab) && visible;
+    bool overlap = enable && active;
 
     // Disabling context while the Window is not minimized can cause issues on receiving Wintab
     // input while changing a window for some drivers, so only disable if either Wintab had been
     // disabled or the window is minimized.
-    m_wintab.enable(m_wintab.context, useWintab && !::IsIconic(m_hWnd));
-    m_wintab.overlap(m_wintab.context, enable);
+    m_wintab.enable(m_wintab.context, enable);
+    m_wintab.overlap(m_wintab.context, overlap);
 
-    if (!enable) {
+    if (!overlap) {
       // WT_PROXIMITY event doesn't occur unless tablet's cursor leaves the proximity while the
       // window is active.
       m_tabletInRange = false;
@@ -1245,7 +1247,8 @@ void GHOST_WindowWin32::processWintabInfoChangeEvent(LPARAM lParam)
   // Update number of connected Wintab digitizers
   if (LOWORD(lParam) == WTI_INTERFACE && HIWORD(lParam) == IFC_NDEVICES) {
     m_wintab.info(WTI_INTERFACE, IFC_NDEVICES, &m_wintab.numDevices);
-    updateWintab((GHOST_WindowWin32 *)system->getWindowManager()->getActiveWindow() == this);
+    updateWintab((GHOST_WindowWin32 *)system->getWindowManager()->getActiveWindow() == this,
+                 !::IsIconic(m_hWnd));
   }
 }
 
diff --git a/intern/ghost/intern/GHOST_WindowWin32.h b/intern/ghost/intern/GHOST_WindowWin32.h
index 00ba63df170..3cf7417e4c1 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.h
+++ b/intern/ghost/intern/GHOST_WindowWin32.h
@@ -439,8 +439,9 @@ class GHOST_WindowWin32 : public GHOST_Window {
   /**
    * Handle setup and switch between Wintab and Pointer APIs
    * \param active    Whether the window is or will be in an active state
+   * \param visible   Whether the window is currently (or will be) visible)
    */
-  void updateWintab(bool active);
+  void updateWintab(bool active, bool visible);
 
   /**
    * Query whether given tablet API should be used.



More information about the Bf-blender-cvs mailing list