diff options
author | das <das> | 2006-04-28 06:02:47 (GMT) |
---|---|---|
committer | das <das> | 2006-04-28 06:02:47 (GMT) |
commit | 37574f162488e058bcba4d8378c94a18716b7af1 (patch) | |
tree | dbf40a74ecf59b8ccec931d28b36eb0dfdafb1a1 /macosx/tkMacOSXWm.c | |
parent | c5df89036d559ebb962065ca285fa46f6828db56 (diff) | |
download | tk-37574f162488e058bcba4d8378c94a18716b7af1.zip tk-37574f162488e058bcba4d8378c94a18716b7af1.tar.gz tk-37574f162488e058bcba4d8378c94a18716b7af1.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:
Diffstat (limited to 'macosx/tkMacOSXWm.c')
-rw-r--r-- | macosx/tkMacOSXWm.c | 69 |
1 files changed, 17 insertions, 52 deletions
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; } |