Fix XDarwin's handling of Wacom tablet mouse buttons (Based on patch

suggested by Daphne Pfister).
This commit is contained in:
Torrey Lyons 2005-04-02 02:29:24 +00:00
parent 03d126081e
commit 55dc930a18

View File

@ -8,7 +8,7 @@
// //
/* /*
* Copyright (c) 2001 Andreas Monitzer. All Rights Reserved. * 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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the * copy of this software and associated documentation files (the
@ -34,7 +34,7 @@
* sale, use or other dealings in this Software without prior written * sale, use or other dealings in this Software without prior written
* authorization. * 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 $ */ /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.19 2003/11/24 05:39:01 torrey Exp $ */
#include "quartzCommon.h" #include "quartzCommon.h"
@ -258,18 +258,17 @@ static io_connect_t root_port;
switch (type) { switch (type) {
case NSLeftMouseUp: case NSLeftMouseUp:
[self getMousePosition:&xe fromEvent:anEvent];
if (quartzRootless && !mouse1Pressed) { if (quartzRootless && !mouse1Pressed) {
// MouseUp after MouseDown in menu - ignore // MouseUp after MouseDown in menu - ignore
return NO; return NO;
} }
mouse1Pressed = NO; mouse1Pressed = NO;
[self getMousePosition:&xe fromEvent:anEvent];
xe.u.u.type = ButtonRelease; xe.u.u.type = ButtonRelease;
xe.u.u.detail = 1; xe.u.u.detail = 1;
break; break;
case NSLeftMouseDown: case NSLeftMouseDown:
[self getMousePosition:&xe fromEvent:anEvent];
if (quartzRootless) { if (quartzRootless) {
// Check that event is in X11 window // Check that event is in X11 window
if (!quartzProcs->IsX11Window([anEvent window], if (!quartzProcs->IsX11Window([anEvent window],
@ -284,10 +283,43 @@ static io_connect_t root_port;
} }
} }
mouse1Pressed = YES; mouse1Pressed = YES;
[self getMousePosition:&xe fromEvent:anEvent];
xe.u.u.type = ButtonPress; xe.u.u.type = ButtonPress;
xe.u.u.detail = 1; xe.u.u.detail = 1;
break; break;
case NSRightMouseUp:
[self getMousePosition:&xe fromEvent:anEvent];
xe.u.u.type = ButtonRelease;
xe.u.u.detail = 3;
break;
case NSRightMouseDown:
[self getMousePosition:&xe fromEvent:anEvent];
xe.u.u.type = ButtonPress;
xe.u.u.detail = 3;
break;
case NSOtherMouseUp:
{
int hwButton = [anEvent buttonNumber];
[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 = ButtonPress;
xe.u.u.detail = (hwButton == 2) ? hwButton : hwButton + 1;
break;
}
case NSMouseMoved: case NSMouseMoved:
case NSLeftMouseDragged: case NSLeftMouseDragged:
case NSRightMouseDragged: case NSRightMouseDragged:
@ -296,23 +328,6 @@ static io_connect_t root_port;
xe.u.u.type = MotionNotify; xe.u.u.type = MotionNotify;
break; break;
case NSSystemDefined:
{
long hwButtons = [anEvent data2];
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 = kXDarwinUpdateButtons;
xe.u.clientMessage.u.l.longs0 = [anEvent data1];
xe.u.clientMessage.u.l.longs1 =[anEvent data2];
break;
}
case NSScrollWheel: case NSScrollWheel:
[self getMousePosition:&xe fromEvent:anEvent]; [self getMousePosition:&xe fromEvent:anEvent];
xe.u.u.type = kXDarwinScrollWheel; xe.u.u.type = kXDarwinScrollWheel;