summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXWindowEvent.c
diff options
context:
space:
mode:
authordas <das>2007-11-09 06:26:53 (GMT)
committerdas <das>2007-11-09 06:26:53 (GMT)
commitb0e3f55fe56f3f1fa4ad3cf7c63dddcfff5a9846 (patch)
tree40938979466c8caac1c03c907753bc43175304bd /macosx/tkMacOSXWindowEvent.c
parent455d9dc4b8b50ed064729851295535018eb99449 (diff)
downloadtk-b0e3f55fe56f3f1fa4ad3cf7c63dddcfff5a9846.zip
tk-b0e3f55fe56f3f1fa4ad3cf7c63dddcfff5a9846.tar.gz
tk-b0e3f55fe56f3f1fa4ad3cf7c63dddcfff5a9846.tar.bz2
Backport from HEAD of Aqua changes from 2007-10-12 to 2007-11-09
Diffstat (limited to 'macosx/tkMacOSXWindowEvent.c')
-rw-r--r--macosx/tkMacOSXWindowEvent.c125
1 files changed, 76 insertions, 49 deletions
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index f909f32..7ad33c8 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -54,7 +54,7 @@
* software in accordance with the terms specified in this
* license.
*
- * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.3.2.25 2007/07/09 08:32:12 das Exp $
+ * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.3.2.26 2007/11/09 06:26:56 das Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -73,10 +73,10 @@
*/
static int GenerateUpdateEvent(Window window);
-static int GenerateUpdates(RgnHandle updateRgn, Rect *updateBounds,
+static int GenerateUpdates(HIMutableShapeRef updateRgn, CGRect *updateBounds,
TkWindow *winPtr);
static int GenerateActivateEvents(Window window, int activeFlag);
-static void ClearPort(CGrafPtr port, RgnHandle updateRgn);
+static void ClearPort(CGrafPtr port, HIShapeRef updateRgn);
/*
@@ -232,7 +232,7 @@ TkMacOSXProcessWindowEvent(
case kEventWindowActivated:
case kEventWindowDeactivated:
case kEventWindowUpdate:
- case kEventWindowExpanded:
+ case kEventWindowExpanding:
case kEventWindowBoundsChanged:
case kEventWindowDragStarted:
case kEventWindowDragCompleted:
@@ -275,10 +275,20 @@ TkMacOSXProcessWindowEvent(
statusPtr->stopProcessing = 1;
}
break;
- case kEventWindowExpanded:
+ case kEventWindowExpanding:
if (winPtr) {
- TkpWmSetState(winPtr, TkMacOSXIsWindowZoomed(winPtr) ?
- ZoomState : NormalState);
+ winPtr->wmInfoPtr->hints.initial_state =
+ TkMacOSXIsWindowZoomed(winPtr) ? ZoomState :
+ NormalState;
+ Tk_MapWindow((Tk_Window) winPtr);
+ /*
+ * Need to process all Tk events generated by Tk_MapWindow()
+ * before returning to ensure all children are mapped, as
+ * otherwise the Activate event that follows Expanding would
+ * not be processed by any unmapped children.
+ */
+ while (Tcl_ServiceEvent(TCL_WINDOW_EVENTS)) {};
+ while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {};
}
break;
case kEventWindowBoundsChanged:
@@ -430,12 +440,14 @@ TkMacOSXProcessWindowEvent(
static int
GenerateUpdateEvent(Window window)
{
- CGrafPtr destPort;
WindowRef macWindow;
TkDisplay *dispPtr;
TkWindow *winPtr;
int result = 0;
- Rect updateBounds, bounds;
+ CGRect updateBounds;
+ HIShapeRef rgn;
+ HIMutableShapeRef updateRgn;
+ int dx, dy;
dispPtr = TkGetDisplayList();
winPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, window);
@@ -443,24 +455,37 @@ GenerateUpdateEvent(Window window)
if (winPtr ==NULL ){
return result;
}
- TkMacOSXCheckTmpQdRgnEmpty();
- destPort = TkMacOSXGetDrawablePort(window);
- macWindow = GetWindowFromPort(destPort);
- ChkErr(GetWindowRegion, macWindow, kWindowUpdateRgn, tkMacOSXtmpQdRgn);
- ChkErr(GetWindowBounds, macWindow, kWindowContentRgn, &bounds);
- OffsetRgn(tkMacOSXtmpQdRgn, -bounds.left, -bounds.top);
- SectRegionWithPortVisibleRegion(destPort, tkMacOSXtmpQdRgn);
- GetRegionBounds(tkMacOSXtmpQdRgn, &updateBounds);
+ macWindow = TkMacOSXDrawableWindow(window);
+ TK_IF_MAC_OS_X_API (5, HIWindowCopyShape,
+ ChkErr(HIWindowCopyShape, macWindow, kWindowUpdateRgn,
+ kHICoordSpaceWindow, &rgn);
+ dx = -winPtr->wmInfoPtr->xInParent;
+ dy = -winPtr->wmInfoPtr->yInParent;
+ ) TK_ELSE_MAC_OS_X (5,
+ Rect bounds;
+
+ TkMacOSXCheckTmpQdRgnEmpty();
+ ChkErr(GetWindowRegion, macWindow, kWindowUpdateRgn, tkMacOSXtmpQdRgn);
+ rgn = HIShapeCreateWithQDRgn(tkMacOSXtmpQdRgn);
+ SetEmptyRgn(tkMacOSXtmpQdRgn);
+ ChkErr(GetWindowBounds, macWindow, kWindowContentRgn, &bounds);
+ dx = -bounds.left;
+ dy = -bounds.top;
+ ) TK_ENDIF
+ updateRgn = HIShapeCreateMutableCopy(rgn);
+ CFRelease(rgn);
+ ChkErr(HIShapeOffset, updateRgn, dx, dy);
+ HIShapeGetBounds(updateRgn, &updateBounds);
#ifdef TK_MAC_DEBUG_CLIP_REGIONS
- TkMacOSXDebugFlashRegion(window, tkMacOSXtmpQdRgn);
+ TkMacOSXDebugFlashRegion(window, updateRgn);
#endif /* TK_MAC_DEBUG_CLIP_REGIONS */
BeginUpdate(macWindow);
if (winPtr->wmInfoPtr->flags & WM_TRANSPARENT) {
- ClearPort(destPort, tkMacOSXtmpQdRgn);
+ ClearPort(TkMacOSXGetDrawablePort(window), updateRgn);
}
- result = GenerateUpdates(tkMacOSXtmpQdRgn, &updateBounds, winPtr);
+ result = GenerateUpdates(updateRgn, &updateBounds, winPtr);
EndUpdate(macWindow);
- SetEmptyRgn(tkMacOSXtmpQdRgn);
+ CFRelease(updateRgn);
if (result) {
/*
* Ensure there are no pending idle-time redraws that could prevent
@@ -493,50 +518,51 @@ GenerateUpdateEvent(Window window)
static int
GenerateUpdates(
- RgnHandle updateRgn,
- Rect *updateBounds,
+ HIMutableShapeRef updateRgn,
+ CGRect *updateBounds,
TkWindow *winPtr)
{
TkWindow *childPtr;
XEvent event;
- Rect bounds, damageBounds;
- static RgnHandle damageRgn = NULL;
-
- TkMacOSXWinBounds(winPtr, &bounds);
- if (bounds.top > updateBounds->bottom ||
- updateBounds->top > bounds.bottom ||
- bounds.left > updateBounds->right ||
- updateBounds->left > bounds.right) {
- return 0;
- }
- if (!RectInRgn(&bounds, updateRgn)) {
+ CGRect bounds, damageBounds;
+ HIShapeRef boundsRgn, damageRgn;
+
+ TkMacOSXWinCGBounds(winPtr, &bounds);
+ if (!CGRectIntersectsRect(bounds, *updateBounds)) {
return 0;
}
+ TK_IF_MAC_OS_X_API (4, HIShapeIntersectsRect,
+ if (!HIShapeIntersectsRect(updateRgn, &bounds)) {
+ return 0;
+ }
+ ) TK_ENDIF
/*
* Compute the bounding box of the area that the damage occured in.
*/
- if (damageRgn == NULL) {
- damageRgn = NewRgn();
+ boundsRgn = HIShapeCreateWithRect(&bounds);
+ damageRgn = HIShapeCreateIntersection(updateRgn, boundsRgn);
+ if (HIShapeIsEmpty(damageRgn)) {
+ CFRelease(damageRgn);
+ CFRelease(boundsRgn);
+ return 0;
}
- RectRgn(damageRgn, &bounds);
- SectRgn(damageRgn, updateRgn, damageRgn);
- GetRegionBounds(damageRgn, &damageBounds);
- RectRgn(damageRgn, &bounds);
- UnionRgn(damageRgn, updateRgn, updateRgn);
- GetRegionBounds(updateRgn, updateBounds);
- SetEmptyRgn(damageRgn);
+ HIShapeGetBounds(damageRgn, &damageBounds);
+ ChkErr(TkMacOSHIShapeUnion, boundsRgn, updateRgn, updateRgn);
+ HIShapeGetBounds(updateRgn, updateBounds);
+ CFRelease(damageRgn);
+ CFRelease(boundsRgn);
event.xany.serial = Tk_Display(winPtr)->request;
event.xany.send_event = false;
event.xany.window = Tk_WindowId(winPtr);
event.xany.display = Tk_Display(winPtr);
event.type = Expose;
- event.xexpose.x = damageBounds.left - bounds.left;
- event.xexpose.y = damageBounds.top - bounds.top;
- event.xexpose.width = damageBounds.right - damageBounds.left;
- event.xexpose.height = damageBounds.bottom - damageBounds.top;
+ event.xexpose.x = damageBounds.origin.x - bounds.origin.x;
+ event.xexpose.y = damageBounds.origin.y - bounds.origin.y;
+ event.xexpose.width = damageBounds.size.width;
+ event.xexpose.height = damageBounds.size.height;
event.xexpose.count = 0;
Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
@@ -945,7 +971,7 @@ Tk_MacOSXIsAppInFront(void)
static void
ClearPort(
CGrafPtr port,
- RgnHandle updateRgn)
+ HIShapeRef updateRgn)
{
CGContextRef context;
Rect bounds;
@@ -957,7 +983,8 @@ ClearPort(
CGContextConcatCTM(context, CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0,
bounds.bottom - bounds.top));
if (updateRgn) {
- ClipCGContextToRegion(context, &bounds, updateRgn);
+ ChkErr(HIShapeReplacePathInCGContext, updateRgn, context);
+ CGContextEOClip(context);
}
rect = CGRectMake(0, 0, bounds.right, bounds.bottom);
CGContextClearRect(context, rect);