From 79dae5f2b4a75211935527ef3ebcdcedf9c423be Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 25 Sep 2024 19:32:21 +0200 Subject: [PATCH] Implement multitouch grab --- libs/tk/ydk/gdkdisplay.c | 5 +++++ libs/tk/ydk/gdkwindow.c | 24 ++++++++++++++++++++++++ libs/tk/ydk/ydk/gdk/gdkdisplay.h | 2 ++ 3 files changed, 31 insertions(+) diff --git a/libs/tk/ydk/gdkdisplay.c b/libs/tk/ydk/gdkdisplay.c index f7b43cf874..b9b036cebe 100644 --- a/libs/tk/ydk/gdkdisplay.c +++ b/libs/tk/ydk/gdkdisplay.c @@ -153,6 +153,11 @@ gdk_display_dispose (GObject *object) display->queued_events = NULL; display->queued_tail = NULL; + if (display->touch_grabs) + { + g_hash_table_destroy (display->touch_grabs); + } + _gdk_displays = g_slist_remove (_gdk_displays, object); if (gdk_display_get_default() == display) diff --git a/libs/tk/ydk/gdkwindow.c b/libs/tk/ydk/gdkwindow.c index fab05d1cac..054d628814 100644 --- a/libs/tk/ydk/gdkwindow.c +++ b/libs/tk/ydk/gdkwindow.c @@ -10848,6 +10848,30 @@ proxy_button_event (GdkEvent *source_event, type, state, NULL, serial); + /* multitouch grab */ + if (type == GDK_TOUCH_BEGIN && !source_event->any.send_event) + { + GdkEventTouch* tev = (GdkEventTouch*) source_event; + if (!display->touch_grabs) { + display->touch_grabs = g_hash_table_new (g_direct_hash, NULL); + } + event_win = _gdk_window_find_descendant_at (toplevel_window, toplevel_x, toplevel_y, NULL, NULL); + g_hash_table_insert (display->touch_grabs, GUINT_TO_POINTER (tev->sequence), event_win); + } + else if (type == GDK_TOUCH_END && display->touch_grabs) + { + GdkEventTouch* tev = (GdkEventTouch*) source_event; + g_hash_table_remove (display->touch_grabs, GUINT_TO_POINTER (tev->sequence)); + } + else if (type == GDK_TOUCH_UPDATE && display->touch_grabs) + { + GdkEventTouch* tev = (GdkEventTouch*) source_event; + void* w = g_hash_table_lookup (display->touch_grabs, GUINT_TO_POINTER (tev->sequence)); + if (w) { + event_win = GDK_WINDOW (w); + } + } + if (event_win == NULL || display->ignore_core_events) return TRUE; diff --git a/libs/tk/ydk/ydk/gdk/gdkdisplay.h b/libs/tk/ydk/ydk/gdk/gdkdisplay.h index 7cc8665144..96bb0572c1 100644 --- a/libs/tk/ydk/ydk/gdk/gdkdisplay.h +++ b/libs/tk/ydk/ydk/gdk/gdkdisplay.h @@ -101,6 +101,8 @@ struct _GdkDisplay GdkKeyboardGrabInfo GSEAL (keyboard_grab); GdkPointerWindowInfo GSEAL (pointer_info); + GHashTable *GSEAL (touch_grabs); + /* Last reported event time from server */ guint32 GSEAL (last_event_time); };