summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorculler <culler>2019-10-21 00:02:08 (GMT)
committerculler <culler>2019-10-21 00:02:08 (GMT)
commite5ec9901434a09547d80a2fa1f351dedcf9e7f1b (patch)
treea23379dcda195c1b444282b3e1f9d137b7b81f14 /macosx
parentb85f408680332d1174c512d285fb74c09a6d9833 (diff)
downloadtk-e5ec9901434a09547d80a2fa1f351dedcf9e7f1b.zip
tk-e5ec9901434a09547d80a2fa1f351dedcf9e7f1b.tar.gz
tk-e5ec9901434a09547d80a2fa1f351dedcf9e7f1b.tar.bz2
Apply macOS patch for [aea00be1] by Christopher Chavez. Prevents glitches when the screen resolution is changed.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXMenu.c2
-rw-r--r--macosx/tkMacOSXMouseEvent.c12
-rw-r--r--macosx/tkMacOSXPrivate.h4
-rw-r--r--macosx/tkMacOSXSubwindows.c4
-rw-r--r--macosx/tkMacOSXWindowEvent.c2
-rw-r--r--macosx/tkMacOSXWm.c8
-rw-r--r--macosx/tkMacOSXXStubs.c70
7 files changed, 78 insertions, 24 deletions
diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c
index 7d2a073..735f7d2 100644
--- a/macosx/tkMacOSXMenu.c
+++ b/macosx/tkMacOSXMenu.c
@@ -821,7 +821,7 @@ TkpPostMenu(
NSInteger itemIndex = index;
NSInteger numItems = [menu numberOfItems];
NSMenuItem *item = nil;
- NSPoint location = NSMakePoint(x, tkMacOSXZeroScreenHeight - y);
+ NSPoint location = NSMakePoint(x, TkMacOSXZeroScreenHeight() - y);
inPostMenu = 1;
result = TkPreprocessMenu(menuPtr);
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index 84b5fa1..56c6431 100644
--- a/macosx/tkMacOSXMouseEvent.c
+++ b/macosx/tkMacOSXMouseEvent.c
@@ -106,7 +106,7 @@ enum {
}
}
local.y = [eventWindow frame].size.height - local.y;
- global.y = tkMacOSXZeroScreenHeight - global.y;
+ global.y = TkMacOSXZeroScreenHeight() - global.y;
} else {
/*
@@ -126,7 +126,7 @@ enum {
}
local = [eventWindow tkConvertPointFromScreen: global];
local.y = [eventWindow frame].size.height - local.y;
- global.y = tkMacOSXZeroScreenHeight - global.y;
+ global.y = TkMacOSXZeroScreenHeight() - global.y;
}
/*
@@ -464,7 +464,7 @@ XQueryPointer(
}
if (getGlobal) {
*root_x_return = global.x;
- *root_y_return = tkMacOSXZeroScreenHeight - global.y;
+ *root_y_return = TkMacOSXZeroScreenHeight() - global.y;
}
}
if (mask_return) {
@@ -548,7 +548,7 @@ TkGenerateButtonEvent(
med.local = med.global;
if (win) {
- NSPoint local = NSMakePoint(x, tkMacOSXZeroScreenHeight - y);
+ NSPoint local = NSMakePoint(x, TkMacOSXZeroScreenHeight() - y);
local = [win tkConvertPointFromScreen:local];
local.y = [win frame].size.height - local.y;
@@ -557,7 +557,7 @@ TkGenerateButtonEvent(
local.y -= macWin->winPtr->wmInfoPtr->yInParent;
}
med.local.h = local.x;
- med.local.v = tkMacOSXZeroScreenHeight - local.y;
+ med.local.v = TkMacOSXZeroScreenHeight() - local.y;
}
return GenerateButtonEvent(&med);
@@ -641,7 +641,7 @@ TkpWarpPointer(
wNum = 0;
pt.x = loc.x = dispPtr->warpX;
pt.y = dispPtr->warpY;
- loc.y = tkMacOSXZeroScreenHeight - pt.y;
+ loc.y = TkMacOSXZeroScreenHeight() - pt.y;
}
/*
diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h
index 511c9f2..8335095 100644
--- a/macosx/tkMacOSXPrivate.h
+++ b/macosx/tkMacOSXPrivate.h
@@ -137,8 +137,6 @@ typedef struct TkMacOSXDrawingContext {
* Variables internal to TkAqua.
*/
-MODULE_SCOPE CGFloat tkMacOSXZeroScreenHeight;
-MODULE_SCOPE CGFloat tkMacOSXZeroScreenTop;
MODULE_SCOPE long tkMacOSXMacOSXVersion;
/*
@@ -177,6 +175,8 @@ MODULE_SCOPE OSStatus TkMacOSHIShapeUnion(HIShapeRef inShape1,
MODULE_SCOPE void * TkMacOSXGetNamedSymbol(const char *module,
const char *symbol);
MODULE_SCOPE void TkMacOSXDisplayChanged(Display *display);
+MODULE_SCOPE CGFloat TkMacOSXZeroScreenHeight();
+MODULE_SCOPE CGFloat TkMacOSXZeroScreenTop();
MODULE_SCOPE int TkMacOSXUseAntialiasedText(Tcl_Interp *interp,
int enable);
MODULE_SCOPE int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable,
diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c
index e851701..5063fa3 100644
--- a/macosx/tkMacOSXSubwindows.c
+++ b/macosx/tkMacOSXSubwindows.c
@@ -426,7 +426,7 @@ XMoveResizeWindow(
CGFloat XOff = (CGFloat) macWin->winPtr->wmInfoPtr->xInParent;
CGFloat YOff = (CGFloat) macWin->winPtr->wmInfoPtr->yInParent;
NSRect r = NSMakeRect(
- X + XOff, tkMacOSXZeroScreenHeight - Y - YOff - Height,
+ X + XOff, TkMacOSXZeroScreenHeight() - Y - YOff - Height,
Width, Height);
[w setFrame:[w frameRectForContentRect:r] display:YES];
@@ -467,7 +467,7 @@ XMoveWindow(
if (w) {
[w setFrameTopLeftPoint: NSMakePoint(
- x, tkMacOSXZeroScreenHeight - y)];
+ x, TkMacOSXZeroScreenHeight() - y)];
}
} else {
MoveResizeWindow(macWin);
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index b8055e8..833df8c 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -78,7 +78,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
int x, y, width = -1, height = -1, flags = 0;
x = bounds.origin.x;
- y = tkMacOSXZeroScreenHeight - (bounds.origin.y + bounds.size.height);
+ y = TkMacOSXZeroScreenHeight() - (bounds.origin.y + bounds.size.height);
if (winPtr->changes.x != x || winPtr->changes.y != y) {
flags |= TK_LOCATION_CHANGED;
} else {
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index a1adcd0..c2b67f6 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -607,7 +607,7 @@ FrontWindowAtPoint(
int x,
int y)
{
- NSPoint p = NSMakePoint(x, tkMacOSXZeroScreenHeight - y);
+ NSPoint p = NSMakePoint(x, TkMacOSXZeroScreenHeight() - y);
NSArray *windows = [NSApp orderedWindows];
TkWindow *winPtr = NULL;
@@ -5230,7 +5230,7 @@ InitialWindowBounds(
cascadePoint = [macWindow cascadeTopLeftFromPoint:cascadePoint];
frame = [macWindow frame];
wmPtr->x = frame.origin.x;
- wmPtr->y = tkMacOSXZeroScreenHeight - (frame.origin.y +
+ wmPtr->y = TkMacOSXZeroScreenHeight() - (frame.origin.y +
frame.size.height);
}
return NSMakeRect(wmPtr->x, wmPtr->y, winPtr->changes.width,
@@ -6102,7 +6102,7 @@ TkMacOSXMakeRealWindowExist(
NSRect structureRect = [winClass frameRectForContentRect:NSZeroRect
styleMask:styleMask];
NSRect contentRect = NSMakeRect(5 - structureRect.origin.x,
- tkMacOSXZeroScreenHeight - (tkMacOSXZeroScreenTop + 5 +
+ TkMacOSXZeroScreenHeight() - (TkMacOSXZeroScreenTop() + 5 +
structureRect.origin.y + structureRect.size.height + 200), 200, 200);
NSWindow *window = [[winClass alloc] initWithContentRect:contentRect
styleMask:styleMask backing:NSBackingStoreBuffered defer:YES];
@@ -6134,7 +6134,7 @@ TkMacOSXMakeRealWindowExist(
NSRect geometry = InitialWindowBounds(winPtr, window);
geometry.size.width += structureRect.size.width;
geometry.size.height += structureRect.size.height;
- geometry.origin.y = tkMacOSXZeroScreenHeight - (geometry.origin.y +
+ geometry.origin.y = TkMacOSXZeroScreenHeight() - (geometry.origin.y +
geometry.size.height);
[window setFrame:geometry display:YES];
TkMacOSXRegisterOffScreenWindow((Window) macWin, window);
diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c
index d60c012..6aeec36 100644
--- a/macosx/tkMacOSXXStubs.c
+++ b/macosx/tkMacOSXXStubs.c
@@ -33,9 +33,6 @@
#define ROOT_ID 10
-CGFloat tkMacOSXZeroScreenHeight = 0;
-CGFloat tkMacOSXZeroScreenTop = 0;
-
/*
* Declarations of static variables used in this file.
*/
@@ -90,13 +87,9 @@ TkMacOSXDisplayChanged(
nsScreens = [NSScreen screens];
if (nsScreens && [nsScreens count]) {
NSScreen *s = [nsScreens objectAtIndex:0];
- NSRect bounds = [s frame], visible = [s visibleFrame];
+ NSRect bounds = [s frame];
NSRect maxBounds = NSZeroRect;
- tkMacOSXZeroScreenHeight = bounds.size.height;
- tkMacOSXZeroScreenTop = tkMacOSXZeroScreenHeight -
- (visible.origin.y + visible.size.height);
-
screen->root_depth = NSBitsPerPixelFromDepth([s depth]);
screen->width = bounds.size.width;
screen->height = bounds.size.height;
@@ -113,6 +106,67 @@ TkMacOSXDisplayChanged(
/*
*----------------------------------------------------------------------
*
+ * TkMacOSXZeroScreenHeight --
+ *
+ * Replacement for the tkMacOSXZeroScreenHeight variable to avoid
+ * caching values from NSScreen (fixes bug aea00be199).
+ *
+ * Results:
+ * Returns the height of screen 0 (the screen assigned the menu bar
+ * in System Preferences), or 0.0 if getting [NSScreen screens] fails.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+CGFloat
+TkMacOSXZeroScreenHeight()
+{
+ NSArray *nsScreens = [NSScreen screens];
+ if (nsScreens && [nsScreens count]) {
+ NSScreen *s = [nsScreens objectAtIndex:0];
+ NSRect bounds = [s frame];
+ return bounds.size.height;
+ }
+ return 0.0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkMacOSXZeroScreenTop --
+ *
+ * Replacement for the tkMacOSXZeroScreenTop variable to avoid
+ * caching values from visibleFrame.
+ *
+ * Results:
+ * Returns how far below the top of screen 0 to draw
+ * (i.e. the height of the menu bar if it is always shown),
+ * or 0.0 if getting [NSScreen screens] fails.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+CGFloat
+TkMacOSXZeroScreenTop()
+{
+ NSArray *nsScreens = [NSScreen screens];
+ if (nsScreens && [nsScreens count]) {
+ NSScreen *s = [nsScreens objectAtIndex:0];
+ NSRect bounds = [s frame], visible = [s visibleFrame];
+ return bounds.size.height - (visible.origin.y + visible.size.height);
+ }
+ return 0.0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkpOpenDisplay --
*
* Create the Display structure and fill it with device specific