From 3a2ae662064addb4c2bc613d51e812240bda183c Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Fri, 4 Mar 2011 16:36:47 +0000 Subject: [PATCH] fixing a CG error during construction on 10.6, resizing the client area so that the content doesn't extend over the shape's boundingbox at the right and the bottom git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@67125 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/toplevel.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp index 5d317ce8dc..074c06d04b 100644 --- a/src/mac/carbon/toplevel.cpp +++ b/src/mac/carbon/toplevel.cpp @@ -1809,13 +1809,19 @@ bool wxTopLevelWindowMac::SetShape(const wxRegion& region) static void wxShapedMacWindowGetPos(WindowRef window, Rect* inRect) { +#if 1 + // under 10.6 we are getting errors during construction otherwise + ::GetWindowBounds(window, kWindowGlobalPortRgn, inRect); +#else GetWindowPortBounds(window, inRect); + Point pt = { inRect->top ,inRect->left }; wxMacLocalToGlobal( window, &pt ) ; inRect->bottom += pt.v - inRect->top; inRect->right += pt.h - inRect->left; inRect->top = pt.v; inRect->left = pt.h; +#endif } static SInt32 wxShapedMacWindowGetFeatures(WindowRef window, SInt32 param) @@ -1849,9 +1855,26 @@ static void wxShapedMacWindowContentRegion(WindowRef window, RgnHandle rgn) wxTopLevelWindowMac* win = wxFindWinFromMacWindow(window); if (win) { - Rect r ; - wxShapedMacWindowGetPos( window, &r ) ; - RectRgn( rgn , &r ) ; + Rect windowRect ; + wxShapedMacWindowGetPos( window, &windowRect ) ; +#if 1 + // the port rectangle of the window may be larger than the window was set, + // therefore we clip at the right and bottom of the shape + RgnHandle cachedRegion = (RgnHandle) GetWRefCon(window); + + if (cachedRegion) + { + CopyRgn(cachedRegion, rgn); // make a copy of our cached region + OffsetRgn(rgn, windowRect.left, windowRect.top); // position it over window + Rect r; + GetRegionBounds(rgn,&r); + r.left = windowRect.left; + r.top = windowRect.top; + RectRgn( rgn , &r ) ; + } +#else + RectRgn( rgn , &windowRect ) ; +#endif } }