VirtualBox

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

Last change on this file was 99601, checked in by vboxsync, 12 months ago

Guest Additions/VBoxClient: Moved the X11-specific code for seamless mode 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 Id Revision
File size: 4.0 KB
Line 
1/* $Id: seamless.h 99601 2023-05-04 10:43:08Z vboxsync $ */
2/** @file
3 * X11 Guest client - seamless mode, missing proper description while using the
4 * potentially confusing word 'host'.
5 */
6
7/*
8 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
9 *
10 * This file is part of VirtualBox base platform packages, as
11 * available from https://www.virtualbox.org.
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation, in version 3 of the
16 * License.
17 *
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, see <https://www.gnu.org/licenses>.
25 *
26 * SPDX-License-Identifier: GPL-3.0-only
27 */
28
29#ifndef GA_INCLUDED_SRC_x11_VBoxClient_seamless_h
30#define GA_INCLUDED_SRC_x11_VBoxClient_seamless_h
31#ifndef RT_WITHOUT_PRAGMA_ONCE
32# pragma once
33#endif
34
35#include <iprt/asm.h>
36#include <iprt/thread.h>
37
38#include <VBox/log.h>
39#include <VBox/VBoxGuestLib.h> /* for the R3 guest library functions */
40
41#include "seamless-x11.h"
42
43/** @name Generic seamless functions
44 * @{ */
45void VBClSeamlessSendRegionUpdate(RTRECT *pRects, size_t cRects);
46/** @} */
47
48/**
49 * Interface class for seamless mode service implementation.
50 */
51class VBClSeamlessSvc
52{
53protected:
54
55 /* Note: Constructor must not throw, as we don't have exception handling on the guest side. */
56 VBClSeamlessSvc(void) { }
57
58public:
59
60 virtual ~VBClSeamlessSvc(void) { }
61
62public:
63
64 virtual int init(void) { return VINF_SUCCESS; }
65 virtual int worker(bool volatile *pfShutdown) { RT_NOREF(pfShutdown); return VINF_SUCCESS; }
66 virtual void reset(void) { }
67 virtual void stop(void) { }
68 virtual int term(void) { return VINF_SUCCESS; }
69
70#ifdef IN_GUEST
71 RTMEM_IMPLEMENT_NEW_AND_DELETE();
72#endif
73};
74
75/**
76 * Service class which implements seamless mode for X11.
77 */
78class VBClX11SeamlessSvc : public VBClSeamlessSvc
79{
80public:
81 VBClX11SeamlessSvc(void);
82
83 virtual ~VBClX11SeamlessSvc();
84
85public:
86
87 /** @copydoc VBCLSERVICE::pfnInit */
88 virtual int init(void);
89
90 /** @copydoc VBCLSERVICE::pfnWorker */
91 virtual int worker(bool volatile *pfShutdown);
92
93 /** @copydoc VBCLSERVICE::pfnStop */
94 virtual void stop(void);
95
96 /** @copydoc VBCLSERVICE::pfnTerm */
97 virtual int term(void);
98
99private:
100 /** Note: We don't want a copy constructor or assignment operator. */
101 VBClX11SeamlessSvc(const VBClX11SeamlessSvc&);
102 VBClX11SeamlessSvc& operator=(const VBClX11SeamlessSvc&);
103
104 /** X11 event monitor object. */
105 VBClX11SeamlessMonitor mX11Monitor;
106
107 /** Thread to start and stop when we enter and leave seamless mode which
108 * monitors X11 windows in the guest. */
109 RTTHREAD mX11MonitorThread;
110 /** Should the X11 monitor thread be stopping? */
111 volatile bool mX11MonitorThreadStopping;
112
113 /** The current seamless mode we are in. */
114 VMMDevSeamlessMode mMode;
115 /** Is the service currently paused? */
116 volatile bool mfPaused;
117
118 /**
119 * Waits for a seamless state change events from the host and dispatch it. This is
120 * meant to be called by the host event monitor thread exclusively.
121 *
122 * @returns IRPT return code.
123 */
124 int nextStateChangeEvent(void);
125
126 /** Thread function to monitor X11 window configuration changes. */
127 static DECLCALLBACK(int) x11MonitorThread(RTTHREAD self, void *pvUser);
128
129 /** Helper to start the X11 monitor thread. */
130 int startX11MonitorThread(void);
131
132 /** Helper to stop the X11 monitor thread again. */
133 int stopX11MonitorThread(void);
134
135 /** Is the service currently actively monitoring X11 windows? */
136 bool isX11MonitorThreadRunning()
137 {
138 return mX11MonitorThread != NIL_RTTHREAD;
139 }
140};
141
142#endif /* !GA_INCLUDED_SRC_x11_VBoxClient_seamless_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use