VirtualBox

Ignore:
Timestamp:
Feb 26, 2010 12:10:36 PM (15 years ago)
Author:
vboxsync
Message:

FE/BFE: resynchronise MouseImpl from Main

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxBFE/MouseImpl.h

    r26173 r26834  
    11/* $Id$ */
    22/** @file
    3  * VBox frontends: Basic Frontend (BFE):
    4  * Declaration of Mouse class
     3 * VirtualBox VBoxBFE/COM class implementation
    54 */
    65
    76/*
    8  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     7 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    98 *
    109 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2423#define ____H_MOUSEIMPL
    2524
    26 #include <VBox/pdm.h>
     25#include "VirtualBoxBase.h"
     26#ifndef VBOXBFE_WITHOUT_COM
     27# include "ConsoleEvents.h"
     28#endif
     29#include "ConsoleImpl.h"
     30#include <VBox/pdmdrv.h>
    2731
    2832/** Simple mouse event class. */
     
    3034{
    3135public:
    32     MouseEvent() : dx(0), dy(0), dz(0), state(-1) {}
    33     MouseEvent(int _dx, int _dy, int _dz, int _state) :
    34         dx(_dx), dy(_dy), dz(_dz), state(_state) {}
     36    MouseEvent() : dx(0), dy(0), dz(0), dw(0), state(-1) {}
     37    MouseEvent(int32_t _dx, int32_t _dy, int32_t _dz, int32_t _dw, int32_t _state) :
     38        dx(_dx), dy(_dy), dz(_dz), dw(_dw), state(_state) {}
    3539    bool isValid()
    3640    {
    3741        return state != -1;
    3842    }
    39     // not logical to be int but that's how it's defined in QEMU
    40     /** @todo r=bird: and what is the logical declaration then? We'll be using int32_t btw. */
    41     int dx, dy, dz;
    42     int state;
     43    /* Note: dw is the horizontal scroll wheel */
     44    int32_t dx, dy, dz, dw;
     45    int32_t state;
     46};
     47#ifndef VBOXBFE_WITHOUT_COM
     48// template instantiation
     49typedef ConsoleEventBuffer<MouseEvent> MouseEventBuffer;
     50#endif
     51
     52enum
     53{
     54    MOUSE_DEVCAP_RELATIVE = 1,
     55    MOUSE_DEVCAP_ABSOLUTE = 2
    4356};
    4457
    45 class Mouse
     58class ATL_NO_VTABLE Mouse :
     59    public VirtualBoxBase
     60#ifndef VBOXBFE_WITHOUT_COM
     61    ,
     62    public VirtualBoxSupportErrorInfoImpl<Mouse, IMouse>,
     63    public VirtualBoxSupportTranslation<Mouse>,
     64    VBOX_SCRIPTABLE_IMPL(IMouse)
     65#endif
    4666{
    4767public:
    4868
    49     Mouse() : fAbsolute(false), fNeedsHostCursor(false), mpDrv(NULL), uHostCaps(0) {}
     69#ifndef VBOXBFE_WITHOUT_COM
     70    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Mouse)
     71
     72    DECLARE_NOT_AGGREGATABLE(Mouse)
     73
     74    DECLARE_PROTECT_FINAL_CONSTRUCT()
     75
     76    BEGIN_COM_MAP(Mouse)
     77        COM_INTERFACE_ENTRY  (ISupportErrorInfo)
     78        COM_INTERFACE_ENTRY  (IMouse)
     79        COM_INTERFACE_ENTRY2 (IDispatch, IMouse)
     80    END_COM_MAP()
     81#endif
     82
     83    DECLARE_EMPTY_CTOR_DTOR (Mouse)
     84
     85    HRESULT FinalConstruct();
     86    void FinalRelease();
     87
     88    // public initializer/uninitializer for internal purposes only
     89    HRESULT init(Console *parent);
     90    void uninit();
     91
     92    // IMouse properties
     93    STDMETHOD(COMGETTER(AbsoluteSupported)) (BOOL *absoluteSupported);
     94    STDMETHOD(COMGETTER(RelativeSupported)) (BOOL *relativeSupported);
     95    STDMETHOD(COMGETTER(NeedsHostCursor)) (BOOL *needsHostCursor);
    5096
    5197    // IMouse methods
    52     int  PutMouseEvent(LONG dx, LONG dy, LONG dz, LONG buttonState);
    53     int  PutMouseEventAbsolute(LONG x, LONG y, LONG dz, LONG buttonState);
     98    STDMETHOD(PutMouseEvent)(LONG dx, LONG dy, LONG dz, LONG dw,
     99                             LONG buttonState);
     100    STDMETHOD(PutMouseEventAbsolute)(LONG x, LONG y, LONG dz, LONG dw,
     101                                     LONG buttonState);
    54102
    55     int  setAbsoluteCoordinates(bool fAbsolute);
    56     int  setNeedsHostCursor(bool fNeedsHostCursor);
    57 #ifdef RT_OS_L4
    58     // So far L4Con does not support an own mouse pointer.
    59     bool getAbsoluteCoordinates() { return false; }
    60 #else
    61     bool getAbsoluteCoordinates() { return fAbsolute; }
    62 #endif
    63     bool getNeedsHostCursor() { return fNeedsHostCursor; }
    64     int  setHostCursor(bool enable);
     103    // for VirtualBoxSupportErrorInfoImpl
     104    static const wchar_t *getComponentName() { return L"Mouse"; }
    65105
    66106    static const PDMDRVREG  DrvReg;
     107
     108#ifndef VBOXBFE_WITHOUT_COM
     109    Console *getParent() const
     110    {
     111        return mParent;
     112    }
     113#endif
     114
     115    // for VMMDevInterface
     116    void onVMMDevCanAbsChange(bool canAbs)
     117    {
     118        fVMMDevCanAbs = canAbs;
     119        sendMouseCapsCallback();
     120    }
     121
     122    void onVMMDevNeedsHostChange(bool needsHost)
     123    {
     124        fVMMDevNeedsHostCursor = needsHost;
     125        sendMouseCapsCallback();
     126    }
    67127
    68128private:
    69129
    70130    static DECLCALLBACK(void *) drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
     131    static DECLCALLBACK(void)   mouseAbsModeChange (PPDMIMOUSECONNECTOR pInterface, bool fAbs);
    71132    static DECLCALLBACK(int)    drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
    72133    static DECLCALLBACK(void)   drvDestruct(PPDMDRVINS pDrvIns);
     134   
     135    int getVMMDevMouseCaps(uint32_t *pfCaps);
     136    int setVMMDevMouseCaps(uint32_t fCaps);
     137    int reportRelEventToMouseDev(int32_t dx, int32_t dy, int32_t dz,
     138                                 int32_t dw, uint32_t fButtons);
     139    int reportAbsEventToMouseDev(uint32_t mouseXAbs, uint32_t mouseYAbs,
     140                                 int32_t dz, int32_t dw, uint32_t fButtons);
     141    int reportAbsEventToVMMDev(uint32_t mouseXAbs, uint32_t mouseYAbs);
     142    int convertDisplayWidth(LONG x, uint32_t *pcX);
     143    int convertDisplayHeight(LONG y, uint32_t *pcY);
     144   
     145    void sendMouseCapsCallback(void);
    73146
    74     /** Guest supports absolute coordinates */
    75     bool fAbsolute;
    76     /** Guest is not able to draw a cursor itself */
    77     bool fNeedsHostCursor;
     147#ifdef VBOXBFE_WITHOUT_COM
     148    Console *mParent;
     149#else
     150    const ComObjPtr<Console, ComWeakRef> mParent;
     151#endif
    78152    /** Pointer to the associated mouse driver. */
    79153    struct DRVMAINMOUSE    *mpDrv;
    80     /** Host capabilities */
     154
    81155    LONG uHostCaps;
     156    LONG uDevCaps;
     157    bool fVMMDevCanAbs;
     158    bool fVMMDevNeedsHostCursor;
     159    uint32_t mLastAbsX;
     160    uint32_t mLastAbsY;
     161    uint32_t mLastButtons;
    82162};
    83163
     164#ifdef VBOXBFE_WITHOUT_COM
    84165extern Mouse *gMouse;
     166#endif
    85167
    86168#endif // !____H_MOUSEIMPL
     169/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette