[gtk/gtk-3-24] Refine GdkQuartzNSWindow convertPointToScreen:
- From: John Ralls <jralls src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk-3-24] Refine GdkQuartzNSWindow convertPointToScreen:
- Date: Sun, 16 Dec 2018 01:47:14 +0000 (UTC)
commit aeec73f53f6df7683e3fddae4563787a3a0457dc
Author: John Ralls <jralls ceridwen us>
Date: Fri Dec 14 16:10:35 2018 -0800
Refine GdkQuartzNSWindow convertPointToScreen:
and convertPointFromScreen:, making them handle all MacOS versions
so that all of the if-deffing happens in the function definitions.
This happens to fix issue 1518 because it turns out that contrary
to the annotation in the 10.14 nNSWindow.h, convertPointToScreen and
convertPointFromScreen originate in 10.14, not 10.12.
Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1518
gdk/quartz/GdkQuartzNSWindow.c | 75 ++++++++++++++++++++----------------------
gdk/quartz/GdkQuartzNSWindow.h | 2 --
gdk/quartz/gdkevents-quartz.c | 12 +------
3 files changed, 36 insertions(+), 53 deletions(-)
---
diff --git a/gdk/quartz/GdkQuartzNSWindow.c b/gdk/quartz/GdkQuartzNSWindow.c
index 6c8f233cf7..f392a71f81 100644
--- a/gdk/quartz/GdkQuartzNSWindow.c
+++ b/gdk/quartz/GdkQuartzNSWindow.c
@@ -379,22 +379,46 @@
initialPositionKnown = NO;
}
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
+
- (NSPoint)convertPointToScreen:(NSPoint)point
{
- NSRect inrect = NSMakeRect (point.x, point.y, 0.0, 0.0);
- NSRect outrect = [self convertRectToScreen: inrect];
- return (NSPoint)((CGRect)outrect).origin;
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
+ if (gdk_quartz_osx_version () >= GDK_OSX_MOJAVE)
+ {
+ return [super convertPointToScreen: point];
+ }
+#endif
+ if (gdk_quartz_osx_version () >= GDK_OSX_LION)
+ {
+ NSRect inrect = NSMakeRect (point.x, point.y, 0.0, 0.0);
+ NSRect outrect = [self convertRectToScreen: inrect];
+ return (NSPoint)((CGRect)outrect).origin;
+ }
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
+ return [self convertBaseToScreen:point];
+#endif
}
- (NSPoint)convertPointFromScreen:(NSPoint)point
{
- NSRect inrect = NSMakeRect (point.x, point.y, 0.0, 0.0);
- NSRect outrect = [self convertRectFromScreen: inrect];
- return (NSPoint)((CGRect)outrect).origin;
-}
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
+ if (gdk_quartz_osx_version () >= GDK_OSX_MOJAVE)
+ {
+ return [super convertPointToScreen: point];
+ }
+#endif
+ if (gdk_quartz_osx_version () >= GDK_OSX_LION)
+ {
+ NSRect inrect = NSMakeRect (point.x, point.y, 0.0, 0.0);
+ NSRect outrect = [self convertRectFromScreen: inrect];
+ return (NSPoint)((CGRect)outrect).origin;
+ }
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
+ return [self convertScreenToBase:point];
#endif
+}
- (BOOL)trackManualMove
{
@@ -407,11 +431,8 @@
if (!inManualMove)
return NO;
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
- currentLocation = [self convertBaseToScreen:[self mouseLocationOutsideOfEventStream]];
-#else
+
currentLocation = [self convertPointToScreen:[self mouseLocationOutsideOfEventStream]];
-#endif
newOrigin.x = currentLocation.x - initialMoveLocation.x;
newOrigin.y = currentLocation.y - initialMoveLocation.y;
@@ -442,11 +463,7 @@
inManualMove = YES;
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
- initialMoveLocation = [self convertBaseToScreen:[self mouseLocationOutsideOfEventStream]];
-#else
initialMoveLocation = [self convertPointToScreen:[self mouseLocationOutsideOfEventStream]];
-#endif
initialMoveLocation.x -= frame.origin.x;
initialMoveLocation.y -= frame.origin.y;
}
@@ -462,12 +479,7 @@
return NO;
inTrackManualResize = YES;
-
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
- mouse_location = [self convertBaseToScreen:[self mouseLocationOutsideOfEventStream]];
-#else
mouse_location = [self convertPointToScreen:[self mouseLocationOutsideOfEventStream]];
-#endif
mdx = initialResizeLocation.x - mouse_location.x;
mdy = initialResizeLocation.y - mouse_location.y;
@@ -552,12 +564,7 @@
resizeEdge = edge;
initialResizeFrame = [self frame];
-
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
- initialResizeLocation = [self convertBaseToScreen:[self mouseLocationOutsideOfEventStream]];
-#else
initialResizeLocation = [self convertPointToScreen:[self mouseLocationOutsideOfEventStream]];
-#endif
}
@@ -690,13 +697,7 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
{
NSPoint point = [sender draggingLocation];
- NSPoint screen_point;
-
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
- screen_point = [self convertBaseToScreen:point];
-#else
- screen_point = [self convertPointToScreen:point];
-#endif
+ NSPoint screen_point = [self convertPointToScreen:point];
GdkEvent *event;
int gx, gy;
@@ -724,13 +725,7 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
NSPoint point = [sender draggingLocation];
- NSPoint screen_point;
-
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
- screen_point = [self convertBaseToScreen:point];
-#else
- screen_point = [self convertPointToScreen:point];
-#endif
+ NSPoint screen_point = [self convertPointToScreen:point];
GdkEvent *event;
int gy, gx;
diff --git a/gdk/quartz/GdkQuartzNSWindow.h b/gdk/quartz/GdkQuartzNSWindow.h
index 45d1d67196..081d5d81c5 100644
--- a/gdk/quartz/GdkQuartzNSWindow.h
+++ b/gdk/quartz/GdkQuartzNSWindow.h
@@ -53,10 +53,8 @@
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
-(void)setStyleMask:(NSUInteger)styleMask;
#endif
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
- (NSPoint)convertPointToScreen:(NSPoint)point;
- (NSPoint)convertPointFromScreen:(NSPoint)point;
-#endif
@end
diff --git a/gdk/quartz/gdkevents-quartz.c b/gdk/quartz/gdkevents-quartz.c
index 642fe7f1ee..74f59b1e01 100644
--- a/gdk/quartz/gdkevents-quartz.c
+++ b/gdk/quartz/gdkevents-quartz.c
@@ -379,12 +379,7 @@ get_window_point_from_screen_point (GdkWindow *window,
GdkQuartzNSWindow *nswindow;
nswindow = (GdkQuartzNSWindow*)(((GdkWindowImplQuartz *)window->impl)->toplevel);
-
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
- point = [nswindow convertScreenToBase:screen_point];
-#else
point = [nswindow convertPointFromScreen:screen_point];
-#endif
*x = point.x;
*y = window->height - point.y;
}
@@ -460,12 +455,7 @@ get_toplevel_from_ns_event (NSEvent *nsevent,
}
else
{
- if (gdk_quartz_osx_version () >= GDK_OSX_LION)
- *screen_point = [(GdkQuartzNSWindow*)[nsevent window] convertPointToScreen:point];
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 10700
- else
- *screen_point = [[nsevent window] convertBaseToScreen:point];
-#endif
+ *screen_point = [(GdkQuartzNSWindow*)[nsevent window] convertPointToScreen:point];
*x = point.x;
*y = toplevel->height - point.y;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]