VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/VBoxClient/displaychange.h@ 18320

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

The Big Sun Rebranding Header Change

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.9 KB
Line 
1/** @file
2 *
3 * Guest client: display auto-resize.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#ifndef __Additions_client_display_change_h
23# define __Additions_client_display_change_h
24
25#include <VBox/log.h>
26#include <VBox/VBoxGuest.h> /* for the R3 guest library functions */
27
28#include "thread.h" /* for VBoxGuestThread */
29
30#if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
31
32#include <X11/Xlib.h>
33
34/**
35 * Display change request monitor thread function
36 */
37class VBoxGuestDisplayChangeThreadX11 : public VBoxGuestThreadFunction
38{
39private:
40 // Copying or assigning a thread object is not sensible
41 VBoxGuestDisplayChangeThreadX11(const VBoxGuestDisplayChangeThreadX11&);
42 VBoxGuestDisplayChangeThreadX11& operator=(const VBoxGuestDisplayChangeThreadX11&);
43
44 // Private member variables
45 /** Have we been initialised yet? */
46 bool mInit;
47 /** The thread object running us. */
48 VBoxGuestThread *mThread;
49public:
50 VBoxGuestDisplayChangeThreadX11()
51 {
52 mInit = false;
53 }
54 ~VBoxGuestDisplayChangeThreadX11()
55 {
56 LogFlowThisFunc(("\n"));
57 if (mInit)
58 {
59 try
60 {
61 uninit();
62 }
63 catch(...) {}
64 }
65 LogFlowThisFunc(("returning\n"));
66 }
67 /**
68 * Initialise the class and check that the guest supports dynamic resizing.
69 * @returns iprt status value
70 */
71 int init(void);
72 /**
73 * Uninitialise the class
74 */
75 void uninit(void);
76 /**
77 * The actual thread function.
78 *
79 * @returns iprt status code as thread return value
80 * @param pParent the VBoxGuestThread running this thread function
81 */
82 virtual int threadFunction(VBoxGuestThread *pThread);
83 /**
84 * Send a signal to the thread function that it should exit
85 */
86 virtual void stop(void);
87};
88
89typedef VBoxGuestDisplayChangeThreadX11 VBoxGuestDisplayChangeThread;
90#else
91/* Just in case anyone else ever uses this */
92# error Port me!
93#endif
94
95/**
96 * Monitor for and dispatch display change events
97 */
98class VBoxGuestDisplayChangeMonitor
99{
100private:
101 // No copying or assignment
102 VBoxGuestDisplayChangeMonitor(const VBoxGuestDisplayChangeMonitor&);
103 VBoxGuestDisplayChangeMonitor& operator=(const VBoxGuestDisplayChangeMonitor&);
104
105 // Private member variables
106 /** Our monitor thread function */
107 VBoxGuestDisplayChangeThread mThreadFunction;
108 /** And the thread for the thread function */
109 VBoxGuestThread mThread;
110 /** Are we initialised? */
111 bool mInit;
112public:
113 /**
114 * Initialise the class.
115 * @returns iprt status value
116 */
117 int init(void);
118 /**
119 * Uninitialise the class.
120 * @param cMillies how long to wait for the thread to stop
121 */
122 void uninit(unsigned cMillies = RT_INDEFINITE_WAIT);
123 VBoxGuestDisplayChangeMonitor() : mThread(&mThreadFunction, 0, RTTHREADTYPE_MSG_PUMP,
124 RTTHREADFLAGS_WAITABLE, "Display change")
125 { mInit = false; }
126 ~VBoxGuestDisplayChangeMonitor()
127 {
128 LogFlowThisFunc(("\n"));
129 try
130 {
131 uninit(2000);
132 }
133 catch(...) {}
134 LogFlowThisFunc(("returning\n"));
135 }
136};
137
138#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