VirtualBox

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

Last change on this file since 2764 was 2764, checked in by vboxsync, 18 years ago

FE/Qt: Fixed spelling; added proper console window restriction for SDL mode when no guest additions are active or when the auto-resize feature is turned off.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.2 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * VBoxConsoleView class declaration
5 */
6
7/*
8 * Copyright (C) 2006 InnoTek Systemberatung 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 as published by the Free Software Foundation,
14 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
15 * distribution. VirtualBox OSE is distributed in the hope that it will
16 * be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * If you received this file as part of a commercial VirtualBox
19 * distribution, then only the terms of your commercial VirtualBox
20 * license agreement apply instead of the previous paragraph.
21 */
22
23#ifndef __VBoxConsoleView_h__
24#define __VBoxConsoleView_h__
25
26#include "COMDefs.h"
27
28#include "VBoxDefs.h"
29#include "VBoxGlobalSettings.h"
30
31#include <qdatetime.h>
32#include <qscrollview.h>
33#include <qpixmap.h>
34#include <qimage.h>
35
36#include <qkeysequence.h>
37
38#if defined (Q_WS_MAC)
39# include <Carbon/Carbon.h>
40# include "DarwinCursor.h"
41/** @todo remove this hack when somebody get around fixing the conflicting typedef/enum OSType. */
42# define OSType VBoxOSType
43#endif
44
45class VBoxConsoleWnd;
46class MousePointerChangeEvent;
47class VBoxFrameBuffer;
48
49class QPainter;
50class QLabel;
51class QMenuData;
52
53class VBoxConsoleView : public QScrollView
54{
55 Q_OBJECT
56
57public:
58
59 enum {
60 MouseCaptured = 0x01,
61 MouseAbsolute = 0x02,
62 MouseAbsoluteDisabled = 0x04,
63 MouseNeedsHostCursor = 0x08,
64 KeyboardCaptured = 0x01,
65 HostKeyPressed = 0x02,
66 };
67
68 VBoxConsoleView (VBoxConsoleWnd *mainWnd,
69 const CConsole &console,
70 VBoxDefs::RenderMode rm,
71 QWidget *parent = 0, const char *name = 0, WFlags f = 0);
72 ~VBoxConsoleView();
73
74 QSize sizeHint() const;
75
76 void attach();
77 void detach();
78 void refresh() { doRefresh(); }
79 void normalizeGeometry (bool adjustPosition = false);
80
81 CConsole &console() { return cconsole; }
82
83 bool pause (bool on);
84
85 void setMouseIntegrationEnabled (bool enabled);
86
87 bool isMouseAbsolute() const { return mouse_absolute; }
88
89 void setAutoresizeGuest (bool on);
90
91 void onFullscreenChange (bool on);
92
93 void fixModifierState (LONG *codes, uint *count);
94
95signals:
96
97 void keyboardStateChanged (int state);
98 void mouseStateChanged (int state);
99 void machineStateChanged (CEnums::MachineState state);
100 void additionsStateChanged (const QString &, bool);
101
102protected:
103
104 // events
105 bool event( QEvent *e );
106 bool eventFilter( QObject *watched, QEvent *e );
107
108#if defined(Q_WS_WIN32)
109 bool winLowKeyboardEvent (UINT msg, const KBDLLHOOKSTRUCT &event);
110 bool winEvent (MSG *msg);
111#elif defined(Q_WS_X11)
112 bool x11Event (XEvent *event );
113#elif defined(Q_WS_MAC)
114 bool darwinKeyboardEvent (EventRef inEvent);
115 void darwinGrabKeyboardEvents (bool fGrab);
116#endif
117
118private:
119
120 // flags for keyEvent()
121 enum {
122 KeyExtended = 0x01,
123 KeyPressed = 0x02,
124 KeyPause = 0x04,
125 KeyPrint = 0x08,
126 };
127
128 void focusEvent (bool focus);
129 bool keyEvent (int key, uint8_t scan, int flags, wchar_t *aUniKey = NULL);
130 bool mouseEvent (int aType, const QPoint &aPos, const QPoint &aGlobalPos,
131 ButtonState aButton,
132 ButtonState aState, ButtonState aStateAfter,
133 int aWheelDelta, Orientation aWheelDir);
134
135 void emitKeyboardStateChanged() {
136 emit keyboardStateChanged (
137 (kbd_captured ? KeyboardCaptured : 0) |
138 (hostkey_pressed ? HostKeyPressed : 0));
139 }
140 void emitMouseStateChanged() {
141 emit mouseStateChanged ((mouse_captured ? MouseCaptured : 0) |
142 (mouse_absolute ? MouseAbsolute : 0) |
143 (!mouse_integration ? MouseAbsoluteDisabled : 0));
144 }
145
146 // IConsoleCallback event handlers
147 void onStateChange (CEnums::MachineState state);
148
149 void doRefresh();
150
151 void viewportPaintEvent( QPaintEvent * );
152#ifdef VBOX_GUI_USE_REFRESH_TIMER
153 void timerEvent( QTimerEvent * );
154#endif
155
156 void captureKbd (bool capture, bool emit_signal = true);
157 void captureMouse (bool capture, bool emit_signal = true);
158
159 bool processHotKey (const QKeySequence &key, QMenuData *data);
160 void updateModifiers (bool fNumLock, bool fCapsLock, bool fScrollLock);
161
162 void releaseAllKeysPressed (bool release_hostkey = true);
163 void saveKeyStates();
164 void sendChangedKeyStates();
165 void updateMouseClipping();
166
167 void setPointerShape (MousePointerChangeEvent *me);
168
169 bool isPaused() { return last_state == CEnums::Paused; }
170 bool isRunning() { return last_state == CEnums::Running; }
171
172 static void dimImage (QImage &img);
173
174private slots:
175
176 void exitFullScreen();
177
178 void doResizeHint();
179 void normalizeGeo() { normalizeGeometry (true); }
180
181private:
182
183 void maybeRestrictMinimumSize();
184
185 VBoxConsoleWnd *mainwnd;
186
187 CConsole cconsole;
188
189 const VBoxGlobalSettings &gs;
190
191 CEnums::MachineState last_state;
192
193 bool attached : 1;
194 bool kbd_captured : 1;
195 bool mouse_captured : 1;
196 bool mouse_absolute : 1;
197 bool mouse_integration : 1;
198 QPoint last_pos;
199 QPoint captured_pos;
200
201 enum { IsKeyPressed = 0x01, IsExtKeyPressed = 0x02, IsKbdCaptured = 0x80 };
202 uint8_t keys_pressed[128];
203 uint8_t keys_pressed_copy[128];
204
205 bool hostkey_pressed : 1;
206 bool hostkey_alone : 1;
207 /** kbd_captured value during the the last host key press or release */
208 bool hostkey_in_capture : 1;
209
210 bool ignore_mainwnd_resize : 1;
211 bool mAutoresizeGuest : 1;
212
213 bool mIsAdditionsActive : 1;
214
215 bool mfNumLock : 1;
216 bool mfScrollLock : 1;
217 bool mfCapsLock : 1;
218 long muNumLockAdaptionCnt;
219 long muCapsLockAdaptionCnt;
220
221 QTimer *resize_hint_timer;
222
223 VBoxDefs::RenderMode mode;
224
225#if defined(Q_WS_WIN)
226 HCURSOR mAlphaCursor;
227#endif
228
229#if defined(Q_WS_MAC)
230# ifndef VBOX_WITH_HACKED_QT
231 /** Event handler reference. NULL if the handler isn't installed. */
232 EventHandlerRef m_darwinEventHandlerRef;
233# endif
234 /** The current modifier key mask. Used to figure out which modifier
235 * key was pressed when we get a kEventRawKeyModifiersChanged event. */
236 UInt32 m_darwinKeyModifiers;
237 /** The darwin cursor handle (see DarwinCursor.h/.cpp). */
238 DARWINCURSOR m_darwinCursor;
239#endif
240
241#if defined (VBOX_GUI_USE_REFRESH_TIMER)
242 QPixmap pm;
243 int tid; /**< Timer id */
244#endif
245
246 VBoxFrameBuffer *fb;
247 CConsoleCallback callback;
248
249 friend class VBoxConsoleCallback;
250
251#if defined (Q_WS_WIN32)
252 static LRESULT CALLBACK lowLevelKeyboardProc (int nCode,
253 WPARAM wParam, LPARAM lParam);
254#elif defined (Q_WS_MAC)
255# ifndef VBOX_WITH_HACKED_QT
256 static pascal OSStatus darwinEventHandlerProc (EventHandlerCallRef inHandlerCallRef,
257 EventRef inEvent, void *inUserData);
258# else /* VBOX_WITH_HACKED_QT */
259 static bool macEventFilter (EventRef inEvent, void *inUserData);
260# endif /* VBOX_WITH_HACKED_QT */
261#endif
262
263 QPixmap mPausedShot;
264};
265
266#endif // __VBoxConsoleView_h__
267
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