VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h@ 7335

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

Frontends/VirtualBox: remember the last video mode hint sent in the machine XML file and resend it on VM boot

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