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