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
This commit is contained in:
parent
baa283b73b
commit
aeec73f53f
@ -379,22 +379,46 @@
|
|||||||
|
|
||||||
initialPositionKnown = NO;
|
initialPositionKnown = NO;
|
||||||
}
|
}
|
||||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
|
|
||||||
- (NSPoint)convertPointToScreen:(NSPoint)point
|
- (NSPoint)convertPointToScreen:(NSPoint)point
|
||||||
|
{
|
||||||
|
#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 inrect = NSMakeRect (point.x, point.y, 0.0, 0.0);
|
||||||
NSRect outrect = [self convertRectToScreen: inrect];
|
NSRect outrect = [self convertRectToScreen: inrect];
|
||||||
return (NSPoint)((CGRect)outrect).origin;
|
return (NSPoint)((CGRect)outrect).origin;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
|
||||||
|
return [self convertBaseToScreen:point];
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSPoint)convertPointFromScreen:(NSPoint)point
|
- (NSPoint)convertPointFromScreen:(NSPoint)point
|
||||||
|
{
|
||||||
|
#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 inrect = NSMakeRect (point.x, point.y, 0.0, 0.0);
|
||||||
NSRect outrect = [self convertRectFromScreen: inrect];
|
NSRect outrect = [self convertRectFromScreen: inrect];
|
||||||
return (NSPoint)((CGRect)outrect).origin;
|
return (NSPoint)((CGRect)outrect).origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
|
||||||
|
return [self convertScreenToBase:point];
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL)trackManualMove
|
- (BOOL)trackManualMove
|
||||||
{
|
{
|
||||||
@ -407,11 +431,8 @@
|
|||||||
|
|
||||||
if (!inManualMove)
|
if (!inManualMove)
|
||||||
return NO;
|
return NO;
|
||||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
|
|
||||||
currentLocation = [self convertBaseToScreen:[self mouseLocationOutsideOfEventStream]];
|
|
||||||
#else
|
|
||||||
currentLocation = [self convertPointToScreen:[self mouseLocationOutsideOfEventStream]];
|
currentLocation = [self convertPointToScreen:[self mouseLocationOutsideOfEventStream]];
|
||||||
#endif
|
|
||||||
newOrigin.x = currentLocation.x - initialMoveLocation.x;
|
newOrigin.x = currentLocation.x - initialMoveLocation.x;
|
||||||
newOrigin.y = currentLocation.y - initialMoveLocation.y;
|
newOrigin.y = currentLocation.y - initialMoveLocation.y;
|
||||||
|
|
||||||
@ -442,11 +463,7 @@
|
|||||||
|
|
||||||
inManualMove = YES;
|
inManualMove = YES;
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
|
|
||||||
initialMoveLocation = [self convertBaseToScreen:[self mouseLocationOutsideOfEventStream]];
|
|
||||||
#else
|
|
||||||
initialMoveLocation = [self convertPointToScreen:[self mouseLocationOutsideOfEventStream]];
|
initialMoveLocation = [self convertPointToScreen:[self mouseLocationOutsideOfEventStream]];
|
||||||
#endif
|
|
||||||
initialMoveLocation.x -= frame.origin.x;
|
initialMoveLocation.x -= frame.origin.x;
|
||||||
initialMoveLocation.y -= frame.origin.y;
|
initialMoveLocation.y -= frame.origin.y;
|
||||||
}
|
}
|
||||||
@ -462,12 +479,7 @@
|
|||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
inTrackManualResize = YES;
|
inTrackManualResize = YES;
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
|
|
||||||
mouse_location = [self convertBaseToScreen:[self mouseLocationOutsideOfEventStream]];
|
|
||||||
#else
|
|
||||||
mouse_location = [self convertPointToScreen:[self mouseLocationOutsideOfEventStream]];
|
mouse_location = [self convertPointToScreen:[self mouseLocationOutsideOfEventStream]];
|
||||||
#endif
|
|
||||||
mdx = initialResizeLocation.x - mouse_location.x;
|
mdx = initialResizeLocation.x - mouse_location.x;
|
||||||
mdy = initialResizeLocation.y - mouse_location.y;
|
mdy = initialResizeLocation.y - mouse_location.y;
|
||||||
|
|
||||||
@ -552,12 +564,7 @@
|
|||||||
resizeEdge = edge;
|
resizeEdge = edge;
|
||||||
|
|
||||||
initialResizeFrame = [self frame];
|
initialResizeFrame = [self frame];
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
|
|
||||||
initialResizeLocation = [self convertBaseToScreen:[self mouseLocationOutsideOfEventStream]];
|
|
||||||
#else
|
|
||||||
initialResizeLocation = [self convertPointToScreen:[self mouseLocationOutsideOfEventStream]];
|
initialResizeLocation = [self convertPointToScreen:[self mouseLocationOutsideOfEventStream]];
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -690,13 +697,7 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
|
|||||||
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
|
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
|
||||||
{
|
{
|
||||||
NSPoint point = [sender draggingLocation];
|
NSPoint point = [sender draggingLocation];
|
||||||
NSPoint screen_point;
|
NSPoint screen_point = [self convertPointToScreen:point];
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
|
|
||||||
screen_point = [self convertBaseToScreen:point];
|
|
||||||
#else
|
|
||||||
screen_point = [self convertPointToScreen:point];
|
|
||||||
#endif
|
|
||||||
GdkEvent *event;
|
GdkEvent *event;
|
||||||
int gx, gy;
|
int gx, gy;
|
||||||
|
|
||||||
@ -724,13 +725,7 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
|
|||||||
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
||||||
{
|
{
|
||||||
NSPoint point = [sender draggingLocation];
|
NSPoint point = [sender draggingLocation];
|
||||||
NSPoint screen_point;
|
NSPoint screen_point = [self convertPointToScreen:point];
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
|
|
||||||
screen_point = [self convertBaseToScreen:point];
|
|
||||||
#else
|
|
||||||
screen_point = [self convertPointToScreen:point];
|
|
||||||
#endif
|
|
||||||
GdkEvent *event;
|
GdkEvent *event;
|
||||||
int gy, gx;
|
int gy, gx;
|
||||||
|
|
||||||
|
@ -53,10 +53,8 @@
|
|||||||
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
|
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
|
||||||
-(void)setStyleMask:(NSUInteger)styleMask;
|
-(void)setStyleMask:(NSUInteger)styleMask;
|
||||||
#endif
|
#endif
|
||||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
|
|
||||||
- (NSPoint)convertPointToScreen:(NSPoint)point;
|
- (NSPoint)convertPointToScreen:(NSPoint)point;
|
||||||
- (NSPoint)convertPointFromScreen:(NSPoint)point;
|
- (NSPoint)convertPointFromScreen:(NSPoint)point;
|
||||||
#endif
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@ -379,12 +379,7 @@ get_window_point_from_screen_point (GdkWindow *window,
|
|||||||
GdkQuartzNSWindow *nswindow;
|
GdkQuartzNSWindow *nswindow;
|
||||||
|
|
||||||
nswindow = (GdkQuartzNSWindow*)(((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];
|
point = [nswindow convertPointFromScreen:screen_point];
|
||||||
#endif
|
|
||||||
*x = point.x;
|
*x = point.x;
|
||||||
*y = window->height - point.y;
|
*y = window->height - point.y;
|
||||||
}
|
}
|
||||||
@ -460,12 +455,7 @@ get_toplevel_from_ns_event (NSEvent *nsevent,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (gdk_quartz_osx_version () >= GDK_OSX_LION)
|
|
||||||
*screen_point = [(GdkQuartzNSWindow*)[nsevent window] convertPointToScreen:point];
|
*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;
|
*x = point.x;
|
||||||
*y = toplevel->height - point.y;
|
*y = toplevel->height - point.y;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user