VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox4/include/VBoxConsoleView.h@ 7463

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

Frontends/VirtualBox: support VideoModeSupported guest request, this time using the right threads

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.6 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * VBoxConsoleView class declaration
5 */
6
7/*
8 * Copyright (C) 2006-2007 innotek GmbH
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.215389.xyz. 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 __VBoxConsoleView_h__
20#define __VBoxConsoleView_h__
21
22#include "COMDefs.h"
23
24#include "VBoxDefs.h"
25#include "VBoxGlobalSettings.h"
26
27/* Qt includes */
28#include <q3scrollview.h>
29
30#if defined (Q_WS_PM)
31#include "src/os2/VBoxHlp.h"
32#define UM_PREACCEL_CHAR WM_USER
33#endif
34
35#if defined (Q_WS_MAC)
36# include <Carbon/Carbon.h>
37# include "DarwinCursor.h"
38#endif
39
40class VBoxConsoleWnd;
41class MousePointerChangeEvent;
42class VBoxFrameBuffer;
43
44class QPainter;
45class QLabel;
46class QMenuData;
47
48class VBoxConsoleView : public Q3ScrollView
49{
50 Q_OBJECT
51
52public:
53
54 enum {
55 MouseCaptured = 0x01,
56 MouseAbsolute = 0x02,
57 MouseAbsoluteDisabled = 0x04,
58 MouseNeedsHostCursor = 0x08,
59 KeyboardCaptured = 0x01,
60 HostKeyPressed = 0x02,
61 };
62
63 VBoxConsoleView (VBoxConsoleWnd *mainWnd,
64 const CConsole &console,
65 VBoxDefs::RenderMode rm,
66 QWidget *parent = 0, const char *name = 0, Qt::WFlags f = 0);
67 ~VBoxConsoleView();
68
69 QSize sizeHint() const;
70
71 void attach();
72 void detach();
73 void refresh() { doRefresh(); }
74 void normalizeGeometry (bool adjustPosition = false);
75
76 CConsole &console() { return mConsole; }
77
78 bool pause (bool on);
79
80 void setMouseIntegrationEnabled (bool enabled);
81
82 bool isMouseAbsolute() const { return mMouseAbsolute; }
83
84 void setAutoresizeGuest (bool on);
85
86 void onFullscreenChange (bool on);
87
88 void onViewOpened();
89
90 void fixModifierState (LONG *codes, uint *count);
91
92 void toggleFSMode();
93
94 void setIgnoreMainwndResize (bool aYes) { mIgnoreMainwndResize = aYes; }
95
96 QRect getDesktopGeometry();
97
98signals:
99
100 void keyboardStateChanged (int state);
101 void mouseStateChanged (int state);
102 void machineStateChanged (KMachineState state);
103 void additionsStateChanged (const QString &, bool, bool);
104 void mediaChanged (VBoxDefs::DiskType aType);
105 void networkStateChange();
106 void usbStateChange();
107 void sharedFoldersChanged();
108 void resizeHintDone();
109
110protected:
111
112 // events
113 bool event (QEvent *e);
114 bool eventFilter (QObject *watched, QEvent *e);
115
116#if defined(Q_WS_WIN32)
117 bool winLowKeyboardEvent (UINT msg, const KBDLLHOOKSTRUCT &event);
118 bool winEvent (MSG *msg);
119#elif defined(Q_WS_PM)
120 bool pmEvent (QMSG *aMsg);
121#elif defined(Q_WS_X11)
122 bool x11Event (XEvent *event);
123#elif defined(Q_WS_MAC)
124 bool darwinKeyboardEvent (EventRef inEvent);
125 void darwinGrabKeyboardEvents (bool fGrab);
126#endif
127
128private:
129
130 /** Flags for keyEvent(). */
131 enum {
132 KeyExtended = 0x01,
133 KeyPressed = 0x02,
134 KeyPause = 0x04,
135 KeyPrint = 0x08,
136 };
137
138 void focusEvent (bool aHasFocus, bool aReleaseHostKey = true);
139 bool keyEvent (int aKey, uint8_t aScan, int aFlags,
140 wchar_t *aUniKey = NULL);
141 bool mouseEvent (int aType, const QPoint &aPos, const QPoint &aGlobalPos,
142 Qt::ButtonState aButton,
143 Qt::ButtonState aState, Qt::ButtonState aStateAfter,
144 int aWheelDelta, Qt::Orientation aWheelDir);
145
146 void emitKeyboardStateChanged()
147 {
148 emit keyboardStateChanged (
149 (mKbdCaptured ? KeyboardCaptured : 0) |
150 (mIsHostkeyPressed ? HostKeyPressed : 0));
151 }
152
153 void emitMouseStateChanged() {
154 emit mouseStateChanged ((mMouseCaptured ? MouseCaptured : 0) |
155 (mMouseAbsolute ? MouseAbsolute : 0) |
156 (!mMouseIntegration ? MouseAbsoluteDisabled : 0));
157 }
158
159 // IConsoleCallback event handlers
160 void onStateChange (KMachineState state);
161
162 void doRefresh();
163
164 void viewportPaintEvent( QPaintEvent * );
165#ifdef VBOX_GUI_USE_REFRESH_TIMER
166 void timerEvent( QTimerEvent * );
167#endif
168
169 void captureKbd (bool aCapture, bool aEmitSignal = true);
170 void captureMouse (bool aCapture, bool aEmitSignal = true);
171
172 bool processHotKey (const QKeySequence &key, QMenuData *data);
173 void updateModifiers (bool fNumLock, bool fCapsLock, bool fScrollLock);
174
175 void releaseAllPressedKeys (bool aReleaseHostKey = true);
176 void saveKeyStates();
177 void sendChangedKeyStates();
178 void updateMouseClipping();
179
180 void setPointerShape (MousePointerChangeEvent *me);
181
182 bool isPaused() { return mLastState == KMachineState_Paused; }
183 bool isRunning() { return mLastState == KMachineState_Running; }
184
185 static void dimImage (QImage &img);
186
187private slots:
188
189 void doResizeHint (const QSize &aSize = QSize());
190 void doResizeDesktop (int);
191
192private:
193
194 void sendInitialSizeHint(void);
195 void maybeRestrictMinimumSize();
196
197 VBoxConsoleWnd *mMainWnd;
198
199 CConsole mConsole;
200
201 const VBoxGlobalSettings &gs;
202
203 KMachineState mLastState;
204
205 bool mAttached : 1;
206 bool mKbdCaptured : 1;
207 bool mMouseCaptured : 1;
208 bool mMouseAbsolute : 1;
209 bool mMouseIntegration : 1;
210 QPoint mLastPos;
211 QPoint mCapturedPos;
212
213 bool mDisableAutoCapture : 1;
214
215 enum { IsKeyPressed = 0x01, IsExtKeyPressed = 0x02, IsKbdCaptured = 0x80 };
216 uint8_t mPressedKeys [128];
217 uint8_t mPressedKeysCopy [128];
218
219 bool mIsHostkeyPressed : 1;
220 bool mIsHostkeyAlone : 1;
221
222 /** mKbdCaptured value during the the last host key press or release */
223 bool hostkey_in_capture : 1;
224
225 bool mIgnoreMainwndResize : 1;
226 bool mAutoresizeGuest : 1;
227
228 bool mIsAdditionsActive : 1;
229
230 bool mNumLock : 1;
231 bool mScrollLock : 1;
232 bool mCapsLock : 1;
233 long muNumLockAdaptionCnt;
234 long muCapsLockAdaptionCnt;
235
236 QTimer *resize_hint_timer;
237 QTimer *mToggleFSModeTimer;
238
239 VBoxDefs::RenderMode mode;
240
241 QRegion mLastVisibleRegion;
242 QSize mNormalSize;
243
244#if defined(Q_WS_WIN)
245 HCURSOR mAlphaCursor;
246#endif
247
248#if defined(Q_WS_MAC)
249# ifndef VBOX_WITH_HACKED_QT
250 /** Event handler reference. NULL if the handler isn't installed. */
251 EventHandlerRef mDarwinEventHandlerRef;
252# endif
253 /** The current modifier key mask. Used to figure out which modifier
254 * key was pressed when we get a kEventRawKeyModifiersChanged event. */
255 UInt32 mDarwinKeyModifiers;
256 /** The darwin cursor handle (see DarwinCursor.h/.cpp). */
257 DARWINCURSOR mDarwinCursor;
258#endif
259
260#if defined (VBOX_GUI_USE_REFRESH_TIMER)
261 QPixmap pm;
262 int tid; /**< Timer id */
263#endif
264
265 VBoxFrameBuffer *mFrameBuf;
266 CConsoleCallback mCallback;
267
268 friend class VBoxConsoleCallback;
269
270#if defined (Q_WS_WIN32)
271 static LRESULT CALLBACK lowLevelKeyboardProc (int nCode,
272 WPARAM wParam, LPARAM lParam);
273#elif defined (Q_WS_MAC)
274# ifndef VBOX_WITH_HACKED_QT
275 static pascal OSStatus darwinEventHandlerProc (EventHandlerCallRef inHandlerCallRef,
276 EventRef inEvent, void *inUserData);
277# else /* VBOX_WITH_HACKED_QT */
278 static bool macEventFilter (EventRef inEvent, void *inUserData);
279# endif /* VBOX_WITH_HACKED_QT */
280#endif
281
282 QPixmap mPausedShot;
283#if defined(Q_WS_MAC)
284 CGImageRef mVirtualBoxLogo;
285#endif
286 QSize mLastSizeHint;
287 QRect mDesktopGeometry;
288};
289
290#endif // __VBoxConsoleView_h__
291
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette