Merge branch 'amolenaar/macos-fix-delayed-rendering' into 'main'

macos: Avoid repeatedly sending events back to macOS

See merge request GNOME/gtk!7158
This commit is contained in:
Matthias Clasen 2024-04-22 16:25:57 +00:00
commit 2e0f411de9
4 changed files with 13 additions and 7 deletions

View File

@ -161,7 +161,7 @@ void _gdk_macos_display_send_event (GdkMacosDisp
void _gdk_macos_display_warp_pointer (GdkMacosDisplay *self, void _gdk_macos_display_warp_pointer (GdkMacosDisplay *self,
int x, int x,
int y); int y);
NSEvent *_gdk_macos_display_get_nsevent (GdkEvent *event); NSEvent *_gdk_macos_display_pop_nsevent (GdkEvent *event);
NSEvent *_gdk_macos_display_get_last_nsevent (void); NSEvent *_gdk_macos_display_get_last_nsevent (void);
GdkDrag *_gdk_macos_display_find_drag (GdkMacosDisplay *self, GdkDrag *_gdk_macos_display_find_drag (GdkMacosDisplay *self,
NSInteger sequence_number); NSInteger sequence_number);

View File

@ -992,16 +992,22 @@ _gdk_macos_display_warp_pointer (GdkMacosDisplay *self,
} }
NSEvent * NSEvent *
_gdk_macos_display_get_nsevent (GdkEvent *event) _gdk_macos_display_pop_nsevent (GdkEvent *event)
{ {
for (const GList *iter = event_map.head; iter; iter = iter->next) for (GList *iter = event_map.head; iter; iter = iter->next)
{ {
const GdkToNSEventMap *map = iter->data; GdkToNSEventMap *map = iter->data;
if (map->gdk_event->event_type == event->event_type && if (map->gdk_event->event_type == event->event_type &&
map->gdk_event->device == event->device && map->gdk_event->device == event->device &&
map->gdk_event->time == event->time) map->gdk_event->time == event->time)
return map->nsevent; {
NSEvent *nsevent = map->nsevent;
g_queue_unlink (&event_map, iter);
gdk_event_unref (map->gdk_event);
g_free (map);
return nsevent;
}
} }
return NULL; return NULL;

View File

@ -738,7 +738,7 @@ gdk_macos_event_source_dispatch (GSource *source,
if (!handled) if (!handled)
{ {
NSEvent *nsevent = _gdk_macos_display_get_nsevent (event); NSEvent *nsevent = _gdk_macos_display_pop_nsevent (event);
if (nsevent != NULL) if (nsevent != NULL)
[NSApp sendEvent: nsevent]; [NSApp sendEvent: nsevent];
} }

View File

@ -185,7 +185,7 @@ quartz_filter_keypress (GtkIMContext *context,
keyval = gdk_key_event_get_keyval (event); keyval = gdk_key_event_get_keyval (event);
keycode = gdk_key_event_get_keycode (event); keycode = gdk_key_event_get_keycode (event);
NSEvent *nsevent = _gdk_macos_display_get_nsevent ((GdkEvent *)event); NSEvent *nsevent = _gdk_macos_display_pop_nsevent ((GdkEvent *)event);
if (!nsevent) if (!nsevent)
{ {