Merge branch 'issue5305' into 'gtk-3-24'
[quartz] Work around macOS 13 not sending trackingArea events. See merge request GNOME/gtk!5280
This commit is contained in:
@ -266,6 +266,9 @@
|
||||
if (trackingRect)
|
||||
{
|
||||
[self removeTrackingRect: trackingRect];
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 10500
|
||||
[(NSTrackingArea*)trackingRect release];
|
||||
#endif
|
||||
trackingRect = 0;
|
||||
}
|
||||
|
||||
@ -479,13 +482,19 @@ copy_rectangle_argb32 (cairo_surface_t *dest, cairo_surface_t *source,
|
||||
{
|
||||
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (gdk_window->impl);
|
||||
NSRect rect;
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 10500
|
||||
NSTrackingArea *trackingArea;
|
||||
#endif
|
||||
|
||||
if (!impl || !impl->toplevel)
|
||||
return;
|
||||
|
||||
if (trackingRect)
|
||||
{
|
||||
[self removeTrackingRect: trackingRect];
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 10500
|
||||
[(NSTrackingArea*)trackingRect release];
|
||||
#endif
|
||||
trackingRect = 0;
|
||||
}
|
||||
|
||||
@ -497,10 +506,19 @@ copy_rectangle_argb32 (cairo_surface_t *dest, cairo_surface_t *source,
|
||||
*/
|
||||
|
||||
rect = [self bounds];
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 10500
|
||||
trackingArea = [[NSTrackingArea alloc] initWithRect: rect
|
||||
options: NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingCursorUpdate | NSTrackingActiveInActiveApp | NSTrackingInVisibleRect | NSTrackingEnabledDuringMouseDrag
|
||||
owner: self
|
||||
userInfo: nil];
|
||||
[self addTrackingArea: trackingArea];
|
||||
trackingRect = (NSInteger)[trackingArea retain];
|
||||
#else
|
||||
trackingRect = [self addTrackingRect: rect
|
||||
owner: self
|
||||
userData: nil
|
||||
assumeInside: NO];
|
||||
#endif
|
||||
}
|
||||
|
||||
-(void)viewDidMoveToWindow
|
||||
@ -516,20 +534,21 @@ copy_rectangle_argb32 (cairo_surface_t *dest, cairo_surface_t *source,
|
||||
if (newWindow == nil && trackingRect)
|
||||
{
|
||||
[self removeTrackingRect: trackingRect];
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 10500
|
||||
[(NSTrackingArea*)trackingRect release];
|
||||
#endif
|
||||
trackingRect = 0;
|
||||
}
|
||||
}
|
||||
|
||||
-(void)createBackingStoreWithWidth: (CGFloat) width andHeight: (CGFloat) height
|
||||
{
|
||||
CVReturn rv;
|
||||
|
||||
g_return_if_fail (width && height);
|
||||
|
||||
CVPixelBufferRelease (pixels);
|
||||
rv = CVPixelBufferCreate (NULL, width, height,
|
||||
kCVPixelFormatType_32BGRA,
|
||||
cfpb_props, &pixels);
|
||||
CVPixelBufferCreate (NULL, width, height,
|
||||
kCVPixelFormatType_32BGRA,
|
||||
cfpb_props, &pixels);
|
||||
|
||||
}
|
||||
|
||||
|
@ -388,7 +388,7 @@ get_window_point_from_screen_point (GdkWindow *window,
|
||||
NSPoint point;
|
||||
GdkQuartzNSWindow *nswindow;
|
||||
|
||||
nswindow = gdk_quartz_window_get_nswindow (window);
|
||||
nswindow = (GdkQuartzNSWindow*)gdk_quartz_window_get_nswindow (window);
|
||||
point = [nswindow convertPointFromScreen:screen_point];
|
||||
*x = point.x;
|
||||
*y = window->height - point.y;
|
||||
@ -793,12 +793,7 @@ find_toplevel_for_mouse_event (NSEvent *nsevent,
|
||||
if (toplevel_under_pointer
|
||||
&& WINDOW_IS_TOPLEVEL (toplevel_under_pointer))
|
||||
{
|
||||
GdkWindowImplQuartz *toplevel_impl;
|
||||
|
||||
toplevel = toplevel_under_pointer;
|
||||
|
||||
toplevel_impl = GDK_WINDOW_IMPL_QUARTZ (toplevel->impl);
|
||||
|
||||
*x = x_tmp;
|
||||
*y = y_tmp;
|
||||
}
|
||||
@ -855,10 +850,43 @@ find_window_for_ns_event (NSEvent *nsevent,
|
||||
/* Only handle our own entered/exited events, not the ones for the
|
||||
* titlebar buttons.
|
||||
*/
|
||||
if ([view trackingRect] == [nsevent trackingNumber])
|
||||
return toplevel;
|
||||
else
|
||||
return NULL;
|
||||
if ([view trackingRect] == nsevent.trackingNumber)
|
||||
return toplevel;
|
||||
|
||||
/* MacOS 13 isn't sending the trackingArea events so we have to
|
||||
* rely on the cursorRect events that we discarded in earlier
|
||||
* macOS versions. These trigger 4 pixels out from the window's
|
||||
* frame so we obtain that rect and adjust it for hit testing.
|
||||
*/
|
||||
if (!nsevent.trackingArea && gdk_quartz_osx_version >= GDK_OSX_VENTURA)
|
||||
{
|
||||
static const int border_width = 4;
|
||||
NSRect frame = nsevent.window.frame;
|
||||
gboolean inside, at_edge;
|
||||
|
||||
frame.origin.x -= border_width;
|
||||
frame.origin.y -= border_width;
|
||||
frame.size.width += 2 * border_width;
|
||||
frame.size.height += 2 * border_width;
|
||||
inside =
|
||||
screen_point.x >= frame.origin.x &&
|
||||
screen_point.x <= frame.origin.x + frame.size.width &&
|
||||
screen_point.y >= frame.origin.y &&
|
||||
screen_point.y <= frame.origin.y + frame.size.height;
|
||||
at_edge =
|
||||
screen_point.x >= frame.origin.x - 1 &&
|
||||
screen_point.x <= frame.origin.x + frame.size.width + 1 &&
|
||||
screen_point.y >= frame.origin.y - 1 &&
|
||||
screen_point.y <= frame.origin.y + frame.size.height + 1;
|
||||
|
||||
if ((event_type == GDK_QUARTZ_MOUSE_ENTERED && inside) ||
|
||||
at_edge)
|
||||
return toplevel;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
case GDK_QUARTZ_KEY_DOWN:
|
||||
case GDK_QUARTZ_KEY_UP:
|
||||
@ -1140,9 +1168,6 @@ fill_scroll_event (GdkWindow *window,
|
||||
GdkScrollDirection direction)
|
||||
{
|
||||
GdkSeat *seat = gdk_display_get_default_seat (_gdk_display);
|
||||
NSPoint point;
|
||||
|
||||
point = [nsevent locationInWindow];
|
||||
|
||||
event->any.type = GDK_SCROLL;
|
||||
event->scroll.window = window;
|
||||
|
@ -43,7 +43,8 @@ typedef enum
|
||||
GDK_OSX_CATALINA = 15,
|
||||
GDK_OSX_BIGSUR = 16,
|
||||
GDK_OSX_MONTEREY = 17,
|
||||
GDK_OSX_CURRENT = 17,
|
||||
GDK_OSX_VENTURA = 18,
|
||||
GDK_OSX_CURRENT = 18,
|
||||
GDK_OSX_NEW = 99
|
||||
} GdkOSXVersion;
|
||||
|
||||
|
Reference in New Issue
Block a user