summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorculler <culler>2020-05-29 18:21:55 (GMT)
committerculler <culler>2020-05-29 18:21:55 (GMT)
commit9ba4c746ec344f1455e03c2f97ca0ae7c95d139f (patch)
treec2f3dab350bf3a9bd83fa139c24f9432b31eac06 /macosx
parentbd0d1fd4d2137bebd775874b705c061a7e13aa7f (diff)
downloadtk-9ba4c746ec344f1455e03c2f97ca0ae7c95d139f.zip
tk-9ba4c746ec344f1455e03c2f97ca0ae7c95d139f.tar.gz
tk-9ba4c746ec344f1455e03c2f97ca0ae7c95d139f.tar.bz2
Remove some unnecessary macOS conditional code by using internal stubs.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXInt.h2
-rw-r--r--macosx/tkMacOSXSubwindows.c8
-rw-r--r--macosx/tkMacOSXWindowEvent.c35
-rw-r--r--macosx/tkMacOSXWm.c34
4 files changed, 49 insertions, 30 deletions
diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h
index 9cb75d2..58761d5 100644
--- a/macosx/tkMacOSXInt.h
+++ b/macosx/tkMacOSXInt.h
@@ -200,8 +200,6 @@ MODULE_SCOPE void TkpClipDrawableToRect(Display *display, Drawable d, int x,
MODULE_SCOPE void TkpRetainRegion(TkRegion r);
MODULE_SCOPE void TkpReleaseRegion(TkRegion r);
MODULE_SCOPE void TkpShiftButton(NSButton *button, NSPoint delta);
-MODULE_SCOPE Bool TkpAppIsDrawing(void);
-MODULE_SCOPE void TkpDisplayWindow(Tk_Window tkwin);
MODULE_SCOPE Bool TkTestLogDisplay(void);
MODULE_SCOPE Bool TkMacOSXInDarkMode(Tk_Window tkwin);
diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c
index 5063fa3..6602564 100644
--- a/macosx/tkMacOSXSubwindows.c
+++ b/macosx/tkMacOSXSubwindows.c
@@ -698,16 +698,10 @@ XConfigureWindow(
if (value_mask & CWStackMode) {
NSView *view = TkMacOSXDrawableView(macWin);
- Rect bounds;
- NSRect r;
if (view) {
TkMacOSXInvalClipRgns((Tk_Window) winPtr->parentPtr);
- TkMacOSXWinBounds(winPtr, &bounds);
- r = NSMakeRect(bounds.left,
- [view bounds].size.height - bounds.bottom,
- bounds.right - bounds.left, bounds.bottom - bounds.top);
- [view setNeedsDisplayInRect:r];
+ TkpRedrawWidget((Tk_Window) winPtr);
}
}
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index cb4ffd1..76b2b04 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -382,26 +382,41 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
/*
*----------------------------------------------------------------------
*
- * TkpAppIsDrawing --
+ * TkpAppCanDraw --
*
* A widget display procedure can call this to determine whether it is
- * being run inside of the drawRect method. This is needed for some tests,
- * especially of the Text widget, which record data in a global Tcl
- * variable and assume that display procedures will be run in a
- * predictable sequence as Tcl idle tasks.
+ * being run inside of the drawRect method. If not, it may be desirable
+ * for the display procedure to simply clear the REDRAW_PENDING flag
+ * and return. The widget can be recorded in order to schedule a
+ * redraw, via and Expose event, from within drawRect.
+ *
+ * This is also needed for some tests, especially of the Text widget,
+ * which record data in a global Tcl variable and assume that display
+ * procedures will be run in a predictable sequence as Tcl idle tasks.
*
* Results:
- * True only while running the drawRect method of a TKContentView;
+ * True if called from the drawRect method of a TKContentView with
+ * tkwin NULL or pointing to a widget in the current focusView.
*
* Side effects:
- * None
+ * The tkwin parameter may be recorded to handle redrawing the widget
+ * later.
*
*----------------------------------------------------------------------
*/
-MODULE_SCOPE Bool
-TkpAppIsDrawing(void) {
- return [NSApp isDrawing];
+int
+TkpAppCanDraw(Tk_Window tkwin) {
+ if (![NSApp isDrawing]) {
+ return 0;
+ }
+ if (tkwin) {
+ TkWindow *winPtr = (TkWindow *)tkwin;
+ NSView *view = TkMacOSXDrawableView(winPtr->privatePtr);
+ return (view == [NSView focusView]);
+ } else {
+ return 1;
+ }
}
/*
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index 9117159..cab2b9a 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -6174,28 +6174,40 @@ TkMacOSXMakeRealWindowExist(
/*
*----------------------------------------------------------------------
*
- * TkpDisplayWindow --
+ * TkpRedrawWidget --
*
- * Mark the contentView of this window as needing display so the window
- * will be drawn by the window manager. If this is called within the
- * drawRect method, do nothing.
+ * Mark the bounding rectangle of this widget as needing display so the
+ * widget will be drawn by [NSView drawRect:]. If this is called within
+ * the drawRect method, do nothing.
*
* Results:
* None.
*
* Side effects:
- * The window's contentView is marked as needing display.
+ * The widget's bounding rectangle is marked as dirty.
*
*----------------------------------------------------------------------
*/
-MODULE_SCOPE void
-TkpDisplayWindow(Tk_Window tkwin) {
- if (![NSApp isDrawing]) {
- TkWindow *winPtr = (TkWindow *) tkwin;
- NSWindow *w = TkMacOSXDrawableWindow(winPtr->window);
+void
+TkpRedrawWidget(Tk_Window tkwin) {
+ TkWindow *winPtr = (TkWindow *) tkwin;
+ NSWindow *w;
+ Rect tkBounds;
+ NSRect bounds;
- [[w contentView] setNeedsDisplay: YES];
+ if ([NSApp isDrawing]) {
+ return;
+ }
+ w = TkMacOSXDrawableWindow(winPtr->window);
+ if (w) {
+ NSView *view = [w contentView];
+ TkMacOSXWinBounds(winPtr, &tkBounds);
+ bounds = NSMakeRect(tkBounds.left,
+ [view bounds].size.height - tkBounds.bottom,
+ tkBounds.right - tkBounds.left,
+ tkBounds.bottom - tkBounds.top);
+ [view setNeedsDisplayInRect:bounds];
}
}