diff --git a/platform/x11/cog-platform-x11.c b/platform/x11/cog-platform-x11.c index 910fd78c..c9695fb7 100644 --- a/platform/x11/cog-platform-x11.c +++ b/platform/x11/cog-platform-x11.c @@ -24,7 +24,9 @@ #endif /* COG_HAVE_LIBPORTAL */ #include "../common/cog-gl-utils.h" #include "../common/egl-proc-address.h" - +#if COG_HAVE_LIBPORTAL +# include "cog-xdp-parent-x11.h" +#endif /* COG_HAVE_LIBPORTAL */ #ifndef EGL_EXT_platform_base #define EGL_EXT_platform_base 1 @@ -880,9 +882,9 @@ cog_x11_platform_get_view_backend(CogPlatform *platform, WebKitWebView *related_ static void on_run_file_chooser(WebKitWebView *view, WebKitFileChooserRequest *request) { - /* TODO: Disable input of main window and keep this new file chooser - * window always on top. This could be done adding an XdpParent. */ - run_file_chooser(view, request, NULL); + g_autoptr(XdpParent) xdp_parent = xdp_parent_new_x11(&s_window->xcb.window); + + run_file_chooser(view, request, xdp_parent); } #endif /* COG_HAVE_LIBPORTAL */ diff --git a/platform/x11/cog-xdp-parent-x11.c b/platform/x11/cog-xdp-parent-x11.c new file mode 100644 index 00000000..940bc151 --- /dev/null +++ b/platform/x11/cog-xdp-parent-x11.c @@ -0,0 +1,35 @@ +/* + * cog-xdp-parent-x11.c + * Copyright (C) 2023 SUSE Software Solutions Germany GmbH + * + * Distributed under terms of the MIT license. + */ + +#include "cog-xdp-parent-x11.h" + +#include "../common/xdp-parent-private.h" + +static gboolean +xdp_parent_export_x11(XdpParent *parent, XdpParentExported callback, gpointer user_data) +{ + xcb_window_t *window_id = (xcb_window_t *) parent->data; + guint32 xid = (guint32) *window_id; + g_autofree char *handle = g_strdup_printf("x11:%x", xid); + callback(parent, handle, user_data); + return TRUE; +} + +static void +xdp_parent_unexport_x11(XdpParent *parent) +{ +} + +XdpParent * +xdp_parent_new_x11(xcb_window_t *window_id) +{ + XdpParent *parent = g_new0(XdpParent, 1); + parent->parent_export = xdp_parent_export_x11; + parent->parent_unexport = xdp_parent_unexport_x11; + parent->data = (gpointer) window_id; + return parent; +} diff --git a/platform/x11/cog-xdp-parent-x11.h b/platform/x11/cog-xdp-parent-x11.h new file mode 100644 index 00000000..27b47f8b --- /dev/null +++ b/platform/x11/cog-xdp-parent-x11.h @@ -0,0 +1,17 @@ +/* + * cog-xdp-parent-x11.h + * Copyright (C) 2023 SUSE Software Solutions Germany GmbH + * + * Distributed under terms of the MIT license. + */ + +#pragma once + +#include +#include + +G_BEGIN_DECLS + +XdpParent *xdp_parent_new_x11(xcb_window_t *window); + +G_END_DECLS diff --git a/platform/x11/meson.build b/platform/x11/meson.build index 80bc6e9c..d8f77eca 100644 --- a/platform/x11/meson.build +++ b/platform/x11/meson.build @@ -1,5 +1,6 @@ x11_platform_plugin = shared_module('cogplatform-x11', 'cog-platform-x11.c', + 'cog-xdp-parent-x11.c', c_args: ['-DG_LOG_DOMAIN="Cog-X11"'], dependencies: [ wpebackend_fdo_dep,