VirtualBox

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

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

Additions/X11: first attempt at dynamic guest resizing

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