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 6, 2023
1 parent 7247fff commit 542d331
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 3 deletions.
9 changes: 6 additions & 3 deletions platform/x11/cog-platform-x11.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
37 changes: 37 additions & 0 deletions platform/x11/cog-xdp-parent-x11.c
Original file line number Diff line number Diff line change
@@ -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;
}
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
1 change: 1 addition & 0 deletions platform/x11/meson.build
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit 542d331

Please sign in to comment.