Skip to content

Add clipboard API and new input capture session construction API#208

Open
jadahl wants to merge 11 commits intoflatpak:mainfrom
jadahl:wip/input-capture-clipboard
Open

Add clipboard API and new input capture session construction API#208
jadahl wants to merge 11 commits intoflatpak:mainfrom
jadahl:wip/input-capture-clipboard

Conversation

@jadahl
Copy link

@jadahl jadahl commented Nov 20, 2025

This adds clipboard API usable with the existing remote desktop portal, and implements the new split session construction input capture API, as well as input capture clipboard support. See flatpak/xdg-desktop-portal#1803.

This makes the label not "fly away" when some other widget makes its
column wider.
Only starts the session and reports the shared devices and streams.
This will be necessary when handling signals, which needs to fetch the
session from a handle.
This adds API to interact with the clipboard portal associated with a
remote desktop session.
This allows copying to, and pasting from, the clipboard portal.
This makes it easier to construct a session from somewhere else, which
will be needed with CreateSession2().
It's its own thing, that also controls the lifetime of the actual
session, so need some special casing.
Rather useless, since we're not adding any barriers, but more complete
none the less.
In API version 2, the CreateSession() was replaced by
CreateSession2()/Start(); add API that corresponds to this.

Unfortunately applications will need to check whether this is supported
by manually checking the exposed API version, to use the new
construction method.
This will allow enabling clipboard integration later.
Copy link
Contributor

@whot whot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that one of the commit messages has a portal--test/ prefix

}

/**
* xdp_session_is_clipboard_enabed:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* xdp_session_is_clipboard_enabed:
* xdp_session_is_clipboard_enabled:

{
XdpPortal *portal = data;
XdpSession *session;
g_autoptr(GVariant) variant = NULL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
g_autoptr(GVariant) variant = NULL;

unused

mime_type, serial);
}

void
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void
static void

&error);
if (!ret)
{
g_warning ("Failed to write selection: %s", error->message);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
g_warning ("Failed to write selection: %s", error->message);
g_warning ("Failed to read selection: %s", error->message);

PORTAL_BUS_NAME,
PORTAL_OBJECT_PATH,
"org.freedesktop.portal.Clipboard",
"SetSelection",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"SetSelection",
"SelectionWriteDone",

if (!call->session_path)
{
g_task_return_new_error (call->task, G_IO_ERROR, G_IO_ERROR_FAILED,
"Missing session handel");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Missing session handel");
"Missing session handle");

Copy link
Contributor

@whot whot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nitpicks after a manual review, but overall this LGTM

Comment on lines +760 to +783
g_autoptr(GString) devices_s = NULL;

if (s->len > 0)
g_string_append (s, "\n");

devices_s = g_string_new (NULL);
g_string_append (s, "Devices: ");

if (device_types & XDP_DEVICE_KEYBOARD)
g_string_append (devices_s, "keyboard");

if (device_types & XDP_DEVICE_POINTER)
{
if (devices_s->len > 0)
g_string_append (devices_s, ", ");
g_string_append (devices_s, "pointer");
}

if (device_types & XDP_DEVICE_TOUCHSCREEN)
{
if (devices_s->len > 0)
g_string_append (devices_s, ", ");
g_string_append (devices_s, "touchscreen");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reckon this would be easier to read with a GStrv and a g_strjoin() or whatever it's called.

gpointer data);

XDP_PUBLIC
XdpInputCaptureSession * xdp_portal_create_input_capture_session2_finish (XdpPortal *portal,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just ftr, it'd be nice to also have this as _sync, feel free to steal that from #214

/* background */
guint background_interface_version;

/* clipbord */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* clipbord */
/* clipboard */

Comment on lines +764 to +768
"width", &w,
"height", &h,
"x", &x,
"y", &y,
NULL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like wrong indentation here

win);
if (xdp_portal_get_input_capture_version_sync (win->portal, NULL, NULL) > 1)
{
g_print ("Using new input capture session construction API\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover debug statement?

}
else
{
g_print ("Using legacy input capture session construction API\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@whot
Copy link
Contributor

whot commented Feb 26, 2026

yikes, another issue: the first two commits for portal-test/gtk3 need to be ordered after Add clipboard API, they make use of the clipboard api and won't build in this order.

Anyway, I've squashed all the above comments into my branch in #214 so might be easiest to get that one merged.

@sithlord48
Copy link

I've squashed all the above comments into my branch in #214 so might be easiest to get that one merged.

This has been replaced by #214 this one can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants