summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXMouseEvent.c
diff options
context:
space:
mode:
authordas <das@noemail.net>2007-04-23 21:24:31 (GMT)
committerdas <das@noemail.net>2007-04-23 21:24:31 (GMT)
commitff8c6fdb06d2a564791dc729a66db5c2a8d23519 (patch)
tree1a0bc7c114e940c5e46d3704ac14fb34f4cc029e /macosx/tkMacOSXMouseEvent.c
parentc041421d45d038598b4a8a26a28f124f5f43c749 (diff)
downloadtk-ff8c6fdb06d2a564791dc729a66db5c2a8d23519.zip
tk-ff8c6fdb06d2a564791dc729a66db5c2a8d23519.tar.gz
tk-ff8c6fdb06d2a564791dc729a66db5c2a8d23519.tar.bz2
* macosx/tkMacOSXCarbonEvents.c: add window event target carbon event
* macosx/tkMacOSXEvent.c: handler for all kEventClassWindow and * macosx/tkMacOSXEvent.h: kEventClassMouse events; * macosx/tkMacOSXNotify.c: move all remaining events except for * macosx/tkMacOSXWindowEvent.c: kEventClassKeyboard from dispatcher to application event handler; pass event handler callRef downstream; fix debug event tracing; process all tcl event types in carbon event timer; delay carbon event timer first fire; add TkMacOSXTrackingLoop() to mark enter/exit of event tracking loop during which all tcl events but only carbon update events should be processed by the timer (replaces various calls to Tcl_SetServiceMode()); rename TkMacOSXReceiveAndProcessEvent() to TkMacOSXReceiveAndDispatchEvent(), move it from tkMacOSXEvent.c to tkMacOSXCarbonEvents.c and modify it to dequeue only update events during a tracking loop; add TkMacOSXRunTclEventLoop() to standardize the various ways in use to run the tcl event loop; add handling of kEventClassAppearance events (for ScrollBarVariantChanged event). * macosx/tkMacOSXDialog.c: use new TkMacOSXTrackingLoop() around * macosx/tkMacOSXEvent.c: blocking API that puts up modal dialogs * macosx/tkMacOSXMenu.c: or when entering/exiting menu/control * macosx/tkMacOSXMouseEvent.c: tracking, window dragging and other * macosx/tkMacOSXScale.c: mouse tracking loops. * macosx/tkMacOSXScrlbr.c: * macosx/tkMacOSXWindowEvent.c: * macosx/tkMacOSXWm.c: * macosx/tkMacOSXDialog.c: use new TkMacOSXRunTclEventLoop() * macosx/tkMacOSXScale.c: instead of Tcl_DoOneEvent(), * macosx/tkMacOSXScrlbr.c: Tcl_ServiceAll(), TclServiceIdle() * macosx/tkMacOSXWindowEvent.c: and Tcl_GlobalEval("update idletasks"). * macosx/tkMacOSXColor.c: make available as Tk system colors all * macosx/tkMacOSXPort.h: appearance manager brushes, text colors and backgrounds with new and legacy names, as well as the fully transparent color "systemTransparent"; add TkMacOSXSetColorIn{Port,Context}() to directly set an X pixel color value in the current QD port resp. the given CG context without requiring passage through rgb representation (lossy for most system colors); modernize/remove Classic-era code; replace crufty strcmp() elseifs by Tcl_GetIndexFromObjStruct(). * macosx/tkMacOSXButton.c: use new TkMacOSXSetColorInPort() * macosx/tkMacOSXDraw.c: instead of setting rgb color directly * macosx/tkMacOSXMenubutton.c: to allow for non-rgb system colors. * macosx/tkMacOSXCursor.c: implement "none" cursor as on other platforms [Patch 1615427]; add all missing appearance manager cursors. * macosx/tkMacOSXDefault.h: set SELECT_FG_COLORs to None to match aqua L&F; use standard system color names; use new 'menu' system font; correct default scrollbar width. * macosx/tkMacOSXDraw.c: standardize initialization, use and * macosx/tkMacOSXInt.h: emptying of various static temp rgns * macosx/tkMacOSXRegion.c: onto two global RgnHandles; in debug * macosx/tkMacOSXSubwindows.c: builds, verify emptiness of these temp * macosx/tkMacOSXWindowEvent.c: rgns before use. * macosx/tkMacOSXDraw.c: add TkMacOSX{Setup,Restore}DrawingContext() to * macosx/tkMacOSXInt.h: abstract common setup & teardown of drawing environment (for both CG and QD); save/restore QD theme drawing state; handle GC clip region; add TkpClipDrawableToRect() to allow clipped drawing into drawable regardless of GC used; use new system color "systemWindowHeaderBackground" to setup background in themed toplevels; correct implementation of TkMacOSXMakeStippleMap(). * macosx/tkMacOSXEntry.c: use new TkMacOSXSetupDrawingContext() and * macosx/tkMacOSXFont.c: TkMacOSXRestoreDrawingContext() instead of * macosx/ttkMacOSXTheme.c: various setup/teardown procs like TkMacOSX{SetUp,Release}CGContext(), TkMacOSXQuarz{Start,End}Draw(), TkMacOSXSetUpGraphicsPort() etc. * macosx/tkMacOSXEmbed.c: add CG context and drawable clip rgn fields * macosx/tkMacOSXInt.h: to MacDrawable struct. * macosx/tkMacOSXSubwindows.c: * macosx/tkMacOSXDialog.c: make -parent option of tk_getOpenFile et al. use the sheet version of NavServices dialogs; ensure native parent win exists before using StandardSheet API for tk_messageBox [Bug 1677611]; force sheets to behave like app-modal dialogs via WindowModality() API; use more modern ColorPicker API. * macosx/tkAboutDlg.r: use themed movable modal dialog, fix (c) year. * macosx/tkMacOSXEntry.c: take xOff/yOff of MacDrawable into account * macosx/ttkMacOSXTheme.c: when computing locations/bounds to ensure correct posititioning when not drawing into intermediate pixmap. * macosx/tkMacOSXFont.c: use appearance manager API to map system font * macosx/tkMacOSXFont.h: names to TkFonts; add "menu" system font for menu item text drawing from MDEF; always draw with CG; remove QD dependent stippling algorithm; move most header declarations into the source file (as they were not used anywhere else). * macosx/tkMacOSXMenu.c: large-scale rewrite of custom * macosx/tkMacOSXMenu.r (removed): MDEF and related code that * macosx/Wish.xcode/project.pbxproj: restores many longtime-MIA * macosx/Wish.xcodeproj/project.pbxproj: features to working order * unix/Makefile.in: (e.g. images, custom colors & fonts in menus etc); implement compound menu items; use Appearance Mgr and ThemeText APIs to mimic native MDEF as closely as possible when default "menu" system font is used; remove now obsolete SICN drawing code and resources. * macosx/tkMacOSXCarbonEvents.c: handle additional menu carbon events * macosx/tkMacOSXEvent.c: in order to support <<MenuSelect>> in * macosx/tkMacOSXMenu.c: the menubar and in menus that are not * macosx/tkMacOSXMenus.c: using the custom MDEF [Bug 1620826]; fix early and missing clearing of current Tk active menu entry; fix extraneous sending of <<MenuSelect>> during active menu entry clearing. * macosx/tkMacOSXMouseEvent.c: add support for async window dragging by the window server; set the corresponding window attribute by default. * macosx/tkMacOSXMouseEvent.c: rationalized handling order of non-mousedown events; add TkMacOSXModifierState() to retrieve the current key modifiers in carbon format. * macosx/tkMacOSXScrlbr.c: use appearance manager API to retrieve scrollbar component metrics; add awareness of multiple possibilites for scrollbar arrow position in aqua and handle user changes to arrow position pref; handle difference in metrics of small & large scrollbar variants; handle aqua "jump to here" scrollbar behaviour; correct computation of scroll view size and position; enforce min scrollbar height to avoid scrollbar component overlap; erase scrollbar area outside of standard width; remove broken auto-adjust code; account for window class when leaving space for grow box; remove code to manually draw grow box; use modern API for thumb scroll proc; replace HiliteControl() by modern API; replace control mgr constants with appearance mgr equivalents. * macosx/tkMacOSXSubwindows.c: use SetWindowBounds() API instead of SizeWindow(); invalidate clip regions after X{Map,Unmap}Window as fix for [Bug 940117] made them dependent on mapping state; remove unneeded calls to TkMacOSXInvalClipRgns() and unnecessary setting of QD port; use native-endian pixmap on intel; remove obsolete pixmap pix locking. * macosx/tkMacOSXWindowEvent.c: handle only the first of a batch of kEventAppAvailableWindowBoundsChanged events sent per transaction; handle kEventWindowBoundsChanged event to support live window resizing and centralized sending of location/size changed ConfigureNotify events; ensure HIGrowBox is redrawn after bounds change; constrain window after dragging to ensure titlebar is not inacessible offscreen or under dock/menubar; handle kEventWindowGetRegion and kEventWindowDrawContent for transparent windows to mark resp. paint content region as transparent; handle kEventWindowConstrain for fullscreen windows to ensure bounds match new screen size; enter/exit fullscreen UIMode upon activation/deactivation of fullscreen window. * macosx/tkMacOSXWm.c: use live-resize and async-drag carbon window * macosx/tkMacOSXWm.h: attributes for toplevels by default; implement new [wm attributes] -topmost, -transparent and -fullscreen; refactor WmAttributesCmd() parallelling the tkUnixWm.c implementation, use thus factored proc to set proxy icon from [wm iconbitmap]; dynamically determine default values for toplevel min and max sizes (similar to tkWinWm.c impl): min sizes depend on window class & attributes to ensure visibility of all titlebar widgets and grow box, max sizes depend on maximal window bounds for all active displays; factor out code that puts into effect changes to master or override_redirect; use RepositionWindow() API to determine staggered initial window bounds; correct resize limit calculations, handle gridding and use modern resize API in TkMacOSXGrowToplevel(); remove sending of ConfigureNotify after resize or zoom (now handled by BoundsChanged handler); correct composite carbon window attribute handling, remove currently unusable attributes and add new attributes in [tk::unsupported::MacWindowStyle]; ensure validity of window class and attributes before use; apply changes to window class when handling carbon window attribute changes (if HIWindowChangeClass() API available); add debug build warning message when deprecated window style is used instead of window class; use transparent HIGrowBox for resizable windows; avoid unnecessary calls to window structure width API; use tcl time API in TkpGetMS(); add TkMacOSXEnterExitFullscreen() to enter/exit UIMode with dock and menubar hidden; restrict wmTracing output to debug builds; remove unneeded calls to TkMacOSXInvalClipRgns() and unnecessary setting of QD port; workaround GetWindowStructureWidths() Carbon bug (bogus results for never-mapped floating windows). * macosx/tkMacOSXXStubs.c (TkMacOSXDisplayChanged): add maximal window bounds field to Screen record (in ext_data), computed as the union of available window positioning bounds of all graphics devices (displays). * macosx/tkMacOSXBitmap.c: fix macRoman encoding leak. * macosx/tkMacOSXCursor.c: * macosx/tkMacOSXDebug.c (TkMacOSXCarbonEventToAscii): use static * macosx/tkMacOSXDebug.h: buffer to simplify callers; const fixes. * macosx/tkMacOSXBitmap.c: use more efficient QDSwapPort() instead of * macosx/tkMacOSXButton.c: GetPort()/SetPort()/GetGWorld()/SetGWorld(). * macosx/tkMacOSXDraw.c: * macosx/tkMacOSXMenubutton.c: * macosx/tkMacOSXScale.c: * macosx/tkMacOSXScrlbr.c: * macosx/tkMacOSXXStubs.c: * macosx/tkMacOSXColor.c: use kHIToolboxVersionNumber for runtime OS * macosx/tkMacOSXEntry.c: version check rather than Gestalt() etc. * macosx/tkMacOSXInt.h: * macosx/tkMacOSXWm.c: * macosx/tkMacOSXDraw.c: remove obsolete and now incorrect * macosx/tkMacOSXInt.h: tkMenuCascadeRgn clipping code. * macosx/tkMacOSXMenu.c: * macosx/tkMacOSXHLEvents.c: replace Tcl_GlobalEval() resp. Tcl_Eval() * macosx/tkMacOSXScrlbr.c: by Tcl_EvalEx(). * macosx/tkMacOSXInit.c: * macosx/tkMacOSXInit.c (TkpInit): reorder initialization steps. * macosx/tkMacOSXKeyEvent.c: remove pre-10.2 support. * macosx/tkMacOSXMenus.c: remove now useless call to TkMacOSXHandleTearoffMenu(); use \x.. quoting for non-latin1 macroman literar chars to allow file to be edited as utf-8. * macosx/tkMacOSXScale.c: replace TrackControl() by modern * macosx/tkMacOSXScrlbr.c: HandleControlClick() API (using new TkMacOSXModifierState()). * macosx/tkMacOSXInt.h: move all constant #defines needed to * macosx/tkMacOSXColor.c: support building on older OS X releases * macosx/tkMacOSXEvent.h: to a central location in tkMacOSXInt.h. * macosx/tkMacOSXFont.c: * macosx/tkMacOSXMenu.c: * macosx/tkMacOSXMenubutton.c: * macosx/tkMacOSXMenus.c: * macosx/tkMacOSXMouseEvent.c: * macosx/tkMacOSXWm.c: * macosx/ttkMacOSXTheme.c: * macosx/tkMacOSXInt.h: add ChkErr() macro to factor out * macosx/tkMacOSXButton.c: Carbon OSStatus return value checking * macosx/tkMacOSXCarbonEvents.c: and TkMacOSXDbgMsg() macro to factour * macosx/tkMacOSXClipboard.c: out debug message output; use these * macosx/tkMacOSXColor.c: macros to replace #ifdef TK_MAC_DEBUG * macosx/tkMacOSXCursor.c: blocks & direct printing to stderr, * macosx/tkMacOSXDebug.c: and to do additional OSStatus return * macosx/tkMacOSXDialog.c: checking, and to standardize OSStatus * macosx/tkMacOSXDraw.c: usage. * macosx/tkMacOSXEntry.c: * macosx/tkMacOSXEvent.c: * macosx/tkMacOSXFont.c: * macosx/tkMacOSXHLEvents.c: * macosx/tkMacOSXInit.c: * macosx/tkMacOSXKeyEvent.c: * macosx/tkMacOSXMenu.c: * macosx/tkMacOSXMenubutton.c: * macosx/tkMacOSXMenus.c: * macosx/tkMacOSXMouseEvent.c: * macosx/tkMacOSXScrlbr.c: * macosx/tkMacOSXSubwindows.c: * macosx/tkMacOSXWindowEvent.c: * macosx/tkMacOSXWm.c: * macosx/tkMacOSXXStubs.c: * macosx/tkMacOSXSend.c: remove duplicate/unused declarations * macosx/tkMacOSXXStubs.c: * macosx/tkMacOSXDebug.c: const fixes. * macosx/tkMacOSXInit.c: * macosx/tkMacOSXTest.c: * macosx/tkMacOSXWm.c: * macosx/tkMacOSXXStubs.c: * macosx/Wish-Info.plist.in: add tcl document extensions/mime types and LSMinimumSystemVersion, LSRequiresCarbon & NSAppleScriptEnabled keys. * macosx/Wish-Common.xcconfig: add Wish's Info.plist as __info_plist section to tktest; enable more warnings. * macosx/Wish.xcodeproj/project.pbxproj: add 'DebugMemCompile' build configuration that calls configure with --enable-symbols=all; disable configure check for __attribute__((__visibility__("hidden"))) in Debug configuration to restore availability of ZeroLink. * macosx/Wish-Common.xcconfig: fix whitespace. * macosx/Wish-Debug.xcconfig: * macosx/Wish-Release.xcconfig: * macosx/tkMacOSXAETE.r: * macosx/tkMacOSXConfig.c: * macosx/tkMacOSXCursors.r: * macosx/tkMacOSXKeyboard.c: * macosx/tkMacOSXSend.c: * macosx/ttkMacOSXTheme.c: * macosx/tkMacOSXXCursors.r: * macosx/README: * macosx/GNUmakefile: fix/add copyright and license refs. * macosx/Tk-Info.plist.in: * macosx/Wish-Info.plist.in: * macosx/Wish.xcode/project.pbxproj: * macosx/Wish.xcodeproj/project.pbxproj: * macosx/tkMacOSX.h: FossilOrigin-Name: d9c03a54d7a446be582ab26d32981c3c3b99a0ba
Diffstat (limited to 'macosx/tkMacOSXMouseEvent.c')
-rw-r--r--macosx/tkMacOSXMouseEvent.c660
1 files changed, 340 insertions, 320 deletions
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index b49bc4b..d3d1f61 100644
--- a/macosx/tkMacOSXMouseEvent.c
+++ b/macosx/tkMacOSXMouseEvent.c
@@ -5,56 +5,56 @@
* on MacOS X.
*
* Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2005-2006 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright (c) 2005-2007 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * The following terms apply to all files originating from Apple
- * Computer, Inc. ("Apple") and associated with the software
- * unless explicitly disclaimed in individual files.
- *
- *
- * Apple hereby grants permission to use, copy, modify,
- * distribute, and license this software and its documentation
- * for any purpose, provided that existing copyright notices are
- * retained in all copies and that this notice is included
- * verbatim in any distributions. No written agreement, license,
- * or royalty fee is required for any of the authorized
- * uses. Modifications to this software may be copyrighted by
- * their authors and need not follow the licensing terms
- * described here, provided that the new terms are clearly
- * indicated on the first page of each file where they apply.
- *
- *
- * IN NO EVENT SHALL APPLE, THE AUTHORS OR DISTRIBUTORS OF THE
- * SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
- * INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
- * THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
- * EVEN IF APPLE OR THE AUTHORS HAVE BEEN ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE. APPLE, THE AUTHORS AND
- * DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS
- * SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND APPLE,THE
- * AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
- * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * GOVERNMENT USE: If you are acquiring this software on behalf
- * of the U.S. government, the Government shall have only
- * "Restricted Rights" in the software and related documentation
- * as defined in the Federal Acquisition Regulations (FARs) in
- * Clause 52.227.19 (c) (2). If you are acquiring the software
- * on behalf of the Department of Defense, the software shall be
- * classified as "Commercial Computer Software" and the
- * Government shall have only "Restricted Rights" as defined in
- * Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the
- * foregoing, the authors grant the U.S. Government and others
- * acting in its behalf permission to use and distribute the
- * software in accordance with the terms specified in this
- * license.
- *
- * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.27 2007/04/21 19:06:38 hobbs Exp $
+ * The following terms apply to all files originating from Apple
+ * Computer, Inc. ("Apple") and associated with the software
+ * unless explicitly disclaimed in individual files.
+ *
+ *
+ * Apple hereby grants permission to use, copy, modify,
+ * distribute, and license this software and its documentation
+ * for any purpose, provided that existing copyright notices are
+ * retained in all copies and that this notice is included
+ * verbatim in any distributions. No written agreement, license,
+ * or royalty fee is required for any of the authorized
+ * uses. Modifications to this software may be copyrighted by
+ * their authors and need not follow the licensing terms
+ * described here, provided that the new terms are clearly
+ * indicated on the first page of each file where they apply.
+ *
+ *
+ * IN NO EVENT SHALL APPLE, THE AUTHORS OR DISTRIBUTORS OF THE
+ * SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
+ * INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
+ * THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
+ * EVEN IF APPLE OR THE AUTHORS HAVE BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE. APPLE, THE AUTHORS AND
+ * DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS
+ * SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND APPLE,THE
+ * AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
+ * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * GOVERNMENT USE: If you are acquiring this software on behalf
+ * of the U.S. government, the Government shall have only
+ * "Restricted Rights" in the software and related documentation
+ * as defined in the Federal Acquisition Regulations (FARs) in
+ * Clause 52.227.19 (c) (2). If you are acquiring the software
+ * on behalf of the Department of Defense, the software shall be
+ * classified as "Commercial Computer Software" and the
+ * Government shall have only "Restricted Rights" as defined in
+ * Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the
+ * foregoing, the authors grant the U.S. Government and others
+ * acting in its behalf permission to use and distribute the
+ * software in accordance with the terms specified in this
+ * license.
+ *
+ * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.28 2007/04/23 21:24:33 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -62,21 +62,15 @@
#include "tkMacOSXEvent.h"
#include "tkMacOSXDebug.h"
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 1030
- /* Define constants only available on Mac OS X 10.3 or later */
- #define kEventParamWindowPartCode 'wpar'
- #define typeWindowPartCode 'wpar'
-#endif
-
typedef struct {
WindowRef whichWin;
WindowRef activeNonFloating;
WindowPartCode windowPart;
- Point global;
- Point local;
unsigned int state;
long delta;
Window window;
+ Point global;
+ Point local;
} MouseEventData;
/*
@@ -97,22 +91,23 @@ static int GenerateToolbarButtonEvent(MouseEventData * medPtr);
static int HandleWindowTitlebarMouseDown(MouseEventData * medPtr, Tk_Window tkwin);
static unsigned int ButtonModifiers2State(UInt32 buttonState, UInt32 keyModifiers);
-static int TkMacOSXGetEatButtonUp();
+static int TkMacOSXGetEatButtonUp(void);
static void TkMacOSXSetEatButtonUp(int f);
+
/*
*----------------------------------------------------------------------
*
* TkMacOSXProcessMouseEvent --
*
- * This routine processes the event in eventPtr, and
- * generates the appropriate Tk events from it.
+ * This routine processes the event in eventPtr, and
+ * generates the appropriate Tk events from it.
*
* Results:
- * True if event(s) are generated - false otherwise.
+ * True if event(s) are generated - false otherwise.
*
* Side effects:
- * Additional events may be place on the Tk event queue.
+ * Additional events may be place on the Tk event queue.
*
*----------------------------------------------------------------------
*/
@@ -120,18 +115,18 @@ static void TkMacOSXSetEatButtonUp(int f);
MODULE_SCOPE int
TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
{
- Tk_Window tkwin;
- Point where, where2;
- int xOffset, yOffset, result;
- TkDisplay * dispPtr;
- OSStatus status;
+ Tk_Window tkwin;
+ Point where, where2;
+ int result;
+ TkDisplay * dispPtr;
+ OSStatus err;
MouseEventData mouseEventData, * medPtr = &mouseEventData;
ProcessSerialNumber frontPsn, ourPsn = {0, kCurrentProcess};
- Boolean isFrontProcess = true;
+ Boolean isFrontProcess = true;
switch (eventPtr->eKind) {
- case kEventMouseUp:
case kEventMouseDown:
+ case kEventMouseUp:
case kEventMouseMoved:
case kEventMouseDragged:
case kEventMouseWheelMoved:
@@ -140,27 +135,27 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
return false;
break;
}
- status = GetEventParameter(eventPtr->eventRef,
+ err = ChkErr(GetEventParameter, eventPtr->eventRef,
kEventParamMouseLocation,
- typeQDPoint, NULL,
+ typeQDPoint, NULL,
sizeof(where), NULL,
&where);
- if (status != noErr) {
+ if (err != noErr) {
GetGlobalMouse(&where);
}
- status = GetEventParameter(eventPtr->eventRef,
+ err = ChkErr(GetEventParameter, eventPtr->eventRef,
kEventParamWindowRef,
- typeWindowRef, NULL,
+ typeWindowRef, NULL,
sizeof(WindowRef), NULL,
&medPtr->whichWin);
- if (status == noErr) {
- status = GetEventParameter(eventPtr->eventRef,
+ if (err == noErr) {
+ err = ChkErr(GetEventParameter, eventPtr->eventRef,
kEventParamWindowPartCode,
- typeWindowPartCode, NULL,
+ typeWindowPartCode, NULL,
sizeof(WindowPartCode), NULL,
&medPtr->windowPart);
}
- if (status != noErr) {
+ if (err != noErr) {
medPtr->windowPart = FindWindow(where, &medPtr->whichWin);
}
medPtr->window = TkMacOSXGetXWindow(medPtr->whichWin);
@@ -169,21 +164,23 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
}
if (eventPtr->eKind == kEventMouseDown) {
if (IsWindowPathSelectEvent(medPtr->whichWin, eventPtr->eventRef)) {
- status = WindowPathSelect(medPtr->whichWin, NULL, NULL);
+ ChkErr(WindowPathSelect, medPtr->whichWin, NULL, NULL);
return false;
}
if (medPtr->windowPart == inProxyIcon) {
- status = TrackWindowProxyDrag(medPtr->whichWin, where);
- if (status == errUserWantsToDragWindow) {
+ TkMacOSXTrackingLoop(1);
+ err = ChkErr(TrackWindowProxyDrag, medPtr->whichWin, where);
+ TkMacOSXTrackingLoop(0);
+ if (err == errUserWantsToDragWindow) {
medPtr->windowPart = inDrag;
} else {
return false;
}
}
}
- status = GetFrontProcess(&frontPsn);
- if (status == noErr) {
- SameProcess(&frontPsn, &ourPsn, &isFrontProcess);
+ err = ChkErr(GetFrontProcess, &frontPsn);
+ if (err == noErr) {
+ ChkErr(SameProcess, &frontPsn, &ourPsn, &isFrontProcess);
}
if (isFrontProcess) {
medPtr->state = ButtonModifiers2State(GetCurrentEventButtonState(),
@@ -193,89 +190,80 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
GetCurrentKeyModifiers());
}
medPtr->global = where;
- status = GetEventParameter(eventPtr->eventRef,
+ err = ChkErr(GetEventParameter, eventPtr->eventRef,
kEventParamWindowMouseLocation,
- typeQDPoint, NULL,
+ typeQDPoint, NULL,
sizeof(Point), NULL,
&medPtr->local);
- if (status == noErr) {
+ if (err == noErr) {
if (medPtr->whichWin) {
Rect widths;
GetWindowStructureWidths(medPtr->whichWin, &widths);
medPtr->local.h -= widths.left;
- medPtr->local.v -= widths.top;
+ medPtr->local.v -= widths.top;
}
} else {
medPtr->local = where;
if (medPtr->whichWin) {
QDGlobalToLocalPoint(GetWindowPort(medPtr->whichWin),
- &medPtr->local);
+ &medPtr->local);
}
}
medPtr->activeNonFloating = ActiveNonFloatingWindow();
-
- /*
- * The window manager only needs to know about mouse down events
- * and sometimes we need to "eat" the mouse up. Otherwise, we
- * just pass the event to Tk.
-
- */
- if (eventPtr->eKind == kEventMouseUp) {
- if (TkMacOSXGetEatButtonUp()) {
- TkMacOSXSetEatButtonUp(false);
- return false;
- }
- return GenerateButtonEvent(medPtr);
- }
- if (eventPtr->eKind == kEventMouseDown) {
- TkMacOSXSetEatButtonUp(false);
- }
- if (eventPtr->eKind == kEventMouseWheelMoved) {
- status = GetEventParameter(eventPtr->eventRef,
- 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);
-#endif
- 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();
tkwin = Tk_IdToWindow(dispPtr->display, medPtr->window);
if (eventPtr->eKind != kEventMouseDown) {
- /*
- * MouseMoved, MouseDragged or MouseWheelMoved
- */
+ int res = false;
- if (eventPtr->eKind == kEventMouseWheelMoved) {
- int res = GenerateMouseWheelEvent(medPtr);
- if (res) {
- statusPtr->stopProcessing = 1;
- }
- return res;
- } else {
- return GeneratePollingEvents(medPtr);
+ switch (eventPtr->eKind) {
+ case kEventMouseUp:
+ /*
+ * The window manager only needs to know about mouse down
+ * events and sometimes we need to "eat" the mouse up.
+ * Otherwise, we just pass the event to Tk.
+ */
+ if (TkMacOSXGetEatButtonUp()) {
+ TkMacOSXSetEatButtonUp(false);
+ } else {
+ res = GenerateButtonEvent(medPtr);
+ }
+ break;
+ case kEventMouseWheelMoved:
+ err = ChkErr(GetEventParameter, eventPtr->eventRef,
+ kEventParamMouseWheelDelta, typeLongInteger, NULL,
+ sizeof(long), NULL, &medPtr->delta);
+ if (err != noErr ) {
+ statusPtr->err = 1;
+ } else {
+ EventMouseWheelAxis axis;
+ err = ChkErr(GetEventParameter, eventPtr->eventRef,
+ kEventParamMouseWheelAxis, typeMouseWheelAxis,
+ NULL, sizeof(EventMouseWheelAxis), NULL, &axis);
+ if (err == noErr && axis == kEventMouseWheelAxisX) {
+ medPtr->state |= ShiftMask;
+ }
+ res = GenerateMouseWheelEvent(medPtr);
+ }
+ break;
+ case kEventMouseMoved:
+ case kEventMouseDragged:
+ res = GeneratePollingEvents(medPtr);
+ break;
+ default:
+ Tcl_Panic("Unknown mouse event !");
}
+ if (res) {
+ statusPtr->stopProcessing = 1;
+ }
+ return res;
}
-
+ TkMacOSXSetEatButtonUp(false);
if (medPtr->whichWin) {
/*
* We got a mouse down in a window
* See if this is the activate click
- * This click moves the window forward. We don't want
+ * This click moves the window forward. We don't want
* the corresponding mouse-up to be reported to the application
* or else it will mess up some Tk scripts.
*/
@@ -284,20 +272,20 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
&& (medPtr->whichWin != medPtr->activeNonFloating
|| !isFrontProcess)) {
Tk_Window grabWin = TkMacOSXGetCapture();
- if ((grabWin == NULL)) {
+ if (!grabWin) {
int grabState = TkGrabState((TkWindow*)tkwin);
if (grabState != TK_GRAB_NONE && grabState != TK_GRAB_IN_TREE) {
/* Now we want to set the focus to the local grabWin */
TkMacOSXSetEatButtonUp(true);
grabWin = (Tk_Window) (((TkWindow*)tkwin)->dispPtr->grabWinPtr);
BringWindowForward(GetWindowFromPort(
- TkMacOSXGetDrawablePort(((TkWindow*)grabWin)->window)),
- isFrontProcess);
+ TkMacOSXGetDrawablePort(((TkWindow*)grabWin)->window)),
+ isFrontProcess);
statusPtr->stopProcessing = 1;
return false;
}
}
- if ((grabWin != NULL) && (grabWin != tkwin)) {
+ if (grabWin && grabWin != tkwin) {
TkWindow * tkw, * grb;
tkw = (TkWindow *)tkwin;
grb = (TkWindow *)grabWin;
@@ -314,9 +302,9 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
* Clicks in the titlebar widgets are handled without bringing the
* window forward.
*/
- if ((result = HandleWindowTitlebarMouseDown(medPtr, tkwin)) != -1) {
- return result;
- } else
+ if ((result = HandleWindowTitlebarMouseDown(medPtr, tkwin)) != -1) {
+ return result;
+ } else
/*
* Only windows with the kWindowNoActivatesAttribute can
* receive mouse events in the background.
@@ -326,51 +314,55 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
/*
* Allow background window dragging & growing with Command down
*/
- if (!((medPtr->windowPart == inDrag ||
+ if (!((medPtr->windowPart == inDrag ||
medPtr->windowPart == inGrow) &&
medPtr->state & Mod1Mask)) {
TkMacOSXSetEatButtonUp(true);
BringWindowForward(medPtr->whichWin, isFrontProcess);
- }
- /*
- * Allow dragging & growing of windows that were/are in the
- * background.
- */
- if (!(medPtr->windowPart == inDrag ||
+ }
+ /*
+ * Allow dragging & growing of windows that were/are in the
+ * background.
+ */
+ if (!(medPtr->windowPart == inDrag ||
medPtr->windowPart == inGrow)) {
return false;
- }
- }
+ }
+ }
} else {
if ((result = HandleWindowTitlebarMouseDown(medPtr, tkwin)) != -1) {
return result;
}
}
switch (medPtr->windowPart) {
- case inDrag:
- SetPort(GetWindowPort(medPtr->whichWin));
- DragWindow(medPtr->whichWin, where, NULL);
- where2.h = where2.v = 0;
- LocalToGlobal(&where2);
- if (EqualPt(where, where2)) {
- return false;
+ case inDrag: {
+ WindowAttributes attributes;
+
+ GetWindowAttributes(medPtr->whichWin, &attributes);
+ if (!(attributes & kWindowAsyncDragAttribute)) {
+ TkMacOSXTrackingLoop(1);
+ DragWindow(medPtr->whichWin, where, NULL);
+ TkMacOSXTrackingLoop(0);
+ where2.h = where2.v = 0;
+ QDLocalToGlobalPoint(GetWindowPort(medPtr->whichWin),
+ &where2);
+ if (EqualPt(where, where2)) {
+ return false;
+ }
+ return true;
}
- TkMacOSXWindowOffset(medPtr->whichWin, &xOffset, &yOffset);
- where2.h -= xOffset;
- where2.v -= yOffset;
- TkGenWMConfigureEvent(tkwin, where2.h, where2.v,
- -1, -1, TK_LOCATION_CHANGED);
- return true;
break;
+ }
case inGrow:
/*
* Generally the content region is the domain of Tk
- * sub-windows. However, one exception is the grow
- * region. A button down in this area will be handled
- * by the window manager. Note: this means that Tk
+ * sub-windows. However, one exception is the grow
+ * region. A button down in this area will be handled
+ * by the window manager. Note: this means that Tk
* may not get button down events in this area!
*/
if (TkMacOSXGrowToplevel(medPtr->whichWin, where) == true) {
+ statusPtr->stopProcessing = 1;
return true;
} else {
return GenerateButtonEvent(medPtr);
@@ -392,14 +384,14 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
*
* HandleWindowTitlebarMouseDown --
*
- * Handle clicks in window titlebar.
+ * Handle clicks in window titlebar.
*
* Results:
- * 1 if event was handled, 0 if event was not handled,
- * -1 if MouseDown was not in window titlebar.
+ * 1 if event was handled, 0 if event was not handled,
+ * -1 if MouseDown was not in window titlebar.
*
* Side effects:
- * Additional events may be place on the Tk event queue.
+ * Additional events may be place on the Tk event queue.
*
*----------------------------------------------------------------------
*/
@@ -408,40 +400,41 @@ int
HandleWindowTitlebarMouseDown(MouseEventData * medPtr, Tk_Window tkwin)
{
int result = 0;
-
+
+ TkMacOSXTrackingLoop(1);
switch (medPtr->windowPart) {
- case inGoAway:
- if (TrackGoAway(medPtr->whichWin, medPtr->global)) {
- if (tkwin) {
- TkGenWMDestroyEvent(tkwin);
- result = 1;
- }
- }
- break;
- case inCollapseBox:
- if (TrackBox(medPtr->whichWin, medPtr->global, medPtr->windowPart)) {
- if (tkwin) {
- TkpWmSetState((TkWindow *)tkwin, IconicState);
- result = 1;
- }
- }
- break;
- case inZoomIn:
- case inZoomOut:
- if (TrackBox(medPtr->whichWin, medPtr->global, medPtr->windowPart)) {
- result = TkMacOSXZoomToplevel(medPtr->whichWin, medPtr->windowPart);
- }
- break;
- case inToolbarButton:
- if (TrackBox(medPtr->whichWin, medPtr->global, medPtr->windowPart)) {
- result = GenerateToolbarButtonEvent(medPtr);
- }
- break;
- default:
- result = -1;
- break;
+ case inGoAway:
+ if (TrackGoAway(medPtr->whichWin, medPtr->global)) {
+ if (tkwin) {
+ TkGenWMDestroyEvent(tkwin);
+ result = 1;
+ }
+ }
+ break;
+ case inCollapseBox:
+ if (TrackBox(medPtr->whichWin, medPtr->global, medPtr->windowPart)) {
+ if (tkwin) {
+ TkpWmSetState((TkWindow *)tkwin, IconicState);
+ result = 1;
+ }
+ }
+ break;
+ case inZoomIn:
+ case inZoomOut:
+ if (TrackBox(medPtr->whichWin, medPtr->global, medPtr->windowPart)) {
+ result = TkMacOSXZoomToplevel(medPtr->whichWin, medPtr->windowPart);
+ }
+ break;
+ case inToolbarButton:
+ if (TrackBox(medPtr->whichWin, medPtr->global, medPtr->windowPart)) {
+ result = GenerateToolbarButtonEvent(medPtr);
+ }
+ break;
+ default:
+ result = -1;
+ break;
}
-
+ TkMacOSXTrackingLoop(0);
return result;
}
@@ -450,16 +443,16 @@ HandleWindowTitlebarMouseDown(MouseEventData * medPtr, Tk_Window tkwin)
*
* GeneratePollingEvents --
*
- * This function polls the mouse position and generates X Motion,
- * Enter & Leave events. The cursor is also updated at this
- * time.
+ * This function polls the mouse position and generates X Motion,
+ * Enter & Leave events. The cursor is also updated at this
+ * time.
*
* Results:
- * True if event(s) are generated - false otherwise.
+ * True if event(s) are generated - false otherwise.
*
* Side effects:
- * Additional events may be place on the Tk event queue.
- * The cursor may be changed.
+ * Additional events may be place on the Tk event queue.
+ * The cursor may be changed.
*
*----------------------------------------------------------------------
*/
@@ -474,12 +467,12 @@ GeneratePollingEvents(MouseEventData * medPtr)
grabWin = TkMacOSXGetCapture();
- if ((!TkpIsWindowFloating(medPtr->whichWin)
+ if ((!TkpIsWindowFloating(medPtr->whichWin)
&& (medPtr->activeNonFloating != medPtr->whichWin))) {
/*
* If the window for this event is not floating, and is not the
* active non-floating window, don't generate polling events.
- * We don't send events to backgrounded windows. So either send
+ * We don't send events to backgrounded windows. So either send
* it to the grabWin, or NULL if there is no grabWin.
*/
@@ -487,23 +480,23 @@ GeneratePollingEvents(MouseEventData * medPtr)
} else {
/*
* First check whether the toplevel containing this mouse
- * event is the grab window. If not, then send the event
- * to the grab window. Otherwise, set tkWin to the subwindow
+ * event is the grab window. If not, then send the event
+ * to the grab window. Otherwise, set tkWin to the subwindow
* which most closely contains the mouse event.
*/
-
+
dispPtr = TkGetDisplayList();
rootwin = Tk_IdToWindow(dispPtr->display, medPtr->window);
- if ((rootwin == NULL)
+ if ((rootwin == NULL)
|| ((grabWin != NULL) && (rootwin != grabWin))) {
tkwin = grabWin;
} else {
- tkwin = Tk_TopCoordsToWindow(rootwin,
- medPtr->local.h, medPtr->local.v,
+ tkwin = Tk_TopCoordsToWindow(rootwin,
+ medPtr->local.h, medPtr->local.v,
&local_x, &local_y);
}
}
-
+
/*
* The following call will generate the appropiate X events and
* adjust any state that Tk must remember.
@@ -511,7 +504,7 @@ GeneratePollingEvents(MouseEventData * medPtr)
Tk_UpdatePointer(tkwin, medPtr->global.h, medPtr->global.v,
medPtr->state);
-
+
return true;
}
@@ -520,7 +513,7 @@ GeneratePollingEvents(MouseEventData * medPtr)
*
* BringWindowForward --
*
- * Bring this background window to the front. We also set state
+ * Bring this background window to the front. We also set state
* so Tk thinks the button is currently up.
*
* Results:
@@ -533,21 +526,20 @@ GeneratePollingEvents(MouseEventData * medPtr)
*/
static void
-BringWindowForward(WindowRef wRef, Boolean isFrontProcess)
+BringWindowForward(
+ WindowRef wRef,
+ Boolean isFrontProcess)
{
if (!isFrontProcess) {
ProcessSerialNumber ourPsn = {0, kCurrentProcess};
- OSStatus status = SetFrontProcess(&ourPsn);
- if (status != noErr) {
-#ifdef TK_MAC_DEBUG
- fprintf(stderr,"SetFrontProcess failed, %d\n", (int) status);
-#endif
- }
+
+ ChkErr(SetFrontProcess, &ourPsn);
}
-
+
if (!TkpIsWindowFloating(wRef)) {
- if (IsValidWindowPtr(wRef))
+ if (IsValidWindowPtr(wRef)) {
SelectWindow(wRef);
+ }
}
}
@@ -570,12 +562,12 @@ BringWindowForward(WindowRef wRef, Boolean isFrontProcess)
static int
GenerateMouseWheelEvent(MouseEventData * medPtr)
{
- Tk_Window tkwin, rootwin, grabWin;
+ Tk_Window tkwin, rootwin;
TkDisplay *dispPtr;
TkWindow *winPtr;
- XEvent xEvent;
+ XEvent xEvent;
- if ((!TkpIsWindowFloating(medPtr->whichWin)
+ if ((!TkpIsWindowFloating(medPtr->whichWin)
&& (medPtr->activeNonFloating != medPtr->whichWin))) {
tkwin = NULL;
} else {
@@ -584,24 +576,22 @@ GenerateMouseWheelEvent(MouseEventData * medPtr)
if (rootwin == NULL) {
tkwin = NULL;
} else {
- tkwin = Tk_TopCoordsToWindow(rootwin,
- medPtr->local.h, medPtr->local.v,
+ tkwin = Tk_TopCoordsToWindow(rootwin,
+ medPtr->local.h, medPtr->local.v,
&xEvent.xbutton.x, &xEvent.xbutton.y);
}
}
-
+
/*
* The following call will generate the appropiate X events and
* adjust any state that Tk must remember.
*/
- grabWin = TkMacOSXGetCapture();
-
- if ((tkwin == NULL) && (grabWin != NULL)) {
- tkwin = grabWin;
+ if (!tkwin) {
+ tkwin = TkMacOSXGetCapture();
}
if (!tkwin) {
- return false;
+ return false;
}
winPtr = (TkWindow *) tkwin;
xEvent.type = MouseWheelEvent;
@@ -628,12 +618,12 @@ GenerateMouseWheelEvent(MouseEventData * medPtr)
* next mouse up event
*
* Side effects:
- * None.
+ * None.
*
*----------------------------------------------------------------------
*/
-static int
-TkMacOSXGetEatButtonUp()
+int
+TkMacOSXGetEatButtonUp(void)
{
return gEatButtonUp;
}
@@ -644,7 +634,7 @@ TkMacOSXGetEatButtonUp()
* TkMacOSXSetEatButtonUp --
*
* Results:
- * None.
+ * None.
*
* Side effects:
* Sets the flag indicating if we need to eat the
@@ -652,7 +642,7 @@ TkMacOSXGetEatButtonUp()
*
*----------------------------------------------------------------------
*/
-static void
+void
TkMacOSXSetEatButtonUp(int f)
{
gEatButtonUp = f;
@@ -661,42 +651,78 @@ TkMacOSXSetEatButtonUp(int f)
/*
*----------------------------------------------------------------------
*
+ * TkMacOSXKeyModifiers --
+ *
+ * Returns the current state of the modifier keys.
+ *
+ * Results:
+ * An OS Modifier state.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+EventModifiers
+TkMacOSXModifierState(void)
+{
+ UInt32 keyModifiers;
+ Boolean isFrontProcess = false;
+
+ if (GetCurrentEvent()) {
+ ProcessSerialNumber frontPsn, ourPsn = {0, kCurrentProcess};
+ OSStatus err = ChkErr(GetFrontProcess, &frontPsn);
+
+ if (err == noErr) {
+ ChkErr(SameProcess, &frontPsn, &ourPsn, &isFrontProcess);
+ }
+ }
+ keyModifiers = isFrontProcess ? GetCurrentEventKeyModifiers() :
+ GetCurrentKeyModifiers();
+
+ return (EventModifiers)(keyModifiers & USHRT_MAX);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkMacOSXButtonKeyState --
*
- * Returns the current state of the button & modifier keys.
+ * Returns the current state of the button & modifier keys.
*
* Results:
- * A bitwise inclusive OR of a subset of the following:
- * Button1Mask, ShiftMask, LockMask, ControlMask, Mod?Mask,
- * Mod?Mask.
+ * A bitwise inclusive OR of a subset of the following:
+ * Button1Mask, ShiftMask, LockMask, ControlMask, Mod*Mask.
*
* Side effects:
- * None.
+ * None.
*
*----------------------------------------------------------------------
*/
unsigned int
-TkMacOSXButtonKeyState()
+TkMacOSXButtonKeyState(void)
{
UInt32 buttonState = 0, keyModifiers;
Boolean isFrontProcess = false;
-
+
if (GetCurrentEvent()) {
ProcessSerialNumber frontPsn, ourPsn = {0, kCurrentProcess};
- OSStatus status = GetFrontProcess(&frontPsn);
- if (status == noErr) {
- SameProcess(&frontPsn, &ourPsn, &isFrontProcess);
+ OSStatus err = ChkErr(GetFrontProcess, &frontPsn);
+
+ if (err == noErr) {
+ ChkErr(SameProcess, &frontPsn, &ourPsn, &isFrontProcess);
}
}
-
- if (!gEatButtonUp) {
+
+ if (!TkMacOSXGetEatButtonUp()) {
buttonState = isFrontProcess ? GetCurrentEventButtonState() :
GetCurrentButtonState();
}
keyModifiers = isFrontProcess ? GetCurrentEventKeyModifiers() :
GetCurrentKeyModifiers();
-
+
return ButtonModifiers2State(buttonState, keyModifiers);
}
@@ -721,11 +747,11 @@ static unsigned int
ButtonModifiers2State(UInt32 buttonState, UInt32 keyModifiers)
{
unsigned int state;
-
+
/* Tk supports at most 5 buttons */
state = (buttonState & ((1<<5) - 1)) << 8;
-
- if (keyModifiers & alphaLock) {
+
+ if (keyModifiers & alphaLock) {
state |= LockMask;
}
if (keyModifiers & shiftKey) {
@@ -740,10 +766,10 @@ ButtonModifiers2State(UInt32 buttonState, UInt32 keyModifiers)
if (keyModifiers & optionKey) {
state |= Mod2Mask; /* option key */
}
- if (keyModifiers & kEventKeyModifierNumLockMask) {
+ if (keyModifiers & kEventKeyModifierNumLockMask) {
state |= Mod3Mask;
}
- if (keyModifiers & kEventKeyModifierFnMask) {
+ if (keyModifiers & kEventKeyModifierFnMask) {
state |= Mod4Mask;
}
@@ -755,16 +781,16 @@ ButtonModifiers2State(UInt32 buttonState, UInt32 keyModifiers)
*
* XQueryPointer --
*
- * Check the current state of the mouse. This is not a complete
- * implementation of this function. It only computes the root
- * coordinates and the current mask.
+ * Check the current state of the mouse. This is not a complete
+ * implementation of this function. It only computes the root
+ * coordinates and the current mask.
*
* Results:
- * Sets root_x_return, root_y_return, and mask_return. Returns
- * true on success.
+ * Sets root_x_return, root_y_return, and mask_return. Returns
+ * true on success.
*
* Side effects:
- * None.
+ * None.
*
*----------------------------------------------------------------------
*/
@@ -786,48 +812,41 @@ XQueryPointer(
if (getGlobal || getLocal) {
Point where, local;
- OSStatus status;
+ OSStatus err = noErr;
int gotMouseLoc = 0;
EventRef ev = GetCurrentEvent();
if (ev && getLocal) {
- status = GetEventParameter(ev,
- kEventParamWindowMouseLocation,
- typeQDPoint, NULL,
- sizeof(Point), NULL,
- &local);
- gotMouseLoc = (status == noErr);
+ err = ChkErr(GetEventParameter, ev, kEventParamWindowMouseLocation,
+ typeQDPoint, NULL, sizeof(Point), NULL, &local);
+ gotMouseLoc = (err == noErr);
}
if (getGlobal || !gotMouseLoc) {
if (ev) {
- status = GetEventParameter(ev,
- kEventParamMouseLocation,
- typeQDPoint, NULL,
- sizeof(Point), NULL,
- &where);
+ err = ChkErr(GetEventParameter, ev, kEventParamMouseLocation,
+ typeQDPoint, NULL, sizeof(Point), NULL, &where);
}
- if (!ev || status != noErr) {
+ if (!ev || err != noErr) {
GetGlobalMouse(&where);
}
}
if (getLocal) {
WindowRef whichWin;
if (ev) {
- status = GetEventParameter(ev,
- kEventParamWindowRef,
- typeWindowRef, NULL,
- sizeof(WindowRef), NULL,
+ err = ChkErr(GetEventParameter, ev, kEventParamWindowRef,
+ typeWindowRef, NULL, sizeof(WindowRef), NULL,
&whichWin);
}
- if (!ev || status != noErr) {
+ if (!ev || err != noErr) {
FindWindow(where, &whichWin);
}
if (gotMouseLoc) {
if (whichWin) {
Rect widths;
- GetWindowStructureWidths(whichWin, &widths);
+
+ ChkErr(GetWindowStructureWidths, whichWin, &widths);
local.h -= widths.left;
- local.v -= widths.top;
+ local.v -= widths.top;
}
} else {
local = where;
@@ -856,15 +875,15 @@ XQueryPointer(
*
* TkGenerateButtonEventForXPointer --
*
- * This procedure generates an X button event for the current
- * pointer state as reported by XQueryPointer().
+ * This procedure generates an X button event for the current
+ * pointer state as reported by XQueryPointer().
*
* Results:
- * True if event(s) are generated - false otherwise.
+ * True if event(s) are generated - false otherwise.
*
* Side effects:
- * Additional events may be place on the Tk event queue.
- * Grab state may also change.
+ * Additional events may be place on the Tk event queue.
+ * Grab state may also change.
*
*----------------------------------------------------------------------
*/
@@ -875,7 +894,7 @@ TkGenerateButtonEventForXPointer(
{
MouseEventData med;
int global_x, global_y, local_x, local_y;
-
+
bzero(&med, sizeof(MouseEventData));
XQueryPointer(NULL, None, NULL, NULL, &global_x, &global_y,
&local_x, &local_y, &med.state);
@@ -894,16 +913,16 @@ TkGenerateButtonEventForXPointer(
*
* TkGenerateButtonEvent --
*
- * Given a global x & y position and the button key status this
- * procedure generates the appropiate X button event. It also
- * handles the state changes needed to implement implicit grabs.
+ * Given a global x & y position and the button key status this
+ * procedure generates the appropiate X button event. It also
+ * handles the state changes needed to implement implicit grabs.
*
* Results:
- * True if event(s) are generated - false otherwise.
+ * True if event(s) are generated - false otherwise.
*
* Side effects:
- * Additional events may be place on the Tk event queue.
- * Grab state may also change.
+ * Additional events may be place on the Tk event queue.
+ * Grab state may also change.
*
*----------------------------------------------------------------------
*/
@@ -916,7 +935,7 @@ TkGenerateButtonEvent(
unsigned int state) /* Button Key state suitable for X event */
{
MouseEventData med;
-
+
bzero(&med, sizeof(MouseEventData));
med.state = state;
med.window = window;
@@ -935,15 +954,15 @@ TkGenerateButtonEvent(
*
* GenerateButtonEvent --
*
- * Generate an X button event from a MouseEventData structure.
- * Handles the state changes needed to implement implicit grabs.
+ * Generate an X button event from a MouseEventData structure.
+ * Handles the state changes needed to implement implicit grabs.
*
* Results:
- * True if event(s) are generated - false otherwise.
+ * True if event(s) are generated - false otherwise.
*
* Side effects:
- * Additional events may be place on the Tk event queue.
- * Grab state may also change.
+ * Additional events may be place on the Tk event queue.
+ * Grab state may also change.
*
*----------------------------------------------------------------------
*/
@@ -955,29 +974,30 @@ GenerateButtonEvent(MouseEventData * medPtr)
int dummy;
TkDisplay *dispPtr;
- /*
+#if UNUSED
+ /*
* ButtonDown events will always occur in the front
- * window. ButtonUp events, however, may occur anywhere
- * on the screen. ButtonUp events should only be sent
+ * window. ButtonUp events, however, may occur anywhere
+ * on the screen. ButtonUp events should only be sent
* to Tk if in the front window or during an implicit grab.
*/
- if (0
- && ((medPtr->activeNonFloating == NULL)
- || ((!(TkpIsWindowFloating(medPtr->whichWin))
+ if ((medPtr->activeNonFloating == NULL)
+ || ((!(TkpIsWindowFloating(medPtr->whichWin))
&& (medPtr->activeNonFloating != medPtr->whichWin))
- && TkMacOSXGetCapture() == NULL))) {
+ && TkMacOSXGetCapture() == NULL)) {
return false;
}
+#endif
dispPtr = TkGetDisplayList();
tkwin = Tk_IdToWindow(dispPtr->display, medPtr->window);
if (tkwin != NULL) {
- tkwin = Tk_TopCoordsToWindow(tkwin, medPtr->local.h, medPtr->local.v,
+ tkwin = Tk_TopCoordsToWindow(tkwin, medPtr->local.h, medPtr->local.v,
&dummy, &dummy);
}
- Tk_UpdatePointer(tkwin, medPtr->global.h, medPtr->global.v, medPtr->state);
+ Tk_UpdatePointer(tkwin, medPtr->global.h, medPtr->global.v, medPtr->state);
return true;
}
@@ -1014,7 +1034,7 @@ GenerateToolbarButtonEvent(MouseEventData * medPtr)
medPtr->local.h, medPtr->local.v, &event.x, &event.y);
}
if (!tkwin) {
- return true;
+ return true;
}
winPtr = (TkWindow *)tkwin;