VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/VBoxClient/clipboard.h

Last change on this file was 103365, checked in by vboxsync, 3 months ago

Shared Clipboard/Additions: Removed lots of code duplication for reading clipboard data from the host (partly introduced by r159772).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1/** $Id: clipboard.h 103365 2024-02-14 18:13:38Z vboxsync $ */
2/** @file
3 * Guest Additions - X11 Shared Clipboard - Main header.
4 */
5
6/*
7 * Copyright (C) 2020-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef GA_INCLUDED_SRC_x11_VBoxClient_clipboard_h
29#define GA_INCLUDED_SRC_x11_VBoxClient_clipboard_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include <VBox/GuestHost/SharedClipboard-x11.h>
35#include <VBox/VBoxGuestLib.h>
36#include <iprt/thread.h>
37
38/**
39 * Callback to notify guest that host has new clipboard data in the specified formats.
40 *
41 * @returns VBox status code.
42 * @param fFormats The formats available.
43 * Optional and can be NULL.
44 */
45typedef DECLCALLBACKTYPE(int, FNHOSTCLIPREPORTFMTS, (SHCLFORMATS fFormats));
46typedef FNHOSTCLIPREPORTFMTS *PFNHOSTCLIPREPORTFMTS;
47
48/**
49 * Callback to notify guest that host wants to read clipboard data in specified format.
50 *
51 * @returns VBox status code.
52 * @param uFmt The format in which the data should be read
53 * (VBOX_SHCL_FMT_XXX).
54 */
55typedef DECLCALLBACKTYPE(int, FNHOSTCLIPREAD, (SHCLFORMAT uFmt));
56typedef FNHOSTCLIPREAD *PFNHOSTCLIPREAD;
57
58
59/**
60 * Struct keeping am X11 Shared Clipboard context.
61 */
62struct SHCLCONTEXT
63{
64 /** Client command context */
65 VBGLR3SHCLCMDCTX CmdCtx;
66#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
67 /** Associated transfer data. */
68 SHCLTRANSFERCTX TransferCtx;
69#endif
70 /** Event source for waiting for X11 request responses in the VbglR3 clipboard event loop. */
71 SHCLEVENTSOURCE EventSrc;
72 union
73 {
74 /** X11 clipboard context. */
75 SHCLX11CTX X11;
76 /** @todo Wayland clipboard context goes here. */
77 /* SHCLWAYLANDCTX Wl; */
78 };
79};
80
81/** Shared Clipboard context.
82 * Only one context is supported at a time for now. */
83extern SHCLCONTEXT g_Ctx;
84
85/**
86 * Create thread and wait until it started.
87 *
88 * @returns IPRT status code.
89 * @param pThread Pointer to thread data.
90 * @param pfnThread Pointer to thread main loop function.
91 * @param pszName Thread name.
92 * @param pvUser User data.
93 */
94RTDECL(int) VBClClipboardThreadStart(PRTTHREAD pThread, PFNRTTHREAD pfnThread, const char *pszName, void *pvUser);
95
96/**
97 * Read and process one event from the host clipboard service.
98 *
99 * @returns VBox status code.
100 * @param pCtx Host Shared Clipboard service connection context.
101 * @param pfnHGClipReport A callback to notify guest about new content in host clipboard.
102 * @param pfnGHClipRead A callback to notify guest when host requests guest clipboard content.
103 */
104RTDECL(int) VBClClipboardReadHostEvent(PSHCLCONTEXT pCtx, const PFNHOSTCLIPREPORTFMTS pfnHGClipReport,
105 const PFNHOSTCLIPREAD pfnGHClipRead);
106
107/**
108 * Read entire host clipboard buffer in given format.
109 *
110 * This function will allocate clipboard buffer of necessary size and
111 * place host clipboard content into it. Buffer needs to be freed by caller.
112 *
113 * @returns VBox status code.
114 * @param pCtx Host Shared Clipboard service connection context.
115 * @param uFmt Format in which data should be read.
116 * @param ppvData Newly allocated output buffer (should be freed by caller).
117 * @param pcbData Output buffer size.
118 */
119RTDECL(int) VBClClipboardReadHostClipboard(PVBGLR3SHCLCMDCTX pCtx, SHCLFORMAT uFmt, void **ppvData, uint32_t *pcbData);
120
121#endif /* !GA_INCLUDED_SRC_x11_VBoxClient_clipboard_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use