Skip to content

Commit

Permalink
x11: Add an XdpParent on file chooser dialog
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
joantolo committed Oct 18, 2023
1 parent 0933cb8 commit cf8d6d8
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 4 deletions.
10 changes: 6 additions & 4 deletions platform/x11/cog-platform-x11.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */

Expand Down
35 changes: 35 additions & 0 deletions platform/x11/cog-xdp-parent-x11.c
Original file line number Diff line number Diff line change
@@ -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;
}
17 changes: 17 additions & 0 deletions platform/x11/cog-xdp-parent-x11.h
Original file line number Diff line number Diff line change
@@ -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 <libportal/types.h>
#include <xcb/xproto.h>

G_BEGIN_DECLS

XdpParent *xdp_parent_new_x11(xcb_window_t *window);

G_END_DECLS
6 changes: 6 additions & 0 deletions platform/x11/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
x11_platform_sources = []
if libportal_dep.found()
x11_platform_sources += ['cog-xdp-parent-x11.c']
endif

x11_platform_plugin = shared_module('cogplatform-x11',
'cog-platform-x11.c',
x11_platform_sources,
c_args: ['-DG_LOG_DOMAIN="Cog-X11"'],
dependencies: [
wpebackend_fdo_dep,
Expand Down

0 comments on commit cf8d6d8

Please sign in to comment.