summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXMouseEvent.c
diff options
context:
space:
mode:
authordas <das>2006-04-28 06:02:57 (GMT)
committerdas <das>2006-04-28 06:02:57 (GMT)
commita5b92093185c667fa3159a2ee58b5682290af6b1 (patch)
tree5b3992c68a12ca95ff81a211d111286d7c82c2e0 /macosx/tkMacOSXMouseEvent.c
parent29fd0ac98c568926da12b00ea63d88c6d98985f7 (diff)
downloadtk-a5b92093185c667fa3159a2ee58b5682290af6b1.zip
tk-a5b92093185c667fa3159a2ee58b5682290af6b1.tar.gz
tk-a5b92093185c667fa3159a2ee58b5682290af6b1.tar.bz2
* macosx/tkMacOSXWm.c (TkWmMapWindow, InitialWindowBounds): fix use of
potentially stale window position in initial configure event on first map of a window. [Bug 1476443] (TkMacOSXWindowOffset): use modern GetWindowStructureWidths API. * macosx/tkMacOSXInt.h: * macosx/tkMacOSXMouseEvent.c (TkGenerateButtonEventForXPointer): new internal function to generate button events for current pointer directly, without requiring prior call to XQueryPointer(). * macosx/tkMacOSXMouseEvent.c (XQueryPointer): implement return of window-local pointer position. * macosx/tkMacOSXInt.h: use improvements above to avoid calls to * macosx/tkMacOSXKeyEvent.c: GlobalToLocal() when the current port might * macosx/tkMacOSXMenu.c: not be set correctly. May fix [Bug 1243318] * macosx/tkMacOSXMenus.c: * macosx/tkMacOSXScale.c: * macosx/tkMacOSXScrlbr.c: * tkAboutDlg.r: update copyright. * macosx/tkMacOSXCarbonEvents.c: sync with HEAD * macosx/tkMacOSXDebug.c: * macosx/tkMacOSXDebug.h: * macosx/tkMacOSXDraw.c: * macosx/tkMacOSXEvent.c: * macosx/tkMacOSXEvent.h: * macosx/tkMacOSXFont.h: * macosx/tkMacOSXInit.c: * macosx/tkMacOSXInt.h: * macosx/tkMacOSXKeyEvent.c: * macosx/tkMacOSXMenu.c: * macosx/tkMacOSXMenubutton.c: * macosx/tkMacOSXMouseEvent.c: * macosx/tkMacOSXSend.c: * macosx/tkMacOSXTest.c: * macosx/tkMacOSXWindowEvent.c: * macosx/tkMacOSXWm.c:
Diffstat (limited to 'macosx/tkMacOSXMouseEvent.c')
-rw-r--r--macosx/tkMacOSXMouseEvent.c115
1 files changed, 99 insertions, 16 deletions
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index 9d0d735..b716a41 100644
--- a/macosx/tkMacOSXMouseEvent.c
+++ b/macosx/tkMacOSXMouseEvent.c
@@ -5,7 +5,7 @@
* on MacOS X.
*
* Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2005 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright (c) 2005-2006 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.
@@ -54,7 +54,7 @@
* software in accordance with the terms specified in this
* license.
*
- * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.6.2.13 2006/04/11 05:42:11 das Exp $
+ * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.6.2.14 2006/04/28 06:03:00 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -117,7 +117,7 @@ static void TkMacOSXSetEatButtonUp(int f);
*----------------------------------------------------------------------
*/
-int
+MODULE_SCOPE int
TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
{
Tk_Window tkwin;
@@ -775,24 +775,69 @@ XQueryPointer(
int* win_y_return,
unsigned int* mask_return)
{
- if (root_x_return && root_y_return) {
- Point where;
- EventRef ev;
+ int getGlobal = (root_x_return && root_y_return);
+ int getLocal = (win_x_return && win_y_return);
+
+ if (getGlobal || getLocal) {
+ Point where, local;
OSStatus status;
+ int gotMouseLoc = 0;
+ EventRef ev = GetCurrentEvent();
- if ((ev = GetCurrentEvent())) {
+ if (ev && getLocal) {
status = GetEventParameter(ev,
- kEventParamMouseLocation,
+ kEventParamWindowMouseLocation,
typeQDPoint, NULL,
- sizeof(where), NULL,
- &where);
+ sizeof(Point), NULL,
+ &local);
+ gotMouseLoc = (status == noErr);
}
- if (!ev || status != noErr) {
- GetGlobalMouse(&where);
+ if (getGlobal || !gotMouseLoc) {
+ if (ev) {
+ status = GetEventParameter(ev,
+ kEventParamMouseLocation,
+ typeQDPoint, NULL,
+ sizeof(Point), NULL,
+ &where);
+ }
+ if (!ev || status != noErr) {
+ GetGlobalMouse(&where);
+ }
+ }
+ if (getLocal) {
+ WindowRef whichWin;
+ if (ev) {
+ status = GetEventParameter(ev,
+ kEventParamWindowRef,
+ typeWindowRef, NULL,
+ sizeof(WindowRef), NULL,
+ &whichWin);
+ }
+ if (!ev || status != noErr) {
+ FindWindow(where, &whichWin);
+ }
+ if (gotMouseLoc) {
+ if (whichWin) {
+ Rect widths;
+ GetWindowStructureWidths(whichWin, &widths);
+ local.h -= widths.left;
+ local.v -= widths.top;
+ }
+ } else {
+ local = where;
+ if (whichWin) {
+ QDGlobalToLocalPoint(GetWindowPort(whichWin), &local);
+ }
+ }
+ }
+ if (getGlobal) {
+ *root_x_return = where.h;
+ *root_y_return = where.v;
+ }
+ if (getLocal) {
+ *win_x_return = local.h;
+ *win_y_return = local.v;
}
-
- *root_x_return = where.h;
- *root_y_return = where.v;
}
if (mask_return) {
*mask_return = TkMacOSXButtonKeyState();
@@ -803,6 +848,44 @@ XQueryPointer(
/*
*----------------------------------------------------------------------
*
+ * TkGenerateButtonEventForXPointer --
+ *
+ * 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.
+ *
+ * Side effects:
+ * Additional events may be place on the Tk event queue.
+ * Grab state may also change.
+ *
+ *----------------------------------------------------------------------
+ */
+
+MODULE_SCOPE int
+TkGenerateButtonEventForXPointer(
+ Window window) /* X Window containing button event. */
+{
+ 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);
+ med.global.h = global_x;
+ med.global.v = global_y;
+ med.local.h = local_x;
+ med.local.v = local_y;
+ med.window = window;
+ med.activeNonFloating = ActiveNonFloatingWindow();
+
+ return GenerateButtonEvent(&med);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkGenerateButtonEvent --
*
* Given a global x & y position and the button key status this
@@ -859,7 +942,7 @@ TkGenerateButtonEvent(
*----------------------------------------------------------------------
*/
-static int
+static int
GenerateButtonEvent(MouseEventData * medPtr)
{
Tk_Window tkwin;