diff options
author | das <das> | 2006-04-28 06:02:57 (GMT) |
---|---|---|
committer | das <das> | 2006-04-28 06:02:57 (GMT) |
commit | a5b92093185c667fa3159a2ee58b5682290af6b1 (patch) | |
tree | 5b3992c68a12ca95ff81a211d111286d7c82c2e0 /macosx/tkMacOSXWm.c | |
parent | 29fd0ac98c568926da12b00ea63d88c6d98985f7 (diff) | |
download | tk-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/tkMacOSXWm.c')
-rw-r--r-- | macosx/tkMacOSXWm.c | 72 |
1 files changed, 19 insertions, 53 deletions
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 19376f3..f9cd855 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.7.2.24 2006/04/22 04:12:25 das Exp $ + * RCS: @(#) $Id: tkMacOSXWm.c,v 1.7.2.25 2006/04/28 06:03:00 das Exp $ */ #include "tkMacOSXInt.h" @@ -309,14 +310,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. @@ -324,18 +320,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. @@ -4367,11 +4357,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. @@ -4383,19 +4373,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; } /* @@ -4634,7 +4621,7 @@ TkMacOSXGetXWindow( *---------------------------------------------------------------------- */ -int +MODULE_SCOPE int TkMacOSXIsWindowZoomed( TkWindow *winPtr) { @@ -5453,7 +5440,7 @@ TkpIsWindowFloating(WindowRef wRef) *---------------------------------------------------------------------- */ -WindowClass +MODULE_SCOPE WindowClass TkMacOSXWindowClass(TkWindow *winPtr) { WindowRef wRef; @@ -5495,32 +5482,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; } |