1 /* 2 * Copyright (C) 2018, Matthias Clasen 3 * 4 * This file is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU Lesser General Public License as 6 * published by the Free Software Foundation, version 3.0 of the 7 * License. 8 * 9 * This file is distributed in the hope that it will be useful, but 10 * WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this program. If not, see <http://www.gnu.org/licenses/>. 16 * 17 * SPDX-License-Identifier: LGPL-3.0-only 18 */ 19 20 #pragma once 21 22 #include <libportal/types.h> 23 24 G_BEGIN_DECLS 25 26 #define XDP_TYPE_SESSION (xdp_session_get_type ()) 27 28 XDP_PUBLIC 29 G_DECLARE_FINAL_TYPE (XdpSession, xdp_session, XDP, SESSION, GObject) 30 31 /** 32 * XdpOutputType: 33 * @XDP_OUTPUT_MONITOR: allow selecting monitors 34 * @XDP_OUTPUT_WINDOW: allow selecting individual application windows 35 * @XDP_OUTPUT_VIRTUAL: allow creating new virtual displays 36 * 37 * Flags to specify what kind of sources to offer for a screencast session. 38 */ 39 typedef enum { 40 XDP_OUTPUT_MONITOR = 1 << 0, 41 XDP_OUTPUT_WINDOW = 1 << 1, 42 XDP_OUTPUT_VIRTUAL = 1 << 2, 43 } XdpOutputType; 44 45 /** 46 * XdpDeviceType: 47 * @XDP_DEVICE_NONE: no device 48 * @XDP_DEVICE_KEYBOARD: control the keyboard. 49 * @XDP_DEVICE_POINTER: control the pointer. 50 * @XDP_DEVICE_TOUCHSCREEN: control the touchscreen. 51 * 52 * Flags to specify what input devices to control for a remote desktop session. 53 */ 54 typedef enum { 55 XDP_DEVICE_NONE = 0, 56 XDP_DEVICE_KEYBOARD = 1 << 0, 57 XDP_DEVICE_POINTER = 1 << 1, 58 XDP_DEVICE_TOUCHSCREEN = 1 << 2 59 } XdpDeviceType; 60 61 /** 62 * XdpSessionType: 63 * @XDP_SESSION_SCREENCAST: a screencast session. 64 * @XDP_SESSION_REMOTE_DESKTOP: a remote desktop session. 65 * 66 * The type of a session. 67 */ 68 typedef enum { 69 XDP_SESSION_SCREENCAST, 70 XDP_SESSION_REMOTE_DESKTOP 71 } XdpSessionType; 72 73 /** 74 * XdpSessionState: 75 * @XDP_SESSION_INITIAL: the session has not been started. 76 * @XDP_SESSION_ACTIVE: the session is active. 77 * @XDP_SESSION_CLOSED: the session is no longer active. 78 * 79 * The state of a session. 80 */ 81 typedef enum { 82 XDP_SESSION_INITIAL, 83 XDP_SESSION_ACTIVE, 84 XDP_SESSION_CLOSED 85 } XdpSessionState; 86 87 /** 88 * XdpScreencastFlags: 89 * @XDP_SCREENCAST_FLAG_NONE: No options 90 * @XDP_SCREENCAST_FLAG_MULTIPLE: allow opening multiple streams 91 * 92 * Options for starting screen casts. 93 */ 94 typedef enum { 95 XDP_SCREENCAST_FLAG_NONE = 0, 96 XDP_SCREENCAST_FLAG_MULTIPLE = 1 << 0 97 } XdpScreencastFlags; 98 99 /** 100 * XdpCursorMode: 101 * @XDP_CURSOR_MODE_HIDDEN: no cursor 102 * @XDP_CURSOR_MODE_EMBEDDED: cursor is embedded on the stream 103 * @XDP_CURSOR_MODE_METADATA: cursor is sent as metadata of the stream 104 * 105 * Options for how the cursor is handled. 106 */ 107 typedef enum { 108 XDP_CURSOR_MODE_HIDDEN = 1 << 0, 109 XDP_CURSOR_MODE_EMBEDDED = 1 << 1, 110 XDP_CURSOR_MODE_METADATA = 1 << 2, 111 } XdpCursorMode; 112 113 /** 114 * XdpPersistMode: 115 * @XDP_PERSIST_MODE_NONE: do not persist 116 * @XDP_PERSIST_MODE_TRANSIENT: persist as long as the application is alive 117 * @XDP_PERSIST_MODE_PERSISTENT: persist until the user revokes this permission 118 * 119 * Options for how the screencast session should persist. 120 */ 121 typedef enum { 122 XDP_PERSIST_MODE_NONE, 123 XDP_PERSIST_MODE_TRANSIENT, 124 XDP_PERSIST_MODE_PERSISTENT, 125 } XdpPersistMode; 126 127 XDP_PUBLIC 128 void xdp_portal_create_screencast_session (XdpPortal *portal, 129 XdpOutputType outputs, 130 XdpScreencastFlags flags, 131 XdpCursorMode cursor_mode, 132 XdpPersistMode persist_mode, 133 const char *restore_token, 134 GCancellable *cancellable, 135 GAsyncReadyCallback callback, 136 gpointer data); 137 138 XDP_PUBLIC 139 XdpSession *xdp_portal_create_screencast_session_finish (XdpPortal *portal, 140 GAsyncResult *result, 141 GError **error); 142 143 /** 144 * XdpRemoteDesktopFlags: 145 * @XDP_REMOTE_DESKTOP_FLAG_NONE: No options 146 * @XDP_REMOTE_DESKTOP_FLAG_MULTIPLE: allow opening multiple streams 147 * 148 * Options for starting remote desktop sessions. 149 */ 150 typedef enum { 151 XDP_REMOTE_DESKTOP_FLAG_NONE = 0, 152 XDP_REMOTE_DESKTOP_FLAG_MULTIPLE = 1 << 0 153 } XdpRemoteDesktopFlags; 154 155 XDP_PUBLIC 156 void xdp_portal_create_remote_desktop_session (XdpPortal *portal, 157 XdpDeviceType devices, 158 XdpOutputType outputs, 159 XdpRemoteDesktopFlags flags, 160 XdpCursorMode cursor_mode, 161 GCancellable *cancellable, 162 GAsyncReadyCallback callback, 163 gpointer data); 164 165 XDP_PUBLIC 166 XdpSession *xdp_portal_create_remote_desktop_session_finish (XdpPortal *portal, 167 GAsyncResult *result, 168 GError **error); 169 170 XDP_PUBLIC 171 void xdp_session_start (XdpSession *session, 172 XdpParent *parent, 173 GCancellable *cancellable, 174 GAsyncReadyCallback callback, 175 gpointer data); 176 177 XDP_PUBLIC 178 gboolean xdp_session_start_finish (XdpSession *session, 179 GAsyncResult *result, 180 GError **error); 181 182 XDP_PUBLIC 183 void xdp_session_close (XdpSession *session); 184 185 XDP_PUBLIC 186 int xdp_session_open_pipewire_remote (XdpSession *session); 187 188 XDP_PUBLIC 189 XdpSessionType xdp_session_get_session_type (XdpSession *session); 190 191 XDP_PUBLIC 192 XdpSessionState xdp_session_get_session_state (XdpSession *session); 193 194 XDP_PUBLIC 195 XdpDeviceType xdp_session_get_devices (XdpSession *session); 196 197 XDP_PUBLIC 198 GVariant * xdp_session_get_streams (XdpSession *session); 199 200 XDP_PUBLIC 201 void xdp_session_pointer_motion (XdpSession *session, 202 double dx, 203 double dy); 204 205 XDP_PUBLIC 206 void xdp_session_pointer_position (XdpSession *session, 207 guint stream, 208 double x, 209 double y); 210 /** 211 * XdpButtonState: 212 * @XDP_BUTTON_RELEASED: the button is down 213 * @XDP_BUTTON_PRESSED: the button is up 214 * 215 * The XdpButtonState enumeration is used to describe 216 * the state of buttons. 217 */ 218 typedef enum { 219 XDP_BUTTON_RELEASED = 0, 220 XDP_BUTTON_PRESSED = 1 221 } XdpButtonState; 222 223 XDP_PUBLIC 224 void xdp_session_pointer_button (XdpSession *session, 225 int button, 226 XdpButtonState state); 227 228 XDP_PUBLIC 229 void xdp_session_pointer_axis (XdpSession *session, 230 gboolean finish, 231 double dx, 232 double dy); 233 234 /** 235 * XdpDiscreteAxis: 236 * @XDP_AXIS_HORIZONTAL_SCROLL: the horizontal scroll axis 237 * @XDP_AXIS_VERTICAL_SCROLL: the horizontal scroll axis 238 * 239 * The XdpDiscreteAxis enumeration is used to describe 240 * the discrete scroll axes. 241 */ 242 typedef enum { 243 XDP_AXIS_HORIZONTAL_SCROLL = 0, 244 XDP_AXIS_VERTICAL_SCROLL = 1 245 } XdpDiscreteAxis; 246 247 XDP_PUBLIC 248 void xdp_session_pointer_axis_discrete (XdpSession *session, 249 XdpDiscreteAxis axis, 250 int steps); 251 252 /** 253 * XdpKeyState: 254 * @XDP_KEY_RELEASED: the key is down 255 * @XDP_KEY_PRESSED: the key is up 256 * 257 * The XdpKeyState enumeration is used to describe 258 * the state of keys. 259 */ 260 typedef enum { 261 XDP_KEY_RELEASED = 0, 262 XDP_KEY_PRESSED = 1 263 } XdpKeyState; 264 265 XDP_PUBLIC 266 void xdp_session_keyboard_key (XdpSession *session, 267 gboolean keysym, 268 int key, 269 XdpKeyState state); 270 271 XDP_PUBLIC 272 void xdp_session_touch_down (XdpSession *session, 273 guint stream, 274 guint slot, 275 double x, 276 double y); 277 278 XDP_PUBLIC 279 void xdp_session_touch_position (XdpSession *session, 280 guint stream, 281 guint slot, 282 double x, 283 double y); 284 285 XDP_PUBLIC 286 void xdp_session_touch_up (XdpSession *session, 287 guint slot); 288 289 290 XDP_PUBLIC 291 XdpPersistMode xdp_session_get_persist_mode (XdpSession *session); 292 293 XDP_PUBLIC 294 char *xdp_session_get_restore_token (XdpSession *session); 295 296 G_END_DECLS 297