From 542d331c12fe072ea9c14b2d4f9c0aeb07867b20 Mon Sep 17 00:00:00 2001 From: Joan Torres Date: Fri, 6 Oct 2023 19:08:15 +0200 Subject: [PATCH] x11: Add an XdpParent on file chooser dialog This adds a new implementation of XdpParent. To get the "parent_window" is simpler, it's just the window_id which is the window property of xcb. --- platform/x11/cog-platform-x11.c | 9 +++++--- platform/x11/cog-xdp-parent-x11.c | 37 +++++++++++++++++++++++++++++++ platform/x11/cog-xdp-parent-x11.h | 17 ++++++++++++++ platform/x11/meson.build | 1 + 4 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 platform/x11/cog-xdp-parent-x11.c create mode 100644 platform/x11/cog-xdp-parent-x11.h diff --git a/platform/x11/cog-platform-x11.c b/platform/x11/cog-platform-x11.c index 8d6dbec8..4f53ba75 100644 --- a/platform/x11/cog-platform-x11.c +++ b/platform/x11/cog-platform-x11.c @@ -22,6 +22,7 @@ #include "../common/cog-file-chooser.h" #include "../common/cog-gl-utils.h" #include "../common/egl-proc-address.h" +#include "cog-xdp-parent-x11.h" #ifndef EGL_EXT_platform_base @@ -877,9 +878,11 @@ 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); + XdpParent *xdp_parent = xdp_parent_new_x11(&s_window->xcb.window); + + run_file_chooser(view, request, xdp_parent); + + g_clear_pointer(&xdp_parent, xdp_parent_free); } static void diff --git a/platform/x11/cog-xdp-parent-x11.c b/platform/x11/cog-xdp-parent-x11.c new file mode 100644 index 00000000..0937d2c2 --- /dev/null +++ b/platform/x11/cog-xdp-parent-x11.c @@ -0,0 +1,37 @@ +/* + * 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..fe3df0e2 --- /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,