VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxBFE/ConsoleImpl.h@ 28587

Last change on this file since 28587 was 26980, checked in by vboxsync, 15 years ago

FE/BFE: more clean-up to reduce the difference between MouseImpl.cpp in Main and VBoxBFE

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.6 KB
Line 
1/** @file
2 *
3 * VBox frontends: Basic Frontend (BFE):
4 * Declaration of Console class
5 */
6
7/*
8 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
19 * Clara, CA 95054 USA or visit http://www.sun.com if you need
20 * additional information or have any questions.
21 */
22
23#ifndef ____H_CONSOLEIMPL
24#define ____H_CONSOLEIMPL
25
26#include <VBox/types.h>
27
28/*
29 * Host key handling.
30 *
31 * The golden rule is that host-key combinations should not be seen
32 * by the guest. For instance a CAD should not have any extra RCtrl down
33 * and RCtrl up around itself. Nor should a resume be followed by a Ctrl-P
34 * that could encourage applications to start printing.
35 *
36 * We must not confuse the hostkey processing into any release sequences
37 * either, the host key is supposed to be explicitly pressing one key.
38 *
39 * Quick state diagram:
40 *
41 * host key down alone
42 * (Normal) ---------------
43 * ^ ^ |
44 * | | v host combination key down
45 * | | (Host key down) ----------------
46 * | | host key up v | |
47 * | |-------------- | other key down v host combination key down
48 * | | (host key used) -------------
49 * | | | ^ |
50 * | (not host key)-- | |---------------
51 * | | | | |
52 * | | ---- other |
53 * | modifiers = 0 v v
54 * -----------------------------------------------
55 */
56typedef enum _HKEYSTATE
57{
58 /** The initial and most common state, pass keystrokes to the guest.
59 * Next state: HKEYSTATE_DOWN
60 * Prev state: Any */
61 HKEYSTATE_NORMAL = 1,
62 /** The host key has been pressed down.
63 * Prev state: HKEYSTATE_NORMAL
64 * Next state: HKEYSTATE_NORMAL - host key up, capture toggle.
65 * Next state: HKEYSTATE_USED - host key combination down.
66 * Next state: HKEYSTATE_NOT_IT - non-host key combination down.
67 */
68 HKEYSTATE_DOWN,
69 /** A host key combination was pressed.
70 * Prev state: HKEYSTATE_DOWN
71 * Next state: HKEYSTATE_NORMAL - when modifiers are all 0
72 */
73 HKEYSTATE_USED,
74 /** A non-host key combination was attempted. Send hostkey down to the
75 * guest and continue until all modifiers have been released.
76 * Prev state: HKEYSTATE_DOWN
77 * Next state: HKEYSTATE_NORMAL - when modifiers are all 0
78 */
79 HKEYSTATE_NOT_IT
80} HKEYSTATE;
81
82typedef enum _CONEVENT
83{
84 CONEVENT_SCREENUPDATE = 1,
85 CONEVENT_KEYUP,
86 CONEVENT_KEYDOWN,
87 CONEVENT_MOUSEMOVE,
88 CONEVENT_MOUSEBUTTONUP,
89 CONEVENT_MOUSEBUTTONDOWN,
90 CONEVENT_FOCUSCHANGE,
91
92 CONEVENT_USR_QUIT,
93 CONEVENT_USR_SCREENUPDATERECT,
94 CONEVENT_USR_SCREENRESIZE,
95 CONEVENT_USR_TITLEBARUPDATE,
96 CONEVENT_USR_SECURELABELUPDATE,
97 CONEVENT_USR_MOUSEPOINTERCHANGE,
98
99 CONEVENT_QUIT,
100
101 CONEVENT_NONE
102} CONEVENT;
103
104/**
105 * Checks the availability of the underlying VM device driver corresponding
106 * to the COM interface (IKeyboard, IMouse, IDisplay, etc.). When the driver is
107 * not available (NULL), sets error info and returns returns E_ACCESSDENIED.
108 * The translatable error message is defined in null context.
109 *
110 * Intended to used only within Console children (i.e. Keyboard, Mouse,
111 * Display, etc.).
112 *
113 * @param drv driver pointer to check (compare it with NULL)
114 */
115#define CHECK_CONSOLE_DRV(drv) \
116 do { \
117 if (!(drv)) \
118 return setError(E_ACCESSDENIED, tr("The console is not powered up")); \
119 } while (0)
120
121class VMMDev;
122class Display;
123
124class Console
125{
126public:
127 Console()
128 {
129 enmHKeyState = HKEYSTATE_NORMAL;
130 mfInitialized = false;
131 mfInputGrab = false;
132 }
133 virtual ~Console() {}
134
135 virtual void updateTitlebar() = 0;
136 virtual void updateTitlebarProgress(const char *pszStr, int iPercent) = 0;
137
138 virtual void inputGrabStart() = 0;
139 virtual void inputGrabEnd() = 0;
140 virtual bool inputGrabbed() { return mfInputGrab; }
141 virtual void resetCursor() {}
142
143 virtual void mouseSendEvent(int dz) = 0;
144 virtual void onMousePointerShapeChange(bool fVisible,
145 bool fAlpha, uint32_t xHot,
146 uint32_t yHot, uint32_t width,
147 uint32_t height, void *pShape) = 0;
148 virtual void onMouseCapabilityChange(bool fAbs, bool fRel,
149 bool fNeedsHostCursor) {}
150
151 virtual CONEVENT eventWait() = 0;
152 virtual void eventQuit() = 0;
153 bool initialized() { return mfInitialized; }
154 virtual void progressInfo(PVM pVM, unsigned uPercent, void *pvUser) = 0;
155 virtual void resetKeys(void) = 0;
156 virtual VMMDev *getVMMDev() = 0;
157 virtual Display *getDisplay() = 0;
158
159protected:
160 HKEYSTATE enmHKeyState;
161 bool mfInitialized;
162 bool mfInputGrab;
163};
164
165extern Console *gConsole;
166
167#endif // ____H_CONSOLEIMPL
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