[gtk/gtk-3-24: 3/20] Replace convertBaseToScreen & convertScreenToBase.



commit 4d0cae4468e111c29b2a5b393b4188d417e2e270
Author: John Ralls <jralls ceridwen us>
Date:   Mon Dec 3 21:03:34 2018 +0900

    Replace convertBaseToScreen & convertScreenToBase.
    
    With convertPointToScreen & convertPointFromScreen when
    MacOS version is > =10.7, when the earlier functions were
    deprecated and replaced.

 gdk/quartz/GdkQuartzNSWindow.c | 50 +++++++++++++++++++++++++++++++++++++++---
 gdk/quartz/GdkQuartzNSWindow.h |  5 ++++-
 gdk/quartz/gdkevents-quartz.c  | 19 +++++++++++-----
 3 files changed, 65 insertions(+), 9 deletions(-)
---
diff --git a/gdk/quartz/GdkQuartzNSWindow.c b/gdk/quartz/GdkQuartzNSWindow.c
index c66fea73c8..2ef40f86fb 100644
--- a/gdk/quartz/GdkQuartzNSWindow.c
+++ b/gdk/quartz/GdkQuartzNSWindow.c
@@ -366,6 +366,22 @@
 
   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;
+
+}
+
+- (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;
+}
+#endif
 
 - (BOOL)trackManualMove
 {
@@ -378,8 +394,11 @@
 
   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;
 
@@ -410,7 +429,11 @@
 
   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;
 }
@@ -427,7 +450,11 @@
 
   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;
 
@@ -512,7 +539,12 @@
   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
 }
 
 
@@ -647,7 +679,13 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
 - (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
 {
   NSPoint point = [sender draggingLocation];
-  NSPoint screen_point = [self convertBaseToScreen:point];
+  NSPoint screen_point;
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
+  screen_point = [self convertBaseToScreen:point];
+#else
+  screen_point = [self convertPointToScreen:point];
+#endif
   GdkEvent *event;
   int gx, gy;
 
@@ -675,7 +713,13 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
 - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
 {
   NSPoint point = [sender draggingLocation];
-  NSPoint screen_point = [self convertBaseToScreen:point];
+  NSPoint screen_point;
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
+    screen_point = [self convertBaseToScreen:point];
+#else
+  screen_point = [self convertPointToScreen:point];
+#endif
   GdkEvent *event;
   int gy, gx;
 
diff --git a/gdk/quartz/GdkQuartzNSWindow.h b/gdk/quartz/GdkQuartzNSWindow.h
index b8edf43e69..45d1d67196 100644
--- a/gdk/quartz/GdkQuartzNSWindow.h
+++ b/gdk/quartz/GdkQuartzNSWindow.h
@@ -53,7 +53,10 @@
 #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 01a400889a..fa64af4957 100644
--- a/gdk/quartz/gdkevents-quartz.c
+++ b/gdk/quartz/gdkevents-quartz.c
@@ -394,12 +394,15 @@ get_window_point_from_screen_point (GdkWindow *window,
                                     gint      *y)
 {
   NSPoint point;
-  NSWindow *nswindow;
+  GdkQuartzNSWindow *nswindow;
 
-  nswindow = ((GdkWindowImplQuartz *)window->impl)->toplevel;
+  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;
 }
@@ -413,6 +416,8 @@ is_mouse_button_press_event (NSEventType type)
       case NSRightMouseDown:
       case NSOtherMouseDown:
         return TRUE;
+    default:
+      return FALSE;
     }
 
   return FALSE;
@@ -473,8 +478,12 @@ get_toplevel_from_ns_event (NSEvent *nsevent,
         }
       else
         {
-          *screen_point = [[nsevent window] convertBaseToScreen:point];
-
+          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
           *x = point.x;
           *y = toplevel->height - point.y;
         }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]