From: Christian Hergert Date: Sat, 5 Feb 2022 01:24:13 +0000 (-0800) Subject: macos: use input_region to specify tracking areas X-Git-Tag: archive/raspbian/4.6.5+ds-1+rpi1~1^2~19^2~3^2~94^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=f20740222883972826d9343c44284532dd377412;p=gtk4.git macos: use input_region to specify tracking areas We want our tracking area to be limited to the input region so that we don't pass along events outside of them for the window. This improves the chances we click-out of a popover with a large shadow. This still doesn't let us pass-through clicks for large shadows on top- level windows though. --- diff --git a/gdk/macos/GdkMacosBaseView.c b/gdk/macos/GdkMacosBaseView.c index ddce1241a3..a86d9712b2 100644 --- a/gdk/macos/GdkMacosBaseView.c +++ b/gdk/macos/GdkMacosBaseView.c @@ -45,7 +45,6 @@ options = (NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | - NSTrackingInVisibleRect | NSTrackingActiveAlways); trackingArea = [[NSTrackingArea alloc] initWithRect:rect options:options @@ -57,9 +56,26 @@ return self; } +-(void)setInputArea:(const cairo_rectangle_int_t *)area +{ + NSRect rect = NSMakeRect (area->x, area->y, area->width, area->height); + NSTrackingAreaOptions options; + + [self removeTrackingArea:trackingArea]; + + options = (NSTrackingMouseEnteredAndExited | + NSTrackingMouseMoved | + NSTrackingActiveAlways); + trackingArea = [[NSTrackingArea alloc] initWithRect:rect + options:options + owner:(id)self + userInfo:nil]; + [self addTrackingArea:trackingArea]; +} + -(void)setOpaqueRegion:(cairo_region_t *)region { - /* Do nothing */ + /* Handled in Subclass */ } -(BOOL)acceptsFirstMouse diff --git a/gdk/macos/GdkMacosBaseView.h b/gdk/macos/GdkMacosBaseView.h index 7fcfc7e43b..2eb6f72721 100644 --- a/gdk/macos/GdkMacosBaseView.h +++ b/gdk/macos/GdkMacosBaseView.h @@ -42,5 +42,6 @@ -(void)setNeedsInvalidateShadow: (BOOL)invalidate; -(NSTrackingArea *)trackingArea; -(void)setOpaqueRegion:(cairo_region_t *)region; +-(void)setInputArea:(const cairo_rectangle_int_t *)area; @end diff --git a/gdk/macos/gdkmacossurface.c b/gdk/macos/gdkmacossurface.c index b28fb27083..a2c7bb485d 100644 --- a/gdk/macos/gdkmacossurface.c +++ b/gdk/macos/gdkmacossurface.c @@ -94,6 +94,17 @@ static void gdk_macos_surface_set_input_region (GdkSurface *surface, cairo_region_t *region) { + GdkMacosSurface *self = (GdkMacosSurface *)surface; + cairo_rectangle_int_t rect; + + g_assert (GDK_IS_MACOS_SURFACE (self)); + + if (self->window == NULL) + return; + + cairo_region_get_extents (region, &rect); + + [(GdkMacosBaseView *)[self->window contentView] setInputArea:&rect]; } static void