VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxBFE/SDLConsole.h@ 27742

Last change on this file since 27742 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: 4.7 KB
Line 
1/** @file
2 *
3 * VBox frontends: Basic Frontend (BFE):
4 * Declaration of SDLConsole 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_VBOXSDL
24#define __H_VBOXSDL
25
26/* include this first so Windows.h get's in before our stuff. */
27#include <SDL.h>
28#ifndef RT_OS_DARWIN
29# define Display Display_ /* Xlib defines "Display" and so do we... */
30# include <SDL_syswm.h>
31# undef Display
32#endif
33#if defined(RT_OS_WINDOWS) /// @todo someone please explain why this is necessary. This breaks darwin solid.
34// damn SDL redefines main!
35#undef main
36#endif
37
38#include "ConsoleImpl.h"
39#include <iprt/string.h>
40
41/** Pointer shape change event data strucure */
42struct PointerShapeChangeData
43{
44 PointerShapeChangeData (BOOL aVisible, BOOL aAlpha, ULONG aXHot, ULONG aYHot,
45 ULONG aWidth, ULONG aHeight,
46 const uint8_t *aShape)
47 : visible (aVisible), alpha (aAlpha), xHot (aXHot), yHot (aYHot)
48 , width (aWidth), height (aHeight), shape (NULL)
49 {
50 // make a copy of the shape
51 if (aShape) {
52 uint32_t shapeSize = ((((aWidth + 7) / 8) * aHeight + 3) & ~3) + aWidth * 4 * aHeight;
53 shape = new uint8_t [shapeSize];
54 if (shape)
55 memcpy ((void *) shape, (void *) aShape, shapeSize);
56 }
57 }
58
59 ~PointerShapeChangeData()
60 {
61 if (shape) delete[] shape;
62 }
63
64 const BOOL visible;
65 const BOOL alpha;
66 const ULONG xHot;
67 const ULONG yHot;
68 const ULONG width;
69 const ULONG height;
70 const uint8_t *shape;
71};
72
73/** custom SDL event for display update handling */
74#define SDL_USER_EVENT_UPDATERECT (SDL_USEREVENT + 4)
75/** custom SDL event for resize handling */
76#define SDL_USER_EVENT_RESIZE (SDL_USEREVENT + 5)
77/** custom SDL for XPCOM event queue processing */
78#define SDL_USER_EVENT_XPCOM_EVENTQUEUE (SDL_USEREVENT + 6)
79
80
81/** custom SDL for XPCOM event queue processing */
82#define SDL_USER_EVENT_GRAB (SDL_USEREVENT + 6)
83
84/** custom SDL event for updating the titlebar */
85#define SDL_USER_EVENT_UPDATE_TITLEBAR (SDL_USEREVENT + 7)
86/** custom SDL user event for terminating the session */
87#define SDL_USER_EVENT_TERMINATE (SDL_USEREVENT + 8)
88/** custom SDL user event for secure label update notification */
89#define SDL_USER_EVENT_SECURELABEL_UPDATE (SDL_USEREVENT + 9)
90/** custom SDL user event for pointer shape change request */
91#define SDL_USER_EVENT_POINTER_CHANGE (SDL_USEREVENT + 10)
92
93#define SDL_USER_
94
95
96class SDLConsole : public Console
97{
98public:
99 SDLConsole();
100 ~SDLConsole();
101
102 virtual void updateTitlebar();
103 virtual void updateTitlebarProgress(const char *pszStr, int iPercent);
104
105 virtual void inputGrabStart();
106 virtual void inputGrabEnd();
107
108 virtual void mouseSendEvent(int dz);
109 virtual void onMousePointerShapeChange(bool fVisible,
110 bool fAlpha, uint32_t xHot,
111 uint32_t yHot, uint32_t width,
112 uint32_t height, void *pShape);
113 virtual void progressInfo(PVM pVM, unsigned uPercent, void *pvUser);
114
115 virtual CONEVENT eventWait();
116 virtual void eventQuit();
117 virtual void resetCursor();
118 virtual void resetKeys(void);
119 virtual VMMDev *getVMMDev();
120 virtual Display *getDisplay();
121
122private:
123
124 int handleHostKey(const SDL_KeyboardEvent *pEv);
125 uint8_t keyEventToKeyCode(const SDL_KeyboardEvent *ev);
126 void processKey(SDL_KeyboardEvent *ev);
127 void setPointerShape (const PointerShapeChangeData *data);
128 static void doEventQuit(void);
129
130 /** modifier keypress status (scancode as index) */
131 uint8_t gaModifiersState[256];
132
133 SDL_Cursor *gpDefaultCursor;
134 SDL_Cursor *gpCustomCursor;
135 /** Custom window manager cursor? */
136 WMcursor *gpCustomWMcursor;
137 /** the application Icon */
138 SDL_Surface *mWMIcon;
139#ifdef VBOXBFE_WITH_X11
140 SDL_SysWMinfo gSdlInfo;
141#endif
142
143 /* Current event */
144 SDL_Event ev1;
145 SDL_Event EvHKeyDown;
146};
147
148#endif // __H_VBOXSDL
149
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