diff options
Diffstat (limited to 'generic/tkEvent.c')
-rw-r--r-- | generic/tkEvent.c | 94 |
1 files changed, 56 insertions, 38 deletions
diff --git a/generic/tkEvent.c b/generic/tkEvent.c index 9c3b1b3..1231a97 100644 --- a/generic/tkEvent.c +++ b/generic/tkEvent.c @@ -4,10 +4,10 @@ * This file provides basic low-level facilities for managing X events in * Tk. * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1995 Sun Microsystems, Inc. - * Copyright (c) 1998-2000 Ajuba Solutions. - * Copyright (c) 2004 George Peter Staplin + * Copyright © 1990-1994 The Regents of the University of California. + * Copyright © 1994-1995 Sun Microsystems, Inc. + * Copyright © 1998-2000 Ajuba Solutions. + * Copyright © 2004 George Peter Staplin * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -15,6 +15,14 @@ #include "tkInt.h" +#ifdef _WIN32 +#include "tkWinInt.h" +#elif defined(MAC_OSX_TK) +#include "tkMacOSXInt.h" +#else +#include "tkUnixInt.h" +#endif + /* * There's a potential problem if a handler is deleted while it's current * (i.e. its function is executing), since Tk_HandleEvent will need to read @@ -43,7 +51,7 @@ typedef struct InProgress { typedef struct GenericHandler { Tk_GenericProc *proc; /* Function to dispatch on all X events. */ - ClientData clientData; /* Client data to pass to function. */ + void *clientData; /* Client data to pass to function. */ int deleteFlag; /* Flag to set when this handler is * deleted. */ struct GenericHandler *nextPtr; @@ -115,7 +123,8 @@ static const unsigned long eventMasks[TK_LASTEVENT] = { VirtualEventMask, /* VirtualEvents */ ActivateMask, /* ActivateNotify */ ActivateMask, /* DeactivateNotify */ - MouseWheelMask /* MouseWheelEvent */ + MouseWheelMask, /* MouseWheelEvent */ + TouchpadScrollMask /* TouchpadScroll */ }; /* @@ -125,7 +134,7 @@ static const unsigned long eventMasks[TK_LASTEVENT] = { typedef struct ExitHandler { Tcl_ExitProc *proc; /* Function to call when process exits. */ - ClientData clientData; /* One word of information to pass to proc. */ + void *clientData; /* One word of information to pass to proc. */ struct ExitHandler *nextPtr;/* Next in list of all exit handlers for this * application, or NULL for end of list. */ } ExitHandler; @@ -165,7 +174,7 @@ typedef struct { Tk_RestrictProc *restrictProc; /* Function to call. NULL means no * restrictProc is currently in effect. */ - ClientData restrictArg; /* Argument to pass to restrictProc. */ + void *restrictArg; /* Argument to pass to restrictProc. */ ExitHandler *firstExitPtr; /* First in list of all exit handlers for this * thread. */ int inExit; /* True when this thread is exiting. This is @@ -189,7 +198,7 @@ TCL_DECLARE_MUTEX(exitMutex) */ static void CleanUpTkEvent(XEvent *eventPtr); -static void DelayedMotionProc(ClientData clientData); +static void DelayedMotionProc(void *clientData); static unsigned long GetEventMaskFromXEvent(XEvent *eventPtr); static TkWindow * GetTkWindowFromXEvent(XEvent *eventPtr); static void InvokeClientMessageHandlers(ThreadSpecificData *tsdPtr, @@ -202,12 +211,10 @@ static int InvokeMouseHandlers(TkWindow *winPtr, unsigned long mask, XEvent *eventPtr); static Window ParentXId(Display *display, Window w); static int RefreshKeyboardMappingIfNeeded(XEvent *eventPtr); -static int TkXErrorHandler(ClientData clientData, +static int TkXErrorHandler(void *clientData, XErrorEvent *errEventPtr); static int WindowEventProc(Tcl_Event *evPtr, int flags); -#ifdef TK_USE_INPUT_METHODS static void CreateXIC(TkWindow *winPtr); -#endif /* TK_USE_INPUT_METHODS */ /* *---------------------------------------------------------------------- @@ -315,7 +322,6 @@ InvokeMouseHandlers( *---------------------------------------------------------------------- */ -#ifdef TK_USE_INPUT_METHODS static void CreateXIC( TkWindow *winPtr) @@ -362,7 +368,6 @@ CreateXIC( XSelectInput(winPtr->display, winPtr->window, winPtr->atts.event_mask); } } -#endif /* *---------------------------------------------------------------------- @@ -509,9 +514,12 @@ RefreshKeyboardMappingIfNeeded( /* *---------------------------------------------------------------------- * - * TkGetButtonMask -- + * Tk_GetButtonMask -- * - * Return the proper Button${n}Mask for the button. + * Return the proper Button${n}Mask for the button. Don't care about + * Button4 - Button7, because those are not actually buttons: Those + * are used for the horizontal or vertical mouse wheels. Button4Mask + * and higher is actually used for Button 8 and higher. * * Results: * A button mask. @@ -523,14 +531,15 @@ RefreshKeyboardMappingIfNeeded( */ static const unsigned buttonMasks[] = { - 0, Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask + 0, Button1Mask, Button2Mask, Button3Mask, 0, 0, 0, 0, Button4Mask, \ + Button5Mask, Button6Mask, Button7Mask, Button8Mask, Button9Mask }; unsigned -TkGetButtonMask( +Tk_GetButtonMask( unsigned button) { - return (button > Button5) ? 0 : buttonMasks[button]; + return (button > Button9) ? 0 : buttonMasks[button]; } /* @@ -683,7 +692,7 @@ Tk_CreateEventHandler( * handler. */ unsigned long mask, /* Events for which proc should be called. */ Tk_EventProc *proc, /* Function to call for each selected event */ - ClientData clientData) /* Arbitrary data to pass to proc. */ + void *clientData) /* Arbitrary data to pass to proc. */ { TkEventHandler *handlerPtr; TkWindow *winPtr = (TkWindow *)token; @@ -773,7 +782,7 @@ Tk_DeleteEventHandler( Tk_Window token, /* Same as corresponding arguments passed */ unsigned long mask, /* previously to Tk_CreateEventHandler. */ Tk_EventProc *proc, - ClientData clientData) + void *clientData) { TkEventHandler *handlerPtr; InProgress *ipPtr; @@ -848,7 +857,7 @@ Tk_DeleteEventHandler( void Tk_CreateGenericHandler( Tk_GenericProc *proc, /* Function to call on every event. */ - ClientData clientData) /* One-word value to pass to proc. */ + void *clientData) /* One-word value to pass to proc. */ { GenericHandler *handlerPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) @@ -889,7 +898,7 @@ Tk_CreateGenericHandler( void Tk_DeleteGenericHandler( Tk_GenericProc *proc, - ClientData clientData) + void *clientData) { GenericHandler * handler; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) @@ -1034,7 +1043,7 @@ TkEventInit(void) static int TkXErrorHandler( - ClientData clientData, /* Pointer to flag we set. */ + void *clientData, /* Pointer to flag we set. */ TCL_UNUSED(XErrorEvent *)) /* X error info. */ { int *error = (int *)clientData; @@ -1132,11 +1141,22 @@ Tk_HandleEvent( ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); -#if !defined(MAC_OSX_TK) && !defined(_WIN32) - if (((eventPtr->type == ButtonPress) || (eventPtr->type == ButtonRelease)) - && ((eventPtr->xbutton.button - 6) < 2)) { - eventPtr->xbutton.button -= 2; - eventPtr->xbutton.state ^= ShiftMask; + +#if !defined(_WIN32) && !defined(MAC_OSX_TK) + if ((eventPtr->type == ButtonRelease) || (eventPtr->type == ButtonPress)) { + if ((eventPtr->xbutton.button >= Button4) && (eventPtr->xbutton.button < Button8)) { + if (eventPtr->type == ButtonRelease) { + return; + } else { /* eventPtr->type == ButtonPress */ + int but = eventPtr->xbutton.button; + eventPtr->type = MouseWheelEvent; + eventPtr->xany.send_event = -1; + eventPtr->xkey.keycode = (but & 1) ? -120 : 120; + if (but > Button5) { + eventPtr->xkey.state |= ShiftMask; + } + } + } } #endif @@ -1206,7 +1226,6 @@ Tk_HandleEvent( * ever active for X11. */ -#ifdef TK_USE_INPUT_METHODS /* * If the XIC has been invalidated, it must be recreated. */ @@ -1228,7 +1247,6 @@ Tk_HandleEvent( XSetICFocus(winPtr->inputContext); } } -#endif /*TK_USE_INPUT_METHODS*/ /* * For events where it hasn't already been done, update the current time @@ -1437,8 +1455,8 @@ TkCurrentTime( Tk_RestrictProc * Tk_RestrictEvents( Tk_RestrictProc *proc, /* Function to call for each incoming event */ - ClientData arg, /* Arbitrary argument to pass to proc. */ - ClientData *prevArgPtr) /* Place to store information about previous + void *arg, /* Arbitrary argument to pass to proc. */ + void **prevArgPtr) /* Place to store information about previous * argument. */ { Tk_RestrictProc *prev; @@ -1796,7 +1814,7 @@ CleanUpTkEvent( static void DelayedMotionProc( - ClientData clientData) /* Pointer to display containing a delayed + void *clientData) /* Pointer to display containing a delayed * motion event to be serviced. */ { TkDisplay *dispPtr = (TkDisplay *)clientData; @@ -1827,7 +1845,7 @@ DelayedMotionProc( void TkCreateExitHandler( Tcl_ExitProc *proc, /* Function to invoke. */ - ClientData clientData) /* Arbitrary value to pass to proc. */ + void *clientData) /* Arbitrary value to pass to proc. */ { ExitHandler *exitPtr; @@ -1882,7 +1900,7 @@ TkCreateExitHandler( void TkDeleteExitHandler( Tcl_ExitProc *proc, /* Function that was previously registered. */ - ClientData clientData) /* Arbitrary value to pass to proc. */ + void *clientData) /* Arbitrary value to pass to proc. */ { ExitHandler *exitPtr, *prevPtr; @@ -1924,7 +1942,7 @@ TkDeleteExitHandler( void TkCreateThreadExitHandler( Tcl_ExitProc *proc, /* Function to invoke. */ - ClientData clientData) /* Arbitrary value to pass to proc. */ + void *clientData) /* Arbitrary value to pass to proc. */ { ExitHandler *exitPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) @@ -1965,7 +1983,7 @@ TkCreateThreadExitHandler( void TkDeleteThreadExitHandler( Tcl_ExitProc *proc, /* Function that was previously registered. */ - ClientData clientData) /* Arbitrary value to pass to proc. */ + void *clientData) /* Arbitrary value to pass to proc. */ { ExitHandler *exitPtr, *prevPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) |