~ubuntu-branches/ubuntu/gutsy/virtualbox-ose/gutsy

« back to all changes in this revision

Viewing changes to src/VBox/Frontends/VBoxBFE/SDLConsole.h

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2007-09-08 16:44:58 UTC
  • Revision ID: james.westby@ubuntu.com-20070908164458-wao29470vqtr8ksy
Tags: upstream-1.5.0-dfsg2
ImportĀ upstreamĀ versionĀ 1.5.0-dfsg2

Show diffs side-by-side

added added

removed removed

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