Deskflow 1.26.0.314
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
PortalRemoteDesktop.h
Go to the documentation of this file.
1/*
2 * Deskflow -- mouse and keyboard sharing utility
3 * SPDX-FileCopyrightText: (C) 2024 Synergy App Ltd
4 * SPDX-FileCopyrightText: (C) 2022 Red Hat, Inc.
5 * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
6 */
7
8#pragma once
9
10#include "mt/Thread.h"
11#include "platform/EiScreen.h"
12
13#include <glib.h>
14#include <libportal/portal.h>
15
16#include <QByteArray>
17
18namespace deskflow {
19
21{
22public:
25
26 void claimClipboard() const;
27
28private:
29 void glibThread(const void *);
30 gboolean timeoutHandler() const;
31 gboolean initSession();
32 void handleInitSession(GObject *object, GAsyncResult *res);
33 void handleSessionStarted(GObject *object, GAsyncResult *res);
34 void handleSessionClosed(XdpSession *session);
35 void handleSelectionTransfer(XdpSession *session, const char *mimeType, uint32_t serial) const;
36 void handleSelectionOwnerChanged(XdpSession *session, char **mimeTypes, gboolean isOwner) const;
37 void reconnect(unsigned int timeout = 1000);
38
39 static void handleSessionClosedCallback(XdpSession *session, gpointer data)
40 {
41 static_cast<PortalRemoteDesktop *>(data)->handleSessionClosed(session);
42 }
43
44 static void selectionTransferCallback(XdpSession *session, const char *mimeType, uint32_t serial, gpointer data)
45 {
46 static_cast<PortalRemoteDesktop *>(data)->handleSelectionTransfer(session, mimeType, serial);
47 }
48
49 static void selectionOwnerChangedCallback(XdpSession *session, char **mimeTypes, gboolean isOwner, gpointer data)
50 {
51 static_cast<PortalRemoteDesktop *>(data)->handleSelectionOwnerChanged(session, mimeTypes, isOwner);
52 }
53
54private:
55 EiScreen *m_screen;
56 IEventQueue *m_events;
57
58 Thread *m_glibThread;
59 GMainLoop *m_glibMainLoop = nullptr;
60
61 XdpPortal *m_portal = nullptr;
62 XdpSession *m_session = nullptr;
63 char *m_sessionRestoreToken = nullptr;
64
65 guint m_sessionSignalId = 0;
66 guint m_selectionTransferSignalId = 0;
67 guint m_selectionOwnerChangedSignalId = 0;
68
70 guint m_sessionIteration = 0;
71};
72
73} // namespace deskflow
static int void FAR * data
Definition ArchNetworkWinsock.cpp:35
static fd_set FAR fd_set FAR fd_set FAR const struct timeval FAR * timeout
Definition ArchNetworkWinsock.cpp:40
Event queue interface.
Definition IEventQueue.h:29
Thread handle.
Definition Thread.h:33
Implementation of IPlatformScreen for X11.
Definition EiScreen.h:36
void claimClipboard() const
Definition PortalRemoteDesktop.cpp:222
PortalRemoteDesktop(EiScreen *screen, IEventQueue *events)
Definition PortalRemoteDesktop.cpp:21
~PortalRemoteDesktop()
Definition PortalRemoteDesktop.cpp:34
Definition DaemonApp.h:18