quartz: fix enter/leave on macOS 13 and Dock redraws
Also builds with the 10.4 SDK again. Taken from Ardour's YTK, which has the enter/leave fix from GTK 3: - 7e1a3ffa37 (John Ralls, GTK 3) - ea461691 (Paul Davis)
This commit is contained in:
parent
dece7d509a
commit
38ee32db64
3 changed files with 45 additions and 3 deletions
|
|
@ -69,6 +69,9 @@
|
|||
_gdk_quartz_window_attach_to_parent (window);
|
||||
|
||||
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_ICONIFIED, 0);
|
||||
|
||||
/* newer systems may come back with stale contents (Ardour) */
|
||||
[[self contentView] setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
-(void)windowDidBecomeKey:(NSNotification *)aNotification
|
||||
|
|
|
|||
|
|
@ -863,8 +863,36 @@ find_window_for_ns_event (NSEvent *nsevent,
|
|||
*/
|
||||
if ([view trackingRect] == [nsevent trackingNumber])
|
||||
return toplevel;
|
||||
else
|
||||
return NULL;
|
||||
|
||||
/* macOS 13 no longer sends the events of the tracking rect, but
|
||||
* those of the cursor rects, which earlier ones were left out:
|
||||
* they come 4 pixels outside the frame of the window (the same
|
||||
* fix as GTK+ 3 and Ardour's YTK) */
|
||||
if (gdk_quartz_osx_version () >= GDK_OSX_VENTURA &&
|
||||
(![nsevent respondsToSelector:@selector(trackingArea)] ||
|
||||
[(id) nsevent trackingArea] == nil))
|
||||
{
|
||||
const CGFloat 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 == NSMouseEntered && inside) || at_edge)
|
||||
return toplevel;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
case NSKeyDown:
|
||||
case NSKeyUp:
|
||||
|
|
|
|||
|
|
@ -145,9 +145,19 @@ _gdk_quartz_image_copy_to_image (GdkDrawable *drawable,
|
|||
|
||||
if (GDK_WINDOW_IMPL_QUARTZ (drawable) == GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (_gdk_root)->impl))
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050
|
||||
/* the screen cannot be read before 10.5 (CGWindowListCreateImage) */
|
||||
return image;
|
||||
#else
|
||||
/* Special case for the root window. */
|
||||
CGRect rect = CGRectMake (src_x, src_y, width, height);
|
||||
CGImageRef root_image_ref = CGWindowListCreateImage (rect,
|
||||
CGImageRef root_image_ref;
|
||||
|
||||
/* weakly linked where 10.4 is the oldest system */
|
||||
if (CGWindowListCreateImage == NULL)
|
||||
return image;
|
||||
|
||||
root_image_ref = CGWindowListCreateImage (rect,
|
||||
kCGWindowListOptionOnScreenOnly,
|
||||
kCGNullWindowID,
|
||||
kCGWindowImageDefault);
|
||||
|
|
@ -170,6 +180,7 @@ _gdk_quartz_image_copy_to_image (GdkDrawable *drawable,
|
|||
|
||||
rep = [[NSBitmapImageRep alloc] initWithCGImage: root_image_ref];
|
||||
CGImageRelease (root_image_ref);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue