VirtualBox

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

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

Frontends/VirtualBox4: 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.5 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/* 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
96signals:
97
98 void keyboardStateChanged (int state);
99 void mouseStateChanged (int state);
100 void machineStateChanged (KMachineState state);
101 void additionsStateChanged (const QString &, bool, bool);
102 void mediaChanged (VBoxDefs::DiskType aType);
103 void networkStateChange();
104 void usbStateChange();
105 void sharedFoldersChanged();
106 void resizeHintDone();
107
108protected:
109
110 // events
111 bool event (QEvent *e);
112 bool eventFilter (QObject *watched, QEvent *e);
113
114#if defined(Q_WS_WIN32)
115 bool winLowKeyboardEvent (UINT msg, const KBDLLHOOKSTRUCT &event);
116 bool winEvent (MSG *msg);
117#elif defined(Q_WS_PM)
118 bool pmEvent (QMSG *aMsg);
119#elif defined(Q_WS_X11)
120 bool x11Event (XEvent *event);
121#elif defined(Q_WS_MAC)
122 bool darwinKeyboardEvent (EventRef inEvent);
123 void darwinGrabKeyboardEvents (bool fGrab);
124#endif
125
126private:
127
128 /** Flags for keyEvent(). */
129 enum {
130 KeyExtended = 0x01,
131 KeyPressed = 0x02,
132 KeyPause = 0x04,
133 KeyPrint = 0x08,
134 };
135
136 void focusEvent (bool aHasFocus, bool aReleaseHostKey = true);
137 bool keyEvent (int aKey, uint8_t aScan, int aFlags,
138 wchar_t *aUniKey = NULL);
139 bool mouseEvent (int aType, const QPoint &aPos, const QPoint &aGlobalPos,
140 Qt::ButtonState aButton,
141 Qt::ButtonState aState, Qt::ButtonState aStateAfter,
142 int aWheelDelta, Qt::Orientation aWheelDir);
143
144 void emitKeyboardStateChanged()
145 {
146 emit keyboardStateChanged (
147 (mKbdCaptured ? KeyboardCaptured : 0) |
148 (mIsHostkeyPressed ? HostKeyPressed : 0));
149 }
150
151 void emitMouseStateChanged() {
152 emit mouseStateChanged ((mMouseCaptured ? MouseCaptured : 0) |
153 (mMouseAbsolute ? MouseAbsolute : 0) |
154 (!mMouseIntegration ? MouseAbsoluteDisabled : 0));
155 }
156
157 // IConsoleCallback event handlers
158 void onStateChange (KMachineState state);
159
160 void doRefresh();
161
162 void viewportPaintEvent( QPaintEvent * );
163#ifdef VBOX_GUI_USE_REFRESH_TIMER
164 void timerEvent( QTimerEvent * );
165#endif
166
167 void captureKbd (bool aCapture, bool aEmitSignal = true);
168 void captureMouse (bool aCapture, bool aEmitSignal = true);
169
170 bool processHotKey (const QKeySequence &key, QMenuData *data);
171 void updateModifiers (bool fNumLock, bool fCapsLock, bool fScrollLock);
172
173 void releaseAllPressedKeys (bool aReleaseHostKey = true);
174 void saveKeyStates();
175 void sendChangedKeyStates();
176 void updateMouseClipping();
177
178 void setPointerShape (MousePointerChangeEvent *me);
179
180 bool isPaused() { return mLastState == KMachineState_Paused; }
181 bool isRunning() { return mLastState == KMachineState_Running; }
182
183 static void dimImage (QImage &img);
184
185private slots:
186
187 void doResizeHint (const QSize &aSize = QSize());
188
189private:
190
191 void sendInitialSizeHint(void);
192 void maybeRestrictMinimumSize();
193
194 VBoxConsoleWnd *mMainWnd;
195
196 CConsole mConsole;
197
198 const VBoxGlobalSettings &gs;
199
200 KMachineState mLastState;
201
202 bool mAttached : 1;
203 bool mKbdCaptured : 1;
204 bool mMouseCaptured : 1;
205 bool mMouseAbsolute : 1;
206 bool mMouseIntegration : 1;
207 QPoint mLastPos;
208 QPoint mCapturedPos;
209
210 bool mDisableAutoCapture : 1;
211
212 enum { IsKeyPressed = 0x01, IsExtKeyPressed = 0x02, IsKbdCaptured = 0x80 };
213 uint8_t mPressedKeys [128];
214 uint8_t mPressedKeysCopy [128];
215
216 bool mIsHostkeyPressed : 1;
217 bool mIsHostkeyAlone : 1;
218
219 /** mKbdCaptured value during the the last host key press or release */
220 bool hostkey_in_capture : 1;
221
222 bool mIgnoreMainwndResize : 1;
223 bool mAutoresizeGuest : 1;
224
225 bool mIsAdditionsActive : 1;
226
227 bool mNumLock : 1;
228 bool mScrollLock : 1;
229 bool mCapsLock : 1;
230 long muNumLockAdaptionCnt;
231 long muCapsLockAdaptionCnt;
232
233 QTimer *resize_hint_timer;
234 QTimer *mToggleFSModeTimer;
235
236 VBoxDefs::RenderMode mode;
237
238 QRegion mLastVisibleRegion;
239 QSize mNormalSize;
240
241#if defined(Q_WS_WIN)
242 HCURSOR mAlphaCursor;
243#endif
244
245#if defined(Q_WS_MAC)
246# ifndef VBOX_WITH_HACKED_QT
247 /** Event handler reference. NULL if the handler isn't installed. */
248 EventHandlerRef mDarwinEventHandlerRef;
249# endif
250 /** The current modifier key mask. Used to figure out which modifier
251 * key was pressed when we get a kEventRawKeyModifiersChanged event. */
252 UInt32 mDarwinKeyModifiers;
253 /** The darwin cursor handle (see DarwinCursor.h/.cpp). */
254 DARWINCURSOR mDarwinCursor;
255#endif
256
257#if defined (VBOX_GUI_USE_REFRESH_TIMER)
258 QPixmap pm;
259 int tid; /**< Timer id */
260#endif
261
262 VBoxFrameBuffer *mFrameBuf;
263 CConsoleCallback mCallback;
264
265 friend class VBoxConsoleCallback;
266
267#if defined (Q_WS_WIN32)
268 static LRESULT CALLBACK lowLevelKeyboardProc (int nCode,
269 WPARAM wParam, LPARAM lParam);
270#elif defined (Q_WS_MAC)
271# ifndef VBOX_WITH_HACKED_QT
272 static pascal OSStatus darwinEventHandlerProc (EventHandlerCallRef inHandlerCallRef,
273 EventRef inEvent, void *inUserData);
274# else /* VBOX_WITH_HACKED_QT */
275 static bool macEventFilter (EventRef inEvent, void *inUserData);
276# endif /* VBOX_WITH_HACKED_QT */
277#endif
278
279 QPixmap mPausedShot;
280#if defined(Q_WS_MAC)
281 CGImageRef mVirtualBoxLogo;
282#endif
283 QSize mLastSizeHint;
284};
285
286#endif // __VBoxConsoleView_h__
287
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