VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/VBoxClient/draganddrop.h@ 99600

Last change on this file since 99600 was 99599, checked in by vboxsync, 19 months ago

Guest Additions/VBoxClient: Moved the X11-specific code for drag'n drop into an own submodule and using the actual service as a (runtime) wrapper (for also the Wayland-specific code later) [build fix]. bugref:10427

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1/** $Id: draganddrop.h 99599 2023-05-04 10:09:59Z vboxsync $ */
2/** @file
3 * Guest Additions - VBoxClient drag'n drop - Main header.
4 */
5
6/*
7 * Copyright (C) 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_draganddrop_h
29#define GA_INCLUDED_SRC_x11_VBoxClient_draganddrop_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include <X11/Xlib.h>
35
36#include <iprt/cpp/mtlist.h>
37
38#include <VBox/VBoxGuestLib.h>
39
40class VBClX11DnDInst;
41
42/**
43 * Structure for storing new drag'n drop events and HGCM messages
44 * into a single event queue.
45 */
46typedef struct VBCLDNDEVENT
47{
48 enum DnDEventType
49 {
50 /** Unknown event, do not use. */
51 DnDEventType_Unknown = 0,
52 /** VBGLR3DNDEVENT event. */
53 DnDEventType_HGCM,
54 /** X11 event. */
55 DnDEventType_X11,
56 /** Blow the type up to 32-bit. */
57 DnDEventType_32BIT_HACK = 0x7fffffff
58 };
59 /** Event type. */
60 DnDEventType enmType;
61 union
62 {
63 PVBGLR3DNDEVENT hgcm;
64 XEvent x11;
65 };
66#ifdef IN_GUEST
67 RTMEM_IMPLEMENT_NEW_AND_DELETE();
68#endif
69} VBCLDNDEVENT;
70/** Pointer to a drag'n drop event. */
71typedef VBCLDNDEVENT *PDNDEVENT;
72
73/**
74 * Interface class for a drag'n drop service implementation.
75 */
76class VBClDnDSvc
77{
78protected:
79
80 /* Note: Constructor must not throw, as we don't have exception handling on the guest side. */
81 VBClDnDSvc(void) { }
82
83public:
84
85 virtual ~VBClDnDSvc(void) { }
86
87public:
88
89 virtual int init(void) { return VINF_SUCCESS; }
90 virtual int worker(bool volatile *pfShutdown) { RT_NOREF(pfShutdown); return VINF_SUCCESS; }
91 virtual void reset(void) { }
92 virtual void stop(void) { }
93 virtual int term(void) { return VINF_SUCCESS; }
94
95#ifdef IN_GUEST
96 RTMEM_IMPLEMENT_NEW_AND_DELETE();
97#endif
98};
99
100/**
101 * Service class which implements drag'n drop for X11.
102 */
103class VBClX11DnDSvc : public VBClDnDSvc
104{
105public:
106 VBClX11DnDSvc(void)
107 : m_pDisplay(NULL)
108 , m_hHGCMThread(NIL_RTTHREAD)
109 , m_hX11Thread(NIL_RTTHREAD)
110 , m_hEventSem(NIL_RTSEMEVENT)
111 , m_pCurDnD(NULL)
112 , m_fStop(false)
113 {
114 RT_ZERO(m_dndCtx);
115 }
116
117 virtual int init(void);
118 virtual int worker(bool volatile *pfShutdown);
119 virtual void reset(void);
120 virtual void stop(void);
121 virtual int term(void);
122
123private:
124
125 static DECLCALLBACK(int) hgcmEventThread(RTTHREAD hThread, void *pvUser);
126 static DECLCALLBACK(int) x11EventThread(RTTHREAD hThread, void *pvUser);
127
128 /* Private member vars */
129 Display *m_pDisplay;
130 /** Our (thread-safe) event queue with mixed events (DnD HGCM / X11). */
131 RTCMTList<VBCLDNDEVENT> m_eventQueue;
132 /** Critical section for providing serialized access to list
133 * event queue's contents. */
134 RTCRITSECT m_eventQueueCS;
135 /** Thread handle for the HGCM message pumping thread. */
136 RTTHREAD m_hHGCMThread;
137 /** Thread handle for the X11 message pumping thread. */
138 RTTHREAD m_hX11Thread;
139 /** This service' DnD command context. */
140 VBGLR3GUESTDNDCMDCTX m_dndCtx;
141 /** Event semaphore for new DnD events. */
142 RTSEMEVENT m_hEventSem;
143 /** Pointer to the allocated DnD instance.
144 Currently we only support and handle one instance at a time. */
145 VBClX11DnDInst *m_pCurDnD;
146 /** Stop indicator flag to signal the thread that it should shut down. */
147 bool m_fStop;
148
149 friend class VBClX11DnDInst;
150};
151#endif /* !GA_INCLUDED_SRC_x11_VBoxClient_draganddrop_h */
152
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