[PATCH v2 04/12] wintab32: Don't overwrite display driver behavior.

Elaine Lefler elaineclefler at gmail.com
Thu Mar 24 23:46:18 CDT 2022


Fix multimonitor support by trusting the driver's values.

Signed-off-by: Elaine Lefler <elaineclefler at gmail.com>
---

v2: Splitting into smaller patches as per feedback.

x11drv correctly sets system extents to the values of SM_CXVIRTUALSCREEN
and SM_CYVIRTUALSCREEN. Overwriting them is not only bad from a code
cleanliness perspective, but it's also wrong, because the values of
SM_CXSCREEN and SM_CYSCREEN break multimonitor support.

The Linux and the Mac drivers do not handle cursor flipping in the same
way, so this code has been delegated to the respective drivers and
wintab32 now translates packets exactly per specification.
---
 dlls/winex11.drv/wintab.c       | 11 ++++++++---
 dlls/wintab32/context.c         | 35 ---------------------------------
 dlls/wintab32/wintab_internal.h |  2 +-
 3 files changed, 9 insertions(+), 39 deletions(-)

diff --git a/dlls/winex11.drv/wintab.c b/dlls/winex11.drv/wintab.c
index 5fc1e8089b8..c54a1d57102 100644
--- a/dlls/winex11.drv/wintab.c
+++ b/dlls/winex11.drv/wintab.c
@@ -831,6 +831,11 @@ static DWORD get_changed_state( PACKET *pkt)
     return change;
 }
 
+static inline DWORD flip_y( DWORD y )
+{
+    return gSysContext.lcInExtY - y;
+}
+
 static BOOL motion_event( HWND hwnd, XEvent *event )
 {
     XDeviceMotionEvent *motion = (XDeviceMotionEvent *)event;
@@ -849,7 +854,7 @@ static BOOL motion_event( HWND hwnd, XEvent *event )
     gMsgPacket.pkSerialNumber = gSerial++;
     gMsgPacket.pkCursor = curnum;
     gMsgPacket.pkX = motion->axis_data[0];
-    gMsgPacket.pkY = motion->axis_data[1];
+    gMsgPacket.pkY = flip_y(motion->axis_data[1]);
     gMsgPacket.pkOrientation.orAzimuth = figure_deg(motion->axis_data[3],motion->axis_data[4]);
     gMsgPacket.pkOrientation.orAltitude = ((1000 - 15 * max
                                             (abs(motion->axis_data[3]),
@@ -883,7 +888,7 @@ static BOOL button_event( HWND hwnd, XEvent *event )
     gMsgPacket.pkCursor = curnum;
     if (button->axes_count > 0) {
         gMsgPacket.pkX = button->axis_data[0];
-        gMsgPacket.pkY = button->axis_data[1];
+        gMsgPacket.pkY = flip_y(button->axis_data[1]);
         gMsgPacket.pkOrientation.orAzimuth = figure_deg(button->axis_data[3],button->axis_data[4]);
         gMsgPacket.pkOrientation.orAltitude = ((1000 - 15 * max(abs(button->axis_data[3]),
                                                                 abs(button->axis_data[4])))
@@ -932,7 +937,7 @@ static BOOL proximity_event( HWND hwnd, XEvent *event )
     gMsgPacket.pkSerialNumber = gSerial++;
     gMsgPacket.pkCursor = curnum;
     gMsgPacket.pkX = proximity->axis_data[0];
-    gMsgPacket.pkY = proximity->axis_data[1];
+    gMsgPacket.pkY = flip_y(proximity->axis_data[1]);
     gMsgPacket.pkOrientation.orAzimuth = figure_deg(proximity->axis_data[3],proximity->axis_data[4]);
     gMsgPacket.pkOrientation.orAltitude = ((1000 - 15 * max(abs(proximity->axis_data[3]),
                                                             abs(proximity->axis_data[4])))
diff --git a/dlls/wintab32/context.c b/dlls/wintab32/context.c
index af013073bc4..da465d180c7 100644
--- a/dlls/wintab32/context.c
+++ b/dlls/wintab32/context.c
@@ -219,15 +219,6 @@ LPOPENCONTEXT AddPacketToContextQueue(LPPACKET packet, HWND hwnd)
                                 ptr->context.lcInExtX, ptr->context.lcOutOrgX,
                                 ptr->context.lcOutExtX);
 
-            /* flip the Y axis */
-            if (ptr->context.lcOutExtY > 0)
-                packet->pkY = ptr->context.lcOutExtY - packet->pkY;
-            else if (ptr->context.lcOutExtY < 0)
-            {
-                int y = ptr->context.lcOutExtY + packet->pkY;
-                packet->pkY = abs(y);
-            }
-
             DUMPPACKET(*packet);
 
             if (tgt == ptr->QueueSize)
@@ -379,25 +370,6 @@ static UINT WTInfoT(UINT wCategory, UINT nIndex, LPVOID lpOutput, BOOL bUnicode)
 
     TRACE("(%d, %d, %p, %d)\n", wCategory, nIndex, lpOutput, bUnicode);
 
-    /*
-     *  Handle system extents here, as we can use user32.dll code to set them.
-     */
-    if(wCategory == WTI_DEFSYSCTX)
-    {
-        switch(nIndex)
-        {
-            case CTX_SYSEXTX:
-                if(lpOutput != NULL)
-                    *(LONG*)lpOutput = GetSystemMetrics(SM_CXSCREEN);
-                return sizeof(LONG);
-            case CTX_SYSEXTY:
-                if(lpOutput != NULL)
-                    *(LONG*)lpOutput = GetSystemMetrics(SM_CYSCREEN);
-                return sizeof(LONG);
-           /* No action, delegate to X11Drv */
-        }
-    }
-
     if (is_logcontext_category(wCategory) && nIndex == 0)
     {
         if (lpOutput)
@@ -405,13 +377,6 @@ static UINT WTInfoT(UINT wCategory, UINT nIndex, LPVOID lpOutput, BOOL bUnicode)
             LOGCONTEXTW buf;
             pWTInfoW(wCategory, nIndex, &buf);
 
-            /*  Handle system extents here, as we can use user32.dll code to set them */
-            if(wCategory == WTI_DEFSYSCTX)
-            {
-                buf.lcSysExtX = GetSystemMetrics(SM_CXSCREEN);
-                buf.lcSysExtY = GetSystemMetrics(SM_CYSCREEN);
-            }
-
             if (bUnicode)
                 memcpy(lpOutput, &buf, sizeof(buf));
             else
diff --git a/dlls/wintab32/wintab_internal.h b/dlls/wintab32/wintab_internal.h
index 09a5c5098f3..2ee59941faf 100644
--- a/dlls/wintab32/wintab_internal.h
+++ b/dlls/wintab32/wintab_internal.h
@@ -133,7 +133,7 @@ int TABLET_PostTabletMessage(LPOPENCONTEXT newcontext, UINT msg, WPARAM wParam,
                              LPARAM lParam, BOOL send_always) DECLSPEC_HIDDEN;
 LPOPENCONTEXT AddPacketToContextQueue(LPPACKET packet, HWND hwnd) DECLSPEC_HIDDEN;
 
-/* X11drv functions */
+/* Display driver functions */
 extern int  (CDECL *pLoadTabletInfo)(HWND hwnddefault) DECLSPEC_HIDDEN;
 extern int  (CDECL *pGetCurrentPacket)(LPPACKET packet) DECLSPEC_HIDDEN;
 extern int  (CDECL *pAttachEventQueueToTablet)(HWND hOwner) DECLSPEC_HIDDEN;
-- 
2.32.0 (Apple Git-132)




More information about the wine-devel mailing list