[gtk/wip/chergert/macos-iosurface] macos: use input area to define tracking areas
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/macos-iosurface] macos: use input area to define tracking areas
- Date: Mon, 14 Feb 2022 01:22:52 +0000 (UTC)
commit d6fb235008f6ce84dfee5bcdde237e1428f5d67f
Author: Christian Hergert <christian hergert me>
Date: Sun Feb 13 17:22:43 2022 -0800
macos: use input area to define tracking areas
These are still way too big for libadwaita apps, but it's a start.
gdk/macos/GdkMacosBaseView.c | 18 ++++++++++++++++++
gdk/macos/GdkMacosBaseView.h | 1 +
gdk/macos/gdkmacossurface.c | 11 +++++++++++
3 files changed, 30 insertions(+)
---
diff --git a/gdk/macos/GdkMacosBaseView.c b/gdk/macos/GdkMacosBaseView.c
index ddce1241a3..79bd7d9617 100644
--- a/gdk/macos/GdkMacosBaseView.c
+++ b/gdk/macos/GdkMacosBaseView.c
@@ -57,6 +57,24 @@
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 |
+ NSTrackingInVisibleRect |
+ NSTrackingActiveAlways);
+ trackingArea = [[NSTrackingArea alloc] initWithRect:rect
+ options:options
+ owner:(id)self
+ userInfo:nil];
+ [self addTrackingArea:trackingArea];
+}
+
-(void)setOpaqueRegion:(cairo_region_t *)region
{
/* Do nothing */
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 6966db7894..80fe42f387 100644
--- a/gdk/macos/gdkmacossurface.c
+++ b/gdk/macos/gdkmacossurface.c
@@ -102,6 +102,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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]