summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordas <das>2006-04-28 06:02:47 (GMT)
committerdas <das>2006-04-28 06:02:47 (GMT)
commitcfb7b37a4c7a4ab2b98b1ee2c1b2c2b7a99d5525 (patch)
treedbf40a74ecf59b8ccec931d28b36eb0dfdafb1a1
parent8aa2c70ff82e72592bfdc9d79454a4ec9a819fd8 (diff)
downloadtk-cfb7b37a4c7a4ab2b98b1ee2c1b2c2b7a99d5525.zip
tk-cfb7b37a4c7a4ab2b98b1ee2c1b2c2b7a99d5525.tar.gz
tk-cfb7b37a4c7a4ab2b98b1ee2c1b2c2b7a99d5525.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/tkMacOSXDebug.h: sync #includes with core-8-4-branch. * macosx/tkMacOSXEvent.h: * macosx/tkMacOSXFont.h:
-rw-r--r--ChangeLog28
-rw-r--r--macosx/tkAboutDlg.r11
-rw-r--r--macosx/tkMacOSXDebug.h8
-rw-r--r--macosx/tkMacOSXEvent.h6
-rw-r--r--macosx/tkMacOSXFont.h8
-rw-r--r--macosx/tkMacOSXInt.h3
-rw-r--r--macosx/tkMacOSXKeyEvent.c25
-rw-r--r--macosx/tkMacOSXMenu.c9
-rw-r--r--macosx/tkMacOSXMenus.c12
-rw-r--r--macosx/tkMacOSXMouseEvent.c113
-rw-r--r--macosx/tkMacOSXScale.c10
-rw-r--r--macosx/tkMacOSXScrlbr.c9
-rw-r--r--macosx/tkMacOSXWm.c69
13 files changed, 185 insertions, 126 deletions
diff --git a/ChangeLog b/ChangeLog
index f9013f1..5207314 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2006-04-28 Daniel Steffen <das@users.sourceforge.net>
+
+ * 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/tkMacOSXDebug.h: sync #includes with core-8-4-branch.
+ * macosx/tkMacOSXEvent.h:
+ * macosx/tkMacOSXFont.h:
+
2006-04-26 Don Porter <dgp@users.sourceforge.net>
*** 8.5a4 TAGGED FOR RELEASE ***
diff --git a/macosx/tkAboutDlg.r b/macosx/tkAboutDlg.r
index 72a5086..3bbdc28 100644
--- a/macosx/tkAboutDlg.r
+++ b/macosx/tkAboutDlg.r
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkAboutDlg.r,v 1.6 2005/05/23 20:23:24 das Exp $
+ * RCS: @(#) $Id: tkAboutDlg.r,v 1.7 2006/04/28 06:02:48 das Exp $
*/
/*
@@ -33,7 +33,7 @@
*/
resource 'DLOG' (128, "About Box", purgeable) {
- {60, 40, 300, 404},
+ {60, 40, 332, 404},
movableDBoxProc,
visible,
noGoAway,
@@ -45,10 +45,11 @@ resource 'DLOG' (128, "About Box", purgeable) {
resource 'DITL' (128, "About Box", purgeable) {
{
- {200, 147, 220, 217}, Button {enabled, "Ok"},
- { 20, 108, 180, 344}, StaticText {disabled,
+ {232, 147, 252, 217}, Button {enabled, "Ok"},
+ { 20, 108, 212, 344}, StaticText {disabled,
"Tcl " TCL_PATCH_LEVEL " & Tk " TK_PATCH_LEVEL "\n\n"
- "© 2005 Tcl Core Team." "\n\n"
+ "© 2002-2006 Tcl Core Team." "\n\n"
+ "© 2002-2006 Daniel A. Steffen." "\n\n"
"Jim Ingham & Ian Reid" "\n"
"© 2001-2002 Apple Computer, Inc." "\n\n"
"Jim Ingham & Ray Johnson" "\n"
diff --git a/macosx/tkMacOSXDebug.h b/macosx/tkMacOSXDebug.h
index 7039b36..f550923 100644
--- a/macosx/tkMacOSXDebug.h
+++ b/macosx/tkMacOSXDebug.h
@@ -50,18 +50,16 @@
* software in accordance with the terms specified in this
* license.
*
- * RCS: @(#) $Id: tkMacOSXDebug.h,v 1.7 2006/01/10 05:37:51 das Exp $
+ * RCS: @(#) $Id: tkMacOSXDebug.h,v 1.8 2006/04/28 06:02:48 das Exp $
*/
#ifndef _TKMACDEBUG
#define _TKMACDEBUG
-#ifndef _TKINT
-#include "tkInt.h"
+#ifndef _TKMACINT
+#include "tkMacOSXInt.h"
#endif
-#include <Carbon/Carbon.h>
-
/* The following define enables printing of debug messages to stderr: */
/* #define TK_MAC_DEBUG 1 */
diff --git a/macosx/tkMacOSXEvent.h b/macosx/tkMacOSXEvent.h
index 8219a36..00f1963 100644
--- a/macosx/tkMacOSXEvent.h
+++ b/macosx/tkMacOSXEvent.h
@@ -50,14 +50,14 @@
* software in accordance with the terms specified in this
* license.
*
- * RCS: @(#) $Id: tkMacOSXEvent.h,v 1.9 2006/03/28 02:43:24 das Exp $
+ * RCS: @(#) $Id: tkMacOSXEvent.h,v 1.10 2006/04/28 06:02:48 das Exp $
*/
#ifndef _TKMACEVENT
#define _TKMACEVENT
-#ifndef _TK
-#include "tk.h"
+#ifndef _TKMACINT
+#include "tkMacOSXInt.h"
#endif
typedef struct {
diff --git a/macosx/tkMacOSXFont.h b/macosx/tkMacOSXFont.h
index 9856722..22555a5 100644
--- a/macosx/tkMacOSXFont.h
+++ b/macosx/tkMacOSXFont.h
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXFont.h,v 1.3 2006/03/28 02:43:24 das Exp $
+ * RCS: @(#) $Id: tkMacOSXFont.h,v 1.4 2006/04/28 06:02:48 das Exp $
*/
#ifndef TKMACOSXFONT_H
@@ -17,7 +17,9 @@
#include "tkFont.h"
-#include <Carbon/Carbon.h>
+#ifndef _TKMACINT
+#include "tkMacOSXInt.h"
+#endif
/*
* Switches
@@ -92,7 +94,6 @@ typedef struct {} DrawingContext;
#endif /* ? TK_MAC_USE_QUARZ */
-
/*
* Function prototypes
*/
@@ -110,5 +111,4 @@ MODULE_SCOPE void TkMacOSXQuarzEndDraw(
TkMacOSXFontDrawingContext * contextPtr);
#endif /* TK_MAC_USE_QUARZ */
-
#endif /*TKMACOSXFONT_H*/
diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h
index 09eb983..2bc85e4 100644
--- a/macosx/tkMacOSXInt.h
+++ b/macosx/tkMacOSXInt.h
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXInt.h,v 1.15 2006/04/11 07:36:36 das Exp $
+ * RCS: @(#) $Id: tkMacOSXInt.h,v 1.16 2006/04/28 06:02:48 das Exp $
*/
#ifndef _TKMACINT
@@ -167,6 +167,7 @@ MODULE_SCOPE void TkMacOSXDefaultStartupScript(void);
MODULE_SCOPE int TkMacOSXGenerateFocusEvent( Window window, int activeFlag);
MODULE_SCOPE WindowClass TkMacOSXWindowClass(TkWindow *winPtr);
MODULE_SCOPE int TkMacOSXIsWindowZoomed(TkWindow *winPtr);
+MODULE_SCOPE int TkGenerateButtonEventForXPointer(Window window);
MODULE_SCOPE int TkMacOSXCompareColors(unsigned long c1, unsigned long c2);
MODULE_SCOPE void* TkMacOSXGetNamedSymbol(const char* module, const char* symbol);
diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c
index d76de1e..17923e8 100644
--- a/macosx/tkMacOSXKeyEvent.c
+++ b/macosx/tkMacOSXKeyEvent.c
@@ -50,7 +50,7 @@
* software in accordance with the terms specified in this
* license.
*
- * RCS: @(#) $Id: tkMacOSXKeyEvent.c,v 1.13 2006/03/24 14:58:01 das Exp $
+ * RCS: @(#) $Id: tkMacOSXKeyEvent.c,v 1.14 2006/04/28 06:02:49 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -58,8 +58,8 @@
typedef struct {
WindowRef whichWindow;
- Point global;
- Point local;
+ int global_x, global_y;
+ int local_x, local_y;
unsigned int state;
unsigned char ch;
UInt32 keyCode;
@@ -435,19 +435,18 @@ GenerateKeyEvent(
static int
InitKeyData(KeyEventData * keyEventDataPtr)
{
- int x, y;
memset (keyEventDataPtr, 0, sizeof(*keyEventDataPtr));
keyEventDataPtr->whichWindow = ActiveNonFloatingWindow();
if (keyEventDataPtr->whichWindow == NULL) {
return false;
}
- XQueryPointer(NULL, None, NULL, NULL, &x, &y,
- NULL, NULL, &keyEventDataPtr->state);
- keyEventDataPtr->global.v = x;
- keyEventDataPtr->global.v = y;
- keyEventDataPtr->local = keyEventDataPtr->global;
- GlobalToLocal(&keyEventDataPtr->local);
+ XQueryPointer(NULL, None, NULL, NULL,
+ &keyEventDataPtr->global_x,
+ &keyEventDataPtr->global_y,
+ &keyEventDataPtr->local_x,
+ &keyEventDataPtr->local_y,
+ &keyEventDataPtr->state);
return true;
}
@@ -534,8 +533,8 @@ InitKeyEvent(
eventPtr->xkey.same_screen = true;
eventPtr->xkey.subwindow = None;
eventPtr->xkey.time = TkpGetMS();
- eventPtr->xkey.x_root = e->global.h;
- eventPtr->xkey.y_root = e->global.v;
+ eventPtr->xkey.x_root = e->global_x;
+ eventPtr->xkey.y_root = e->global_y;
eventPtr->xkey.window = Tk_WindowId(tkwin);
eventPtr->xkey.display = Tk_Display(tkwin);
eventPtr->xkey.root = XRootWindow(Tk_Display(tkwin), 0);
@@ -543,7 +542,7 @@ InitKeyEvent(
eventPtr->xkey.trans_chars[0] = 0;
Tk_TopCoordsToWindow(
- tkwin, e->local.h, e->local.v,
+ tkwin, e->local_x, e->local_y,
&eventPtr->xkey.x, &eventPtr->xkey.y);
eventPtr->xkey.keycode = e->ch |
diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c
index 6eb384e..d7b567d 100644
--- a/macosx/tkMacOSXMenu.c
+++ b/macosx/tkMacOSXMenu.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.27 2006/03/28 02:43:24 das Exp $
+ * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.28 2006/04/28 06:02:49 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -1409,9 +1409,6 @@ TkpPostMenu(
(char *) NULL);
result = TCL_ERROR;
} else {
- Window dummyWin;
- unsigned int state;
- int dummy, mouseX, mouseY;
short menuID;
Window window;
int oldWidth = menuPtr->totalWidth;
@@ -1480,10 +1477,8 @@ TkpPostMenu(
* Simulate the mouse up.
*/
- XQueryPointer(NULL, None, &dummyWin, &dummyWin, &mouseX,
- &mouseY, &dummy, &dummy, &state);
window = Tk_WindowId(menuPtr->tkwin);
- TkGenerateButtonEvent(mouseX, mouseY, window, state);
+ TkGenerateButtonEventForXPointer(window);
/*
* Dispatch the command.
diff --git a/macosx/tkMacOSXMenus.c b/macosx/tkMacOSXMenus.c
index 95702a5..ab1926e 100644
--- a/macosx/tkMacOSXMenus.c
+++ b/macosx/tkMacOSXMenus.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXMenus.c,v 1.10 2006/03/24 14:58:01 das Exp $
+ * RCS: @(#) $Id: tkMacOSXMenus.c,v 1.11 2006/04/28 06:02:49 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -219,7 +219,7 @@ GenerateEditEvent(
int flag)
{
XVirtualEvent event;
- Point where;
+ int x, y;
Tk_Window tkwin;
Window window;
TkDisplay *dispPtr;
@@ -242,12 +242,8 @@ GenerateEditEvent(
event.time = TkpGetMS();
XQueryPointer(NULL, None, NULL, NULL,
- &event.x_root, &event.y_root, NULL, NULL, &event.state);
- where.h = event.x_root;
- where.v = event.y_root;
- GlobalToLocal(&where);
- tkwin = Tk_TopCoordsToWindow(tkwin, where.h, where.v,
- &event.x, &event.y);
+ &event.x_root, &event.y_root, &x, &y, &event.state);
+ tkwin = Tk_TopCoordsToWindow(tkwin, x, y, &event.x, &event.y);
event.same_screen = true;
event.user_data = NULL;
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index 51b33dc..6326ec5 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.21 2006/04/11 05:42:01 das Exp $
+ * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.22 2006/04/28 06:02:49 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -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;
diff --git a/macosx/tkMacOSXScale.c b/macosx/tkMacOSXScale.c
index b50be70..8c5e694 100644
--- a/macosx/tkMacOSXScale.c
+++ b/macosx/tkMacOSXScale.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXScale.c,v 1.7 2006/03/24 14:58:01 das Exp $
+ * RCS: @(#) $Id: tkMacOSXScale.c,v 1.8 2006/04/28 06:02:49 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -395,12 +395,10 @@ MacScaleEventProc(clientData, eventPtr)
MacScale *macScalePtr = (MacScale *) clientData;
Point where;
Rect bounds;
- int part, x, y, dummy;
- unsigned int state;
+ int part;
CGrafPtr saveWorld;
GDHandle saveDevice;
GWorldPtr destPort;
- Window dummyWin;
#ifdef TK_MAC_DEBUG
fprintf(stderr,"MacScaleEventProc\n" );
@@ -438,9 +436,7 @@ MacScaleEventProc(clientData, eventPtr)
* The TrackControl call will "eat" the ButtonUp event. We now
* generate a ButtonUp event so Tk will unset implicit grabs etc.
*/
- XQueryPointer(NULL, None, &dummyWin, &dummyWin, &x,
- &y, &dummy, &dummy, &state);
- TkGenerateButtonEvent(x, y, Tk_WindowId(macScalePtr->info.tkwin), state);
+ TkGenerateButtonEventForXPointer(Tk_WindowId(macScalePtr->info.tkwin));
SetGWorld(saveWorld, saveDevice);
}
diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c
index 8243b00..abb52c8 100644
--- a/macosx/tkMacOSXScrlbr.c
+++ b/macosx/tkMacOSXScrlbr.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXScrlbr.c,v 1.18 2006/03/24 14:58:01 das Exp $
+ * RCS: @(#) $Id: tkMacOSXScrlbr.c,v 1.19 2006/04/28 06:02:49 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -790,8 +790,7 @@ ScrollbarBindProc(
if (eventPtr->type == ButtonPress) {
Point where;
Rect bounds;
- int part, x, y, dummy;
- unsigned int state;
+ int part;
CGrafPtr saveWorld;
GDHandle saveDevice;
GWorldPtr destPort;
@@ -876,10 +875,8 @@ ScrollbarBindProc(
* The TrackControl call will "eat" the ButtonUp event. We now
* generate a ButtonUp event so Tk will unset implicit grabs etc.
*/
- XQueryPointer(NULL, None, &window, &window, &x,
- &y, &dummy, &dummy, &state);
window = Tk_WindowId(scrollPtr->tkwin);
- TkGenerateButtonEvent(x, y, window, state);
+ TkGenerateButtonEventForXPointer(window);
SetGWorld(saveWorld, saveDevice);
}
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index 17d408c..5f6a057 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -8,11 +8,12 @@
*
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
* Copyright 2001, Apple Computer, Inc.
+ * Copyright (c) 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.
*
- * RCS: @(#) $Id: tkMacOSXWm.c,v 1.32 2006/04/22 04:12:02 das Exp $
+ * RCS: @(#) $Id: tkMacOSXWm.c,v 1.33 2006/04/28 06:02:49 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -317,14 +318,9 @@ TkWmMapWindow(
* be mapped. */
{
WmInfo *wmPtr = winPtr->wmInfoPtr;
- Point where = {0, 0};
- int xOffset, yOffset;
- int firstMap = false;
- MacDrawable *macWin;
if (wmPtr->flags & WM_NEVER_MAPPED) {
wmPtr->flags &= ~WM_NEVER_MAPPED;
- firstMap = true;
/*
* Create the underlying Mac window for this Tk window.
@@ -332,18 +328,12 @@ TkWmMapWindow(
if (!TkMacOSXHostToplevelExists(winPtr)) {
TkMacOSXMakeRealWindowExist(winPtr);
}
- macWin = (MacDrawable *) winPtr->window;
/*
* Generate configure event when we first map the window.
*/
- LocalToGlobal(&where);
- TkMacOSXWindowOffset( GetWindowFromPort(TkMacOSXGetDrawablePort((Drawable) macWin)),
- &xOffset, &yOffset);
- where.h -= xOffset;
- where.v -= yOffset;
- TkGenWMConfigureEvent((Tk_Window) winPtr,
- where.h, where.v, -1, -1, TK_LOCATION_CHANGED);
+ TkGenWMConfigureEvent((Tk_Window) winPtr, wmPtr->x, wmPtr->y, -1, -1,
+ TK_LOCATION_CHANGED);
/*
* This is the first time this window has ever been mapped.
@@ -3055,7 +3045,6 @@ Tk_SetGrid(
heightInc = 1;
}
-
/*
* Find the top-level window for tkwin, plus the window manager
* information.
@@ -4462,11 +4451,11 @@ InitialWindowBounds(
TkWindow *winPtr, /* Window to get initial bounds for. */
Rect *geometry) /* On return the initial bounds. */
{
- int x, y;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
static int defaultX = 5;
static int defaultY = 45;
- if (!(winPtr->wmInfoPtr->sizeHintsFlags & (USPosition | PPosition))) {
+ if (!(wmPtr->sizeHintsFlags & (USPosition | PPosition))) {
/*
* We will override the program & hopefully place the
* window in a "better" location.
@@ -4478,19 +4467,16 @@ InitialWindowBounds(
defaultX = 5;
defaultY = 45;
}
- x = defaultX;
- y = defaultY;
+ wmPtr->x = defaultX;
+ wmPtr->y = defaultY;
defaultX += 20;
defaultY += 20;
- } else {
- x = winPtr->wmInfoPtr->x;
- y = winPtr->wmInfoPtr->y;
}
- geometry->left = x;
- geometry->top = y;
- geometry->right = x + winPtr->changes.width;
- geometry->bottom = y + winPtr->changes.height;
+ geometry->left = wmPtr->x;
+ geometry->top = wmPtr->y;
+ geometry->right = wmPtr->x + winPtr->changes.width;
+ geometry->bottom = wmPtr->y + winPtr->changes.height;
}
/*
@@ -5590,32 +5576,11 @@ TkMacOSXWindowOffset(
int *xOffset,
int *yOffset)
{
- OSErr err = noErr;
- static RgnHandle strucRgn = NULL;
- static RgnHandle contRgn = NULL;
- Rect strucRect, contRect;
-
- if (!strucRgn) {
- if(!(strucRgn = NewRgn())) {
- err = MemError();
- }
- }
- if (!contRgn) {
- if(!(contRgn = NewRgn())) {
- err = MemError();
- }
- }
- if (err == noErr) {
- GetWindowRegion(wRef, kWindowStructureRgn, strucRgn);
- GetWindowRegion(wRef, kWindowContentRgn, contRgn);
- GetRegionBounds(strucRgn,&strucRect);
- GetRegionBounds(contRgn,&contRect);
- *xOffset = contRect.left - strucRect.left;
- *yOffset = contRect.top - strucRect.top;
- } else {
- *xOffset = 0;
- *yOffset = 0;
- }
+ Rect widths;
+
+ GetWindowStructureWidths(wRef, &widths);
+ *xOffset = widths.left;
+ *yOffset = widths.top;
return;
}