VirtualBox

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

Last change on this file since 86871 was 86871, checked in by vboxsync, 4 years ago

Additions/VBoxClient: Big revamp of the internal service handling and termination fixes. A service now runs as part of a worker thread, while the main thread is used for initialization / shutdown and signal handling.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 2.8 KB
Line 
1/* $Id: seamless.h 86871 2020-11-12 10:15:18Z 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-2020 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19#ifndef GA_INCLUDED_SRC_x11_VBoxClient_seamless_h
20#define GA_INCLUDED_SRC_x11_VBoxClient_seamless_h
21#ifndef RT_WITHOUT_PRAGMA_ONCE
22# pragma once
23#endif
24
25#include <iprt/thread.h>
26
27#include <VBox/log.h>
28#include <VBox/VBoxGuestLib.h> /* for the R3 guest library functions */
29
30#include "seamless-x11.h"
31
32/**
33 * Interface to the host
34 */
35class SeamlessMain
36{
37private:
38 // We don't want a copy constructor or assignment operator
39 SeamlessMain(const SeamlessMain&);
40 SeamlessMain& operator=(const SeamlessMain&);
41
42 /** X11 event monitor object */
43 SeamlessX11 mX11Monitor;
44
45 /** Thread to start and stop when we enter and leave seamless mode which
46 * monitors X11 windows in the guest. */
47 RTTHREAD mX11MonitorThread;
48 /** Should the X11 monitor thread be stopping? */
49 volatile bool mX11MonitorThreadStopping;
50
51 /** The current seamless mode we are in. */
52 VMMDevSeamlessMode mMode;
53 /** Is the service currently paused? */
54 volatile bool mfPaused;
55
56 /**
57 * Waits for a seamless state change events from the host and dispatch it. This is
58 * meant to be called by the host event monitor thread exclusively.
59 *
60 * @returns IRPT return code.
61 */
62 int nextStateChangeEvent(void);
63
64 /** Thread function to monitor X11 window configuration changes. */
65 static DECLCALLBACK(int) x11MonitorThread(RTTHREAD self, void *pvUser);
66
67 /** Helper to start the X11 monitor thread. */
68 int startX11MonitorThread(void);
69
70 /** Helper to stop the X11 monitor thread again. */
71 int stopX11MonitorThread(void);
72
73 /** Is the service currently actively monitoring X11 windows? */
74 bool isX11MonitorThreadRunning()
75 {
76 return mX11MonitorThread != NIL_RTTHREAD;
77 }
78
79public:
80 SeamlessMain(void);
81 virtual ~SeamlessMain();
82#ifdef RT_NEED_NEW_AND_DELETE
83 RTMEM_IMPLEMENT_NEW_AND_DELETE();
84#endif
85
86 /** @copydoc VBCLSERVICE::pfnInit */
87 int init(void);
88
89 /** @copydoc VBCLSERVICE::pfnWorker */
90 int worker(bool volatile *pfShutdown);
91
92 /** @copydoc VBCLSERVICE::pfnStop */
93 void stop(void);
94
95 /** @copydoc VBCLSERVICE::pfnTerm */
96 int term(void);
97};
98
99#endif /* !GA_INCLUDED_SRC_x11_VBoxClient_seamless_h */
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