summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXWindowEvent.c
diff options
context:
space:
mode:
authorKevin Walzer <kw@codebykevin.com>2015-04-07 01:42:59 (GMT)
committerKevin Walzer <kw@codebykevin.com>2015-04-07 01:42:59 (GMT)
commit6540e0be10afe7208f8e370632256cfd262f5706 (patch)
treeb5bae340eed26502e2261af9d5f190b6893f1b2d /macosx/tkMacOSXWindowEvent.c
parentccdac05dbacc3b62fc27a65c11c8bd1188daddf4 (diff)
downloadtk-6540e0be10afe7208f8e370632256cfd262f5706.zip
tk-6540e0be10afe7208f8e370632256cfd262f5706.tar.gz
tk-6540e0be10afe7208f8e370632256cfd262f5706.tar.bz2
Backing out changes; unexpected issues with window resizing that require further investigation
Diffstat (limited to 'macosx/tkMacOSXWindowEvent.c')
-rw-r--r--macosx/tkMacOSXWindowEvent.c90
1 files changed, 41 insertions, 49 deletions
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index 35f9f1c..2e7c041 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -29,7 +29,7 @@
* Declaration of functions used only in this file
*/
-static int GenerateUpdates(HIShapeRef updateRgn,
+static int GenerateUpdates(HIMutableShapeRef updateRgn,
CGRect *updateBounds, TkWindow *winPtr);
static int GenerateActivateEvents(TkWindow *winPtr,
int activeFlag);
@@ -315,7 +315,7 @@ extern BOOL opaqueTag;
static int
GenerateUpdates(
- HIShapeRef updateRgn,
+ HIMutableShapeRef updateRgn,
CGRect *updateBounds,
TkWindow *winPtr)
{
@@ -782,8 +782,7 @@ Tk_MacOSXIsAppInFront(void)
@interface TKContentView(TKWindowEvent)
- (void) drawRect: (NSRect) rect;
-- (void) generateExposeEvents: (HIShapeRef) shape;
-- (void) generateExposeEvents: (HIShapeRef) shape childrenOnly: (int) childrenOnly;
+- (void) generateExposeEvents: (HIMutableShapeRef) shape;
- (void) viewDidEndLiveResize;
- (void) tkToolbarButton: (id) sender;
- (BOOL) isOpaque;
@@ -793,8 +792,6 @@ Tk_MacOSXIsAppInFront(void)
@end
@implementation TKContentView
-NSDate *_resizeStart;
-NSTimeInterval _resizeDuration;
@end
/*Restrict event processing to Expose events.*/
@@ -832,7 +829,7 @@ ExposeRestrictProc(
HIShapeUnionWithRect(drawShape, &r);
}
if (CFRunLoopGetMain() == CFRunLoopGetCurrent()) {
- [self generateExposeEvents:(HIShapeRef)drawShape];
+ [self generateExposeEvents:drawShape];
} else {
[self performSelectorOnMainThread:@selector(generateExposeEvents:)
withObject:(id)drawShape waitUntilDone:NO
@@ -847,33 +844,25 @@ ExposeRestrictProc(
-(void) setFrameSize: (NSSize)newsize
{
if ( [self inLiveResize] ) {
- NSWindow *w = [self window];
- TkWindow *winPtr = TkMacOSXGetTkWindow(w);
+ NSWindow *window = [self window];
+ TkWindow *winPtr = TkMacOSXGetTkWindow([self window]);
Tk_Window tkwin = (Tk_Window) winPtr;
unsigned int width = (unsigned int)newsize.width;
unsigned int height=(unsigned int)newsize.height;
- /* Resize the NSView */
+ /* Resize the Tk Window to the requested size.*/
+ TkGenWMConfigureEvent(tkwin, Tk_X(tkwin), Tk_Y(tkwin), width, height,
+ TK_SIZE_CHANGED | TK_MACOSX_HANDLE_EVENT_IMMEDIATELY);
+
+ /* Then resize the NSView to the actual window size*/
+ newsize.width = (CGFloat)Tk_Width(tkwin);
+ newsize.height = (CGFloat)Tk_Height(tkwin);
[super setFrameSize: newsize];
- /* Disable drawing until the window has been completely configured.*/
- TkMacOSXSetDrawingEnabled(winPtr, 0);
+ /* Process all pending events to update the window. */
+ while (Tcl_ServiceEvent(TCL_WINDOW_EVENTS)) {}
+ while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {}
- /* Generate and handle a ConfigureNotify event for the new size.*/
- TkGenWMConfigureEvent(tkwin, Tk_X(tkwin), Tk_Y(tkwin), width, height,
- TK_SIZE_CHANGED | TK_MACOSX_HANDLE_EVENT_IMMEDIATELY);
- while ( Tk_DoOneEvent(TK_X_EVENTS|TK_DONT_WAIT) ) {}
-
- /* Now that Tk has configured all subwindows we can create the clip regions. */
- TkMacOSXSetDrawingEnabled(winPtr, 1);
- TkMacOSXInvalClipRgns(tkwin);
- TkMacOSXUpdateClipRgn(winPtr);
-
- /* Finally, generate and process expose events to redraw the window. */
- HIRect bounds = NSRectToCGRect([self bounds]);
- HIShapeRef shape = HIShapeCreateWithRect(&bounds);
- [self generateExposeEvents: shape];
- while ( Tk_DoOneEvent(TK_ALL_EVENTS|TK_DONT_WAIT) ) {}
} else {
[super setFrameSize: newsize];
}
@@ -892,44 +881,46 @@ ExposeRestrictProc(
[self generateExposeEvents: shape];
}
-/* Core method of this class: generates expose events for redrawing.
- * Whereas drawRect is intended to be called only from the Appkit event
- * loop, this can be called from Tk. If the Tcl_ServiceMode is set to
- * TCL_SERVICE_ALL then the expose events will be immediately removed
- * from the Tcl event loop and processed. Typically, they should be queued,
- * however.
- */
-- (void) generateExposeEvents: (HIShapeRef) shape
-{
- [self generateExposeEvents:shape childrenOnly:0];
-}
-
-- (void) generateExposeEvents: (HIShapeRef) shape
- childrenOnly: (int) childrenOnly
+/*Core function of this class, generates expose events for redrawing.*/
+- (void) generateExposeEvents: (HIMutableShapeRef) shape
{
TkWindow *winPtr = TkMacOSXGetTkWindow([self window]);
unsigned long serial;
CGRect updateBounds;
- int updatesNeeded;
if (!winPtr) {
return;
}
- /* Generate Tk Expose events. */
HIShapeGetBounds(shape, &updateBounds);
- /* All of these events will share the same serial number. */
serial = LastKnownRequestProcessed(Tk_Display(winPtr));
- updatesNeeded = GenerateUpdates(shape, &updateBounds, winPtr);
-
- /* Process the Expose events if the service mode is TCL_SERVICE_ALL */
- if (updatesNeeded && Tcl_GetServiceMode() == TCL_SERVICE_ALL) {
- ClientData oldArg;
+ if (GenerateUpdates(shape, &updateBounds, winPtr) &&
+ ![[NSRunLoop currentRunLoop] currentMode] &&
+ Tcl_GetServiceMode() != TCL_SERVICE_NONE) {
+ /*
+ * Ensure there are no pending idle-time redraws that could
+ * prevent the just posted Expose events from generating
+ * new redraws.
+ */
+
+ while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {}
+
+ /*
+ * For smoother drawing, process Expose events and resulting
+ * redraws immediately instead of at idle time.
+ */
+
+ ClientData oldArg;
Tk_RestrictProc *oldProc = Tk_RestrictEvents(ExposeRestrictProc,
UINT2PTR(serial), &oldArg);
+
while (Tcl_ServiceEvent(TCL_WINDOW_EVENTS)) {}
+
Tk_RestrictEvents(oldProc, oldArg, &oldArg);
+
+ while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {}
}
+
}
/*
@@ -945,6 +936,7 @@ ExposeRestrictProc(
int x, y;
TkWindow *winPtr = TkMacOSXGetTkWindow([self window]);
Tk_Window tkwin = (Tk_Window) winPtr;
+
bzero(&event, sizeof(XVirtualEvent));
event.type = VirtualEvent;
event.serial = LastKnownRequestProcessed(Tk_Display(tkwin));