VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/xclient/displaychange.h@ 7449

Last change on this file since 7449 was 7449, checked in by vboxsync, 17 years ago

Additions/x11: added flow logging statements to the VBoxClient code

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.7 KB
Line 
1/** @file
2 *
3 * Guest client: display auto-resize.
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef __Additions_client_display_change_h
19# define __Additions_client_display_change_h
20
21#include <VBox/log.h>
22#include <VBox/VBoxGuest.h> /* for the R3 guest library functions */
23
24#include "thread.h" /* for VBoxGuestThread */
25
26#if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
27
28#include <X11/Xlib.h>
29
30/**
31 * Display change request monitor thread function
32 */
33class VBoxGuestDisplayChangeThreadX11 : public VBoxGuestThreadFunction
34{
35private:
36 // Copying or assigning a thread object is not sensible
37 VBoxGuestDisplayChangeThreadX11(const VBoxGuestDisplayChangeThreadX11&);
38 VBoxGuestDisplayChangeThreadX11& operator=(const VBoxGuestDisplayChangeThreadX11&);
39
40 // Private member variables
41 /** Have we been initialised yet? */
42 bool mInit;
43 /** The thread object running us. */
44 VBoxGuestThread *mThread;
45public:
46 VBoxGuestDisplayChangeThreadX11()
47 {
48 mInit = false;
49 }
50 ~VBoxGuestDisplayChangeThreadX11()
51 {
52 LogFlowThisFunc(("\n"));
53 if (mInit)
54 {
55 try
56 {
57 uninit();
58 }
59 catch(...) {}
60 }
61 LogFlowThisFunc(("returning\n"));
62 }
63 /**
64 * Initialise the class and check that the guest supports dynamic resizing.
65 * @returns iprt status value
66 */
67 int init(void);
68 /**
69 * Uninitialise the class
70 */
71 void uninit(void);
72 /**
73 * The actual thread function.
74 *
75 * @returns iprt status code as thread return value
76 * @param pParent the VBoxGuestThread running this thread function
77 */
78 virtual int threadFunction(VBoxGuestThread *pThread);
79 /**
80 * Send a signal to the thread function that it should exit
81 */
82 virtual void stop(void);
83};
84
85typedef VBoxGuestDisplayChangeThreadX11 VBoxGuestDisplayChangeThread;
86#else
87/* Just in case anyone else ever uses this */
88# error Port me!
89#endif
90
91/**
92 * Monitor for and dispatch display change events
93 */
94class VBoxGuestDisplayChangeMonitor
95{
96private:
97 // No copying or assignment
98 VBoxGuestDisplayChangeMonitor(const VBoxGuestDisplayChangeMonitor&);
99 VBoxGuestDisplayChangeMonitor& operator=(const VBoxGuestDisplayChangeMonitor&);
100
101 // Private member variables
102 /** Our monitor thread function */
103 VBoxGuestDisplayChangeThread mThreadFunction;
104 /** And the thread for the thread function */
105 VBoxGuestThread mThread;
106 /** Are we initialised? */
107 bool mInit;
108public:
109 /**
110 * Initialise the class.
111 * @returns iprt status value
112 */
113 int init(void);
114 /**
115 * Uninitialise the class.
116 * @param cMillies how long to wait for the thread to stop
117 */
118 void uninit(unsigned cMillies = RT_INDEFINITE_WAIT);
119 VBoxGuestDisplayChangeMonitor() : mThread(&mThreadFunction, 0, RTTHREADTYPE_MSG_PUMP,
120 RTTHREADFLAGS_WAITABLE, "Display change")
121 { mInit = false; }
122 ~VBoxGuestDisplayChangeMonitor()
123 {
124 LogFlowThisFunc(("\n"));
125 try
126 {
127 uninit(2000);
128 }
129 catch(...) {}
130 LogFlowThisFunc(("returning\n"));
131 }
132};
133
134#endif /* __Additions_display_change_h not defined */
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