summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXWindowEvent.c
diff options
context:
space:
mode:
authordas <das>2007-05-30 06:35:54 (GMT)
committerdas <das>2007-05-30 06:35:54 (GMT)
commite37ef892e06f50859941c35f85b7f07ce98d756e (patch)
treed698fa040408e94632aa7a89b0599efb12078dfb /macosx/tkMacOSXWindowEvent.c
parenteea3d8a589c007592691cf767336a06b0f600c50 (diff)
downloadtk-e37ef892e06f50859941c35f85b7f07ce98d756e.zip
tk-e37ef892e06f50859941c35f85b7f07ce98d756e.tar.gz
tk-e37ef892e06f50859941c35f85b7f07ce98d756e.tar.bz2
* macosx/tkMacOSXMenu.c (DrawMenuSeparator): use DrawingContext API.
* macosx/tkMacOSXWindowEvent.c (ClearPort): clip to updateRgn. * macosx/tkMacOSXDebug.c: factor out debug region flashing. * macosx/tkMacOSXDebug.h: * macosx/tkMacOSXDraw.c: * macosx/tkMacOSXSubwindows.c: * macosx/tkMacOSXWindowEvent.c: * macosx/tkMacOSXEvent.c: cleanup whitespace and formatting. * macosx/tkMacOSXFont.c: * macosx/tkMacOSXRegion.c: * macosx/tkMacOSXSubwindows.c: * macosx/tkMacOSXWindowEvent.c: * macosx/tkMacOSXWm.c: * macosx/tkMacOSXXStubs.c: * xlib/xgc.c: * macosx/Wish.xcodeproj/project.pbxproj: delete references to removed * macosx/Wish.xcodeproj/default.pbxuser: ttk files.
Diffstat (limited to 'macosx/tkMacOSXWindowEvent.c')
-rw-r--r--macosx/tkMacOSXWindowEvent.c102
1 files changed, 48 insertions, 54 deletions
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index 236bfdc..2f7ddd8 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.22 2007/05/09 12:55:16 das Exp $
+ * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.23 2007/05/30 06:35:55 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -76,16 +76,15 @@ static int tkMacOSXAppInFront = true; /* Boolean variable for determining if
* we are the frontmost app. Only set
* in TkMacOSXProcessApplicationEvent
*/
-static RgnHandle gDamageRgn = NULL;
-
/*
* Declaration of functions used only in this file
*/
-static int GenerateUpdateEvent( Window window);
-static int GenerateUpdates( RgnHandle updateRgn, TkWindow *winPtr);
-static int GenerateActivateEvents( Window window, int activeFlag);
-static void ClearPort(CGrafPtr port);
+static int GenerateUpdateEvent(Window window);
+static int GenerateUpdates(RgnHandle updateRgn, Rect *updateBounds,
+ TkWindow *winPtr);
+static int GenerateActivateEvents(Window window, int activeFlag);
+static void ClearPort(CGrafPtr port, RgnHandle updateRgn);
/*
@@ -411,7 +410,7 @@ TkMacOSXProcessWindowEvent(
CGrafPtr port;
GetPort(&port);
- ClearPort(port);
+ ClearPort(port, NULL);
}
break;
}
@@ -438,11 +437,12 @@ TkMacOSXProcessWindowEvent(
static int
GenerateUpdateEvent(Window window)
{
- CGrafPtr destPort;
- WindowRef macWindow;
- TkDisplay * dispPtr;
- TkWindow * winPtr;
- int result = 0;
+ CGrafPtr destPort;
+ WindowRef macWindow;
+ TkDisplay *dispPtr;
+ TkWindow *winPtr;
+ int result = 0;
+ Rect updateBounds;
dispPtr = TkGetDisplayList();
winPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, window);
@@ -450,31 +450,23 @@ GenerateUpdateEvent(Window window)
if (winPtr ==NULL ){
return result;
}
- if (gDamageRgn == NULL) {
- gDamageRgn = NewRgn();
- }
TkMacOSXCheckTmpRgnEmpty(1);
destPort = TkMacOSXGetDrawablePort(window);
macWindow = GetWindowFromPort(destPort);
GetWindowRegion(macWindow, kWindowUpdateRgn, tkMacOSXtmpRgn1);
QDGlobalToLocalRegion(destPort, tkMacOSXtmpRgn1);
SectRegionWithPortVisibleRegion(destPort, tkMacOSXtmpRgn1);
+ GetRegionBounds(tkMacOSXtmpRgn1, &updateBounds);
#ifdef TK_MAC_DEBUG_CLIP_REGIONS
- TkMacOSXInitNamedDebugSymbol(HIToolbox, int, QDDebugFlashRegion,
- CGrafPtr port, RgnHandle region);
- if (QDDebugFlashRegion) {
- /* Carbon-internal region flashing SPI (c.f. Technote 2124) */
- QDDebugFlashRegion(destPort, tkMacOSXtmpRgn1);
- }
+ TkMacOSXDebugFlashRegion(destPort, tkMacOSXtmpRgn1);
#endif /* TK_MAC_DEBUG_CLIP_REGIONS */
BeginUpdate(macWindow);
if (winPtr->wmInfoPtr->flags & WM_TRANSPARENT) {
- ClearPort(destPort);
+ ClearPort(destPort, tkMacOSXtmpRgn1);
}
- result = GenerateUpdates(tkMacOSXtmpRgn1, winPtr);
+ result = GenerateUpdates(tkMacOSXtmpRgn1, &updateBounds, winPtr);
EndUpdate(macWindow);
SetEmptyRgn(tkMacOSXtmpRgn1);
- SetEmptyRgn(gDamageRgn);
return result;
}
@@ -500,51 +492,48 @@ GenerateUpdateEvent(Window window)
static int
GenerateUpdates(
RgnHandle updateRgn,
+ Rect *updateBounds,
TkWindow *winPtr)
{
TkWindow *childPtr;
XEvent event;
- Rect bounds, updateBounds, damageBounds;
+ Rect bounds, damageBounds;
+ static RgnHandle damageRgn = NULL;
TkMacOSXWinBounds(winPtr, &bounds);
- GetRegionBounds(updateRgn,&updateBounds);
-
- if (bounds.top > updateBounds.bottom ||
- updateBounds.top > bounds.bottom ||
- bounds.left > updateBounds.right ||
- updateBounds.left > bounds.right ||
- !RectInRgn(&bounds, updateRgn)) {
+ if (bounds.top > updateBounds->bottom ||
+ updateBounds->top > bounds.bottom ||
+ bounds.left > updateBounds->right ||
+ updateBounds->left > bounds.right) {
return 0;
}
if (!RectInRgn(&bounds, updateRgn)) {
return 0;
}
+ /*
+ * Compute the bounding box of the area that the damage occured in.
+ */
+
+ if (damageRgn == NULL) {
+ damageRgn = NewRgn();
+ }
+ RectRgn(damageRgn, &bounds);
+ SectRgn(damageRgn, updateRgn, damageRgn);
+ OffsetRgn(damageRgn, -bounds.left, -bounds.top);
+ GetRegionBounds(damageRgn, &damageBounds);
+ SetEmptyRgn(damageRgn);
+
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;
-
- /*
- * Compute the bounding box of the area that the damage occured in.
- */
-
- /*
- * CopyRgn(TkMacOSXVisableClipRgn(winPtr), rgn);
- * TODO: this call doesn't work doing resizes!!!
- */
- RectRgn(gDamageRgn, &bounds);
- SectRgn(gDamageRgn, updateRgn, gDamageRgn);
- OffsetRgn(gDamageRgn, -bounds.left, -bounds.top);
- GetRegionBounds(gDamageRgn,&damageBounds);
event.xexpose.x = damageBounds.left;
event.xexpose.y = damageBounds.top;
event.xexpose.width = damageBounds.right-damageBounds.left;
event.xexpose.height = damageBounds.bottom-damageBounds.top;
event.xexpose.count = 0;
-
Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
/*
@@ -552,12 +541,11 @@ GenerateUpdates(
*/
for (childPtr = winPtr->childList; childPtr != NULL;
- childPtr = childPtr->nextPtr) {
+ childPtr = childPtr->nextPtr) {
if (!Tk_IsMapped(childPtr) || Tk_IsTopLevel(childPtr)) {
continue;
}
-
- GenerateUpdates(updateRgn, childPtr);
+ GenerateUpdates(updateRgn, updateBounds, childPtr);
}
/*
@@ -567,7 +555,7 @@ GenerateUpdates(
if (Tk_IsContainer(winPtr)) {
childPtr = TkpGetOtherWindow(winPtr);
if (childPtr != NULL && Tk_IsMapped(childPtr)) {
- GenerateUpdates(updateRgn, childPtr);
+ GenerateUpdates(updateRgn, updateBounds, childPtr);
}
/*
@@ -922,7 +910,7 @@ TkWmProtocolEventProc(
*/
int
-Tk_MacOSXIsAppInFront (void)
+Tk_MacOSXIsAppInFront(void)
{
return tkMacOSXAppInFront;
}
@@ -943,13 +931,19 @@ Tk_MacOSXIsAppInFront (void)
*----------------------------------------------------------------------
*/
static void
-ClearPort(CGrafPtr port) {
+ClearPort(
+ CGrafPtr port,
+ RgnHandle updateRgn)
+{
CGContextRef context;
Rect bounds;
CGRect rect;
GetPortBounds(port, &bounds);
QDBeginCGContext(port, &context);
+ if (updateRgn) {
+ ClipCGContextToRegion(context, &bounds, updateRgn);
+ }
rect = CGRectMake(0, 0, bounds.right, bounds.bottom);
CGContextClearRect(context, rect);
QDEndCGContext(port, &context);