VirtualBox

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

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

Shared Clipboard/X11: More cleanup.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 5.0 KB
Line 
1/** @file
2 * Shared Clipboard - Common X11 code.
3 */
4
5/*
6 * Copyright (C) 2006-2019 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/** Defines an index of the X11 clipboad format table. */
55typedef unsigned SHCLX11FMTIDX;
56
57/** Prototype for the implementation-specfic Shared Clipboard context. */
58struct _SHCLCONTEXT;
59typedef SHCLCONTEXT _SHCLCONTEXT;
60
61/**
62 * Structure for maintaining a Shared Clipboard context on X11 platforms.
63 */
64typedef struct _SHCLX11CTX
65{
66 /** Opaque data structure describing the front-end. */
67 PSHCLCONTEXT pFrontend;
68 /** Is an X server actually available? */
69 bool fHaveX11;
70 /** The X Toolkit application context structure */
71 XtAppContext appContext;
72
73 /** We have a separate thread to wait for window and clipboard events. */
74 RTTHREAD Thread;
75 /** The X Toolkit widget which we use as our clipboard client. It is never made visible. */
76 Widget pWidget;
77
78 /** Should we try to grab the clipboard on startup? */
79 bool fGrabClipboardOnStart;
80
81 /** The best text format X11 has to offer, as an index into the formats table. */
82 SHCLX11FMTIDX X11TextFormat;
83 /** The best bitmap format X11 has to offer, as an index into the formats table. */
84 SHCLX11FMTIDX X11BitmapFormat;
85 /** The best HTML format X11 has to offer, as an index into the formats table. */
86 SHCLX11FMTIDX X11HTMLFormat;
87#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
88 /** The best HTML format X11 has to offer, as an index into the formats table. */
89 SHCLX11FMTIDX X11URIListFormat;
90#endif
91 /** What kind of formats does VBox have to offer? */
92 SHCLFORMATS vboxFormats;
93 /** Cache of the last unicode data that we received. */
94 void *pvUnicodeCache;
95 /** Size of the unicode data in the cache. */
96 uint32_t cbUnicodeCache;
97 /** When we wish the clipboard to exit, we have to wake up the event
98 * loop. We do this by writing into a pipe. This end of the pipe is
99 * the end that another thread can write to. */
100 int wakeupPipeWrite;
101 /** The reader end of the pipe. */
102 int wakeupPipeRead;
103 /** A pointer to the XFixesSelectSelectionInput function. */
104 void (*fixesSelectInput)(Display *, Window, Atom, unsigned long);
105 /** The first XFixes event number. */
106 int fixesEventBase;
107 /** XtGetSelectionValue on some versions of libXt isn't re-entrant
108 * so block overlapping requests on this flag. */
109 bool fXtBusy;
110 /** If a request is blocked on the previous flag, set this flag to request
111 * an update later - the first callback should check and clear this flag
112 * before processing the callback event. */
113 bool fXtNeedsUpdate;
114} SHCLX11CTX, *PSHCLX11CTX;
115
116/** @name Shared Clipboard APIs for X11.
117 * @{
118 */
119int ShClX11Init(PSHCLX11CTX pCtx, PSHCLCONTEXT pParent, bool fHeadless);
120void ShClX11Destroy(PSHCLX11CTX pCtx);
121int ShClX11ThreadStart(PSHCLX11CTX pCtx, bool grab);
122int ShClX11ThreadStop(PSHCLX11CTX pCtx);
123int ShClX11ReportFormatsToX11(PSHCLX11CTX pCtx, SHCLFORMATS vboxFormats);
124int ShClX11ReadDataFromX11(PSHCLX11CTX pCtx, SHCLFORMATS vboxFormat, CLIPREADCBREQ *pReq);
125/** @} */
126
127/** @name Shared Clipboard callbacks exported by the X11 APIs.
128 * @{
129 */
130DECLCALLBACK(int) ShClX11RequestDataForX11Callback(SHCLCONTEXT *pCtx, SHCLFORMAT Format, void **ppv, uint32_t *pcb);
131DECLCALLBACK(void) ShClX11ReportFormatsCallback(SHCLCONTEXT *pCtx, SHCLFORMATS Formats);
132DECLCALLBACK(void) ShClX11RequestFromX11CompleteCallback(SHCLCONTEXT *pCtx, int rc, CLIPREADCBREQ *pReq, void *pv, uint32_t cb);
133/** @} */
134
135#endif /* !VBOX_INCLUDED_GuestHost_SharedClipboard_x11_h */
136
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