Fix XDarwin's handling of Wacom tablet mouse buttons (Based on patch XORG-6_8_99_1
authorTorrey Lyons <torrey@mrcla.com>
Sat, 2 Apr 2005 02:29:24 +0000 (02:29 +0000)
committerTorrey Lyons <torrey@mrcla.com>
Sat, 2 Apr 2005 02:29:24 +0000 (02:29 +0000)
    suggested by Daphne Pfister).

hw/darwin/quartz/XServer.m

index c8e92cc..a5a1011 100644 (file)
@@ -8,7 +8,7 @@
 //
 /*
  * Copyright (c) 2001 Andreas Monitzer. All Rights Reserved.
- * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved.
+ * Copyright (c) 2002-2005 Torrey T. Lyons. All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the
@@ -34,7 +34,7 @@
  * sale, use or other dealings in this Software without prior written
  * authorization.
  */
-/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.2 2004/04/23 19:15:17 eich Exp $ */
+/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.3 2004/07/30 19:12:17 torrey Exp $ */
 /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.19 2003/11/24 05:39:01 torrey Exp $ */
 
 #include "quartzCommon.h"
@@ -258,18 +258,17 @@ static io_connect_t root_port;
 
     switch (type) {
         case NSLeftMouseUp:
-            [self getMousePosition:&xe fromEvent:anEvent];
             if (quartzRootless && !mouse1Pressed) {
                 // MouseUp after MouseDown in menu - ignore
                 return NO;
             }
             mouse1Pressed = NO;
+            [self getMousePosition:&xe fromEvent:anEvent];
             xe.u.u.type = ButtonRelease;
             xe.u.u.detail = 1;
             break;
 
         case NSLeftMouseDown:
-            [self getMousePosition:&xe fromEvent:anEvent];
             if (quartzRootless) {
                 // Check that event is in X11 window
                 if (!quartzProcs->IsX11Window([anEvent window],
@@ -284,35 +283,51 @@ static io_connect_t root_port;
                 }
             }
             mouse1Pressed = YES;
+            [self getMousePosition:&xe fromEvent:anEvent];
             xe.u.u.type = ButtonPress;
             xe.u.u.detail = 1;
             break;
 
-        case NSMouseMoved:
-        case NSLeftMouseDragged:
-        case NSRightMouseDragged:
-        case NSOtherMouseDragged:
+        case NSRightMouseUp:
             [self getMousePosition:&xe fromEvent:anEvent];
-            xe.u.u.type = MotionNotify;
+            xe.u.u.type = ButtonRelease;
+            xe.u.u.detail = 3;
             break;
 
-        case NSSystemDefined:
+        case NSRightMouseDown:
+            [self getMousePosition:&xe fromEvent:anEvent];
+            xe.u.u.type = ButtonPress;
+            xe.u.u.detail = 3;
+            break;
+
+        case NSOtherMouseUp:
         {
-            long hwButtons = [anEvent data2];
+            int hwButton = [anEvent buttonNumber];
 
-            if (![anEvent subtype]==7)
-                return NO; // we only use multibutton mouse events
-            if (mouseState == hwButtons)
-                return NO; // ignore double events
-            mouseState = hwButtons;
+            [self getMousePosition:&xe fromEvent:anEvent];
+            xe.u.u.type = ButtonRelease;
+            xe.u.u.detail = (hwButton == 2) ? hwButton : hwButton + 1;
+            break;
+        }
+
+        case NSOtherMouseDown:
+        {
+            int hwButton = [anEvent buttonNumber];
 
             [self getMousePosition:&xe fromEvent:anEvent];
-            xe.u.u.type = kXDarwinUpdateButtons;
-            xe.u.clientMessage.u.l.longs0 = [anEvent data1];
-            xe.u.clientMessage.u.l.longs1 =[anEvent data2];
+            xe.u.u.type = ButtonPress;
+            xe.u.u.detail = (hwButton == 2) ? hwButton : hwButton + 1;
             break;
         }
 
+        case NSMouseMoved:
+        case NSLeftMouseDragged:
+        case NSRightMouseDragged:
+        case NSOtherMouseDragged:
+            [self getMousePosition:&xe fromEvent:anEvent];
+            xe.u.u.type = MotionNotify;
+            break;
+
         case NSScrollWheel:
             [self getMousePosition:&xe fromEvent:anEvent];
             xe.u.u.type = kXDarwinScrollWheel;