VirtualBox

source: vbox/trunk/include/VBox/GuestHost/SharedClipboard-x11.h@ 82968

Last change on this file since 82968 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 5.4 KB
Line 
1/** @file
2 * Shared Clipboard - Common X11 code.
3 */
4
5/*
6 * Copyright (C) 2006-2020 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef VBOX_INCLUDED_GuestHost_SharedClipboard_x11_h
27#define VBOX_INCLUDED_GuestHost_SharedClipboard_x11_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <X11/Intrinsic.h>
33
34#include <iprt/thread.h>
35
36#include <VBox/GuestHost/SharedClipboard.h>
37
38/**
39 * Enumeration for all clipboard formats which we support on X11.
40 */
41typedef enum _SHCLX11FMT
42{
43 SHCLX11FMT_INVALID = 0,
44 SHCLX11FMT_TARGETS,
45 SHCLX11FMT_TEXT, /* Treat this as UTF-8, but it may really be ascii */
46 SHCLX11FMT_UTF8,
47 SHCLX11FMT_BMP,
48 SHCLX11FMT_HTML
49#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
50 , SHCLX11FMT_URI_LIST
51#endif
52} SHCLX11FMT;
53
54/**
55 * The table maps X11 names to data formats
56 * and to the corresponding VBox clipboard formats.
57 */
58typedef struct SHCLX11FMTTABLE
59{
60 /** The X11 atom name of the format (several names can match one format). */
61 const char *pcszAtom;
62 /** The format corresponding to the name. */
63 SHCLX11FMT enmFmtX11;
64 /** The corresponding VBox clipboard format. */
65 SHCLFORMAT uFmtVBox;
66} SHCLX11FMTTABLE;
67
68#define NIL_CLIPX11FORMAT 0
69
70/** Defines an index of the X11 clipboad format table. */
71typedef unsigned SHCLX11FMTIDX;
72
73/**
74 * Structure for maintaining a Shared Clipboard context on X11 platforms.
75 */
76typedef struct _SHCLX11CTX
77{
78 /** Opaque data structure describing the front-end. */
79 PSHCLCONTEXT pFrontend;
80 /** Is an X server actually available? */
81 bool fHaveX11;
82 /** The X Toolkit application context structure */
83 XtAppContext appContext;
84
85 /** We have a separate thread to wait for window and clipboard events. */
86 RTTHREAD Thread;
87 /** The X Toolkit widget which we use as our clipboard client. It is never made visible. */
88 Widget pWidget;
89
90 /** Should we try to grab the clipboard on startup? */
91 bool fGrabClipboardOnStart;
92
93 /** The best text format X11 has to offer, as an index into the formats table. */
94 SHCLX11FMTIDX X11TextFormat;
95 /** The best bitmap format X11 has to offer, as an index into the formats table. */
96 SHCLX11FMTIDX X11BitmapFormat;
97 /** The best HTML format X11 has to offer, as an index into the formats table. */
98 SHCLX11FMTIDX X11HTMLFormat;
99#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
100 /** The best HTML format X11 has to offer, as an index into the formats table. */
101 SHCLX11FMTIDX X11URIListFormat;
102#endif
103 /** What kind of formats does VBox have to offer? */
104 SHCLFORMATS vboxFormats;
105 /** Cache of the last unicode data that we received. */
106 void *pvUnicodeCache;
107 /** Size of the unicode data in the cache. */
108 uint32_t cbUnicodeCache;
109 /** When we wish the clipboard to exit, we have to wake up the event
110 * loop. We do this by writing into a pipe. This end of the pipe is
111 * the end that another thread can write to. */
112 int wakeupPipeWrite;
113 /** The reader end of the pipe. */
114 int wakeupPipeRead;
115 /** A pointer to the XFixesSelectSelectionInput function. */
116 void (*fixesSelectInput)(Display *, Window, Atom, unsigned long);
117 /** The first XFixes event number. */
118 int fixesEventBase;
119 /** XtGetSelectionValue on some versions of libXt isn't re-entrant
120 * so block overlapping requests on this flag. */
121 bool fXtBusy;
122 /** If a request is blocked on the previous flag, set this flag to request
123 * an update later - the first callback should check and clear this flag
124 * before processing the callback event. */
125 bool fXtNeedsUpdate;
126} SHCLX11CTX, *PSHCLX11CTX;
127
128/** @name Shared Clipboard APIs for X11.
129 * @{
130 */
131int ShClX11Init(PSHCLX11CTX pCtx, PSHCLCONTEXT pParent, bool fHeadless);
132void ShClX11Destroy(PSHCLX11CTX pCtx);
133int ShClX11ThreadStart(PSHCLX11CTX pCtx, bool grab);
134int ShClX11ThreadStop(PSHCLX11CTX pCtx);
135int ShClX11ReportFormatsToX11(PSHCLX11CTX pCtx, SHCLFORMATS vboxFormats);
136int ShClX11ReadDataFromX11(PSHCLX11CTX pCtx, SHCLFORMATS vboxFormat, CLIPREADCBREQ *pReq);
137/** @} */
138
139/** @name Shared Clipboard callbacks exported by the X11 APIs.
140 * @{
141 */
142DECLCALLBACK(int) ShClX11RequestDataForX11Callback(SHCLCONTEXT *pCtx, SHCLFORMAT Format, void **ppv, uint32_t *pcb);
143DECLCALLBACK(void) ShClX11ReportFormatsCallback(SHCLCONTEXT *pCtx, SHCLFORMATS Formats);
144DECLCALLBACK(void) ShClX11RequestFromX11CompleteCallback(SHCLCONTEXT *pCtx, int rc, CLIPREADCBREQ *pReq, void *pv, uint32_t cb);
145/** @} */
146
147#endif /* !VBOX_INCLUDED_GuestHost_SharedClipboard_x11_h */
148
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette