summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXMouseEvent.c
diff options
context:
space:
mode:
authordas <das>2005-12-13 03:44:41 (GMT)
committerdas <das>2005-12-13 03:44:41 (GMT)
commitc97f485feb8a8de6050fa13f72a5a808cc6f05d0 (patch)
treefbb79b1fd0e2a596050d2b087290c6b5ecf7a3b5 /macosx/tkMacOSXMouseEvent.c
parentd5a443172ee410e009c7e6d7769f8b774d74d3e0 (diff)
downloadtk-c97f485feb8a8de6050fa13f72a5a808cc6f05d0.zip
tk-c97f485feb8a8de6050fa13f72a5a808cc6f05d0.tar.gz
tk-c97f485feb8a8de6050fa13f72a5a808cc6f05d0.tar.bz2
* library/demos/cscroll.tcl: add MouseWheel bindings for aqua.
* macosx/tkMacOSXCarbonEvents.c (TkMacOSXInitCarbonEvents): * macosx/tkMacOSXMouseEvent.c (TkMacOSXProcessMouseEvent, GenerateMouseWheelEvent): add support for kEventMouseScroll events (smooth mouse wheel scrolling from mighty mouse or scrolling trackpad) by handling kEventMouseWheelMoved on application target as well as on dispatcher, in order to pick up synthesized MouseWheel events from HIObject handler (c.f. QA1453); add support for horizontal scrolling events by generating MouseWheel XEvent with Shift modifier.
Diffstat (limited to 'macosx/tkMacOSXMouseEvent.c')
-rw-r--r--macosx/tkMacOSXMouseEvent.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index ef1f9be..9375118 100644
--- a/macosx/tkMacOSXMouseEvent.c
+++ b/macosx/tkMacOSXMouseEvent.c
@@ -54,7 +54,7 @@
* software in accordance with the terms specified in this
* license.
*
- * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.6.2.9 2005/11/27 02:36:46 das Exp $
+ * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.6.2.10 2005/12/13 03:44:42 das Exp $
*/
#include "tkInt.h"
@@ -128,7 +128,7 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
Point where, where2;
int xOffset, yOffset, result;
TkDisplay * dispPtr;
- OSStatus status;
+ OSStatus status;
MouseEventData mouseEventData, * medPtr = &mouseEventData;
switch (eventPtr->eKind) {
@@ -208,17 +208,24 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
}
if (eventPtr->eKind == kEventMouseWheelMoved) {
status = GetEventParameter(eventPtr->eventRef,
- kEventParamMouseWheelDelta,
- typeLongInteger, NULL,
+ kEventParamMouseWheelDelta, typeLongInteger, NULL,
sizeof(long), NULL, &medPtr->delta);
if (status != noErr ) {
#ifdef TK_MAC_DEBUG
- fprintf (stderr,
- "Failed to retrieve mouse wheel delta, %d\n", (int) status);
+ fprintf (stderr,
+ "Failed to retrieve mouse wheel delta, %d\n", (int) status);
#endif
- statusPtr->err = 1;
- return false;
- }
+ statusPtr->err = 1;
+ return false;
+ } else {
+ EventMouseWheelAxis axis;
+ status = GetEventParameter(eventPtr->eventRef,
+ kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL,
+ sizeof(EventMouseWheelAxis), NULL, &axis);
+ if (status == noErr && axis == kEventMouseWheelAxisX) {
+ medPtr->state |= ShiftMask;
+ }
+ }
}
dispPtr = TkGetDisplayList();
@@ -226,11 +233,15 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
if (eventPtr->eKind != kEventMouseDown) {
/*
- * MouseMoved, MouseDragged or kEventMouseWheelMoved
+ * MouseMoved, MouseDragged or MouseWheelMoved
*/
if (eventPtr->eKind == kEventMouseWheelMoved) {
- return GenerateMouseWheelEvent(medPtr);
+ int res = GenerateMouseWheelEvent(medPtr);
+ if (res) {
+ statusPtr->stopProcessing = 1;
+ }
+ return res;
} else {
return GeneratePollingEvents(medPtr);
}
@@ -534,7 +545,6 @@ static int
GenerateMouseWheelEvent(MouseEventData * medPtr)
{
Tk_Window tkwin, rootwin, grabWin;
- int local_x, local_y;
TkDisplay *dispPtr;
TkWindow *winPtr;
XEvent xEvent;
@@ -550,7 +560,7 @@ GenerateMouseWheelEvent(MouseEventData * medPtr)
} else {
tkwin = Tk_TopCoordsToWindow(rootwin,
medPtr->local.h, medPtr->local.v,
- &local_x, &local_y);
+ &xEvent.xbutton.x, &xEvent.xbutton.y);
}
}
@@ -565,12 +575,14 @@ GenerateMouseWheelEvent(MouseEventData * medPtr)
tkwin = grabWin;
}
if (!tkwin) {
- return true;
+ return false;
}
winPtr = (TkWindow *) tkwin;
xEvent.type = MouseWheelEvent;
xEvent.xkey.keycode = medPtr->delta;
- xEvent.xbutton.state = TkMacOSXButtonKeyState();
+ xEvent.xbutton.x_root = medPtr->global.h;
+ xEvent.xbutton.y_root = medPtr->global.v;
+ xEvent.xbutton.state = medPtr->state;
xEvent.xany.serial = LastKnownRequestProcessed(winPtr->display);
xEvent.xany.send_event = false;
xEvent.xany.display = winPtr->display;