From f094120360b4cfbb104496c0b3e21b26f88547a6 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sun, 21 Nov 2021 17:38:41 +0800 Subject: [PATCH] Implement `pick_embedded_child' for offscreen xwidgets * src/xwidget.c (pick_embedded_child): New function. (Fmake_xwidget): Connect `pick-embedded-child' signal to offscreen window. --- src/xwidget.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/xwidget.c b/src/xwidget.c index b0ff142bc73..d88270dbe97 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -64,6 +64,7 @@ static gboolean webkit_script_dialog_cb (WebKitWebView *, WebKitScriptDialog *, static void record_osr_embedder (struct xwidget_view *); static void from_embedder (GdkWindow *, double, double, gpointer, gpointer, gpointer); static void to_embedder (GdkWindow *, double, double, gpointer, gpointer, gpointer); +static GdkWindow *pick_embedded_child (GdkWindow *, double, double, gpointer); #endif static struct xwidget * @@ -243,6 +244,8 @@ fails. */) "from-embedder", G_CALLBACK (from_embedder), NULL); g_signal_connect (G_OBJECT (gtk_widget_get_window (xw->widgetwindow_osr)), "to-embedder", G_CALLBACK (to_embedder), NULL); + g_signal_connect (G_OBJECT (gtk_widget_get_window (xw->widgetwindow_osr)), + "pick-embedded-child", G_CALLBACK (pick_embedded_child), NULL); /* Store some xwidget data in the gtk widgets for convenient retrieval in the event handlers. */ @@ -510,6 +513,32 @@ xwidget_from_id (uint32_t id) } #ifdef USE_GTK +static GdkWindow * +pick_embedded_child (GdkWindow *window, double x, double y, + gpointer user_data) +{ + GtkWidget *widget; + GtkWidget *child; + GdkEvent event; + int xout, yout; + + event.any.window = window; + event.any.type = GDK_NOTHING; + + widget = gtk_get_event_widget (&event); + + if (!widget) + return NULL; + + child = find_widget_at_pos (widget, lrint (x), lrint (y), + &xout, &yout); + + if (!child) + return NULL; + + return gtk_widget_get_window (child); +} + static void record_osr_embedder (struct xwidget_view *view) { -- 2.39.5