VirtualBox

Changeset 34471 in vbox for trunk/src


Ignore:
Timestamp:
Nov 29, 2010 3:28:36 PM (14 years ago)
Author:
vboxsync
Message:

FE/Qt: Mouse-Handler: Extend mouse-handler listener to handle machine-window events. Perform mouse-cursor-clipping update for situations when machine-window was moved by desktop system (win host).

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r33540 r34471  
    474474    machineLogic()->keyboardHandler()->prepareListener(m_uScreenId, this);
    475475
    476     /* Register machine-view in mouse-handler: */
    477     machineLogic()->mouseHandler()->addMachineView(m_uScreenId, this->machineView());
     476    /* Register mouse-handler: */
     477    machineLogic()->mouseHandler()->prepareListener(m_uScreenId, this);
    478478}
    479479
    480480void UIMachineWindow::cleanupHandlers()
    481481{
    482     /* Unregister machine-view from mouse-handler: */
    483     machineLogic()->mouseHandler()->delMachineView(m_uScreenId);
     482    /* Unregister mouse-handler: */
     483    machineLogic()->mouseHandler()->cleanupListener(m_uScreenId);
    484484
    485485    /* Unregister keyboard-handler: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp

    r33540 r34471  
    2929#include "UISession.h"
    3030#include "UIMachineLogic.h"
     31#include "UIMachineWindow.h"
    3132#include "UIMachineView.h"
    3233#include "UIFrameBuffer.h"
     
    8081}
    8182
    82 /* Registers new machine-view: */
    83 void UIMouseHandler::addMachineView(ulong uViewIndex, UIMachineView *pMachineView)
    84 {
     83/* Prepare listener for particular machine-window: */
     84void UIMouseHandler::prepareListener(ulong uIndex, UIMachineWindow *pMachineWindow)
     85{
     86    /* If that window is NOT registered yet: */
     87    if (!m_windows.contains(uIndex))
     88    {
     89        /* Register machine-window: */
     90        m_windows.insert(uIndex, pMachineWindow->machineWindow());
     91        /* Install event-filter for machine-window: */
     92        m_windows[uIndex]->installEventFilter(this);
     93    }
     94
    8595    /* If that view is NOT registered yet: */
    86     if (!m_views.contains(uViewIndex))
     96    if (!m_views.contains(uIndex))
    8797    {
    8898        /* Register machine-view: */
    89         m_views.insert(uViewIndex, pMachineView);
     99        m_views.insert(uIndex, pMachineWindow->machineView());
    90100        /* Install event-filter for machine-view: */
    91         m_views[uViewIndex]->installEventFilter(this);
     101        m_views[uIndex]->installEventFilter(this);
    92102        /* Make machine-view notify mouse-handler about resizeHintDone(): */
    93         connect(m_views[uViewIndex], SIGNAL(resizeHintDone()), this, SLOT(sltMousePointerShapeChanged()));
     103        connect(m_views[uIndex], SIGNAL(resizeHintDone()), this, SLOT(sltMousePointerShapeChanged()));
    94104    }
    95105
    96106    /* If that viewport is NOT registered yet: */
    97     if (!m_viewports.contains(uViewIndex))
     107    if (!m_viewports.contains(uIndex))
    98108    {
    99109        /* Register machine-view-viewport: */
    100         m_viewports.insert(uViewIndex, pMachineView->viewport());
     110        m_viewports.insert(uIndex, pMachineWindow->machineView()->viewport());
    101111        /* Install event-filter for machine-view-viewport: */
    102         m_viewports[uViewIndex]->installEventFilter(this);
    103     }
    104 }
    105 
    106 /* Remove registered machine-view: */
    107 void UIMouseHandler::delMachineView(ulong uViewIndex)
    108 {
    109     /* If that view is registered yet: */
    110     if (m_views.contains(uViewIndex))
     112        m_viewports[uIndex]->installEventFilter(this);
     113    }
     114}
     115
     116/* Cleanup listener for particular machine-window: */
     117void UIMouseHandler::cleanupListener(ulong uIndex)
     118{
     119    /* If that window still registered: */
     120    if (m_windows.contains(uIndex))
     121    {
     122        /* Unregister machine-window: */
     123        m_windows.remove(uIndex);
     124    }
     125
     126    /* If that view still registered: */
     127    if (m_views.contains(uIndex))
    111128    {
    112129        /* Unregister machine-view: */
    113         m_views.remove(uViewIndex);
    114     }
    115 
    116     /* If that viewport is registered yet: */
    117     if (m_viewports.contains(uViewIndex))
     130        m_views.remove(uIndex);
     131    }
     132
     133    /* If that viewport still registered: */
     134    if (m_viewports.contains(uIndex))
    118135    {
    119136        /* Unregister machine-view-viewport: */
    120         m_viewports.remove(uViewIndex);
     137        m_viewports.remove(uIndex);
    121138    }
    122139}
     
    427444    if (QWidget *pWatchedWidget = qobject_cast<QWidget*>(pWatched))
    428445    {
    429         /* If it's a machine-view-viewport: */
     446        /* Check if that widget is in windows list: */
     447        if (m_windows.values().contains(pWatchedWidget))
     448        {
     449#ifdef Q_WS_WIN
     450            /* Handle window events: */
     451            switch (pEvent->type())
     452            {
     453                case QEvent::Move:
     454                {
     455                    /* Update mouse clipping if window was moved
     456                     * by Operating System desktop manager: */
     457                    updateMouseCursorClipping();
     458                    break;
     459                }
     460                default:
     461                    break;
     462            }
     463#endif /* Q_WS_WIN */
     464        }
     465
     466        else
     467
     468        /* Check if that widget is of UIMachineView type: */
     469        if (UIMachineView *pWatchedMachineView = qobject_cast<UIMachineView*>(pWatchedWidget))
     470        {
     471            /* Check if that widget is in views list: */
     472            if (m_views.values().contains(pWatchedMachineView))
     473            {
     474                /* Handle view events: */
     475                switch (pEvent->type())
     476                {
     477                    case QEvent::FocusOut:
     478                    {
     479                        /* Release the mouse: */
     480                        releaseMouse();
     481                        break;
     482                    }
     483                    default:
     484                        break;
     485                }
     486            }
     487        }
     488
     489        else
     490
     491        /* Check if that widget is in viewports list: */
    430492        if (m_viewports.values().contains(pWatchedWidget))
    431493        {
     
    547609            }
    548610        }
    549         /* If no => check if that widget is of UIMachineView type: */
    550         else if (UIMachineView *pWatchedMachineView = qobject_cast<UIMachineView*>(pWatchedWidget))
    551         {
    552             /* If it's a machine-view itself => handle machine-view events: */
    553             if (m_views.values().contains(pWatchedMachineView))
    554             {
    555                 switch (pEvent->type())
    556                 {
    557                     case QEvent::FocusOut:
    558                         /* Just release the mouse: */
    559                         releaseMouse();
    560                         break;
    561                     default:
    562                         break;
    563                 }
    564             }
    565         }
    566611    }
    567612    return QObject::eventFilter(pWatched, pEvent);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.h

    r30637 r34471  
    3535class UISession;
    3636class UIMachineLogic;
     37class UIMachineWindow;
    3738class UIMachineView;
    3839#ifdef Q_WS_X11
     
    5152    static void destroy(UIMouseHandler *pMouseHandler);
    5253
    53     /* Registers/Remove new machine-view: */
    54     void addMachineView(ulong uViewIndex, UIMachineView *pMachineView);
    55     void delMachineView(ulong uViewIndex);
     54    /* Prepare/cleanup listener for particular machine-window: */
     55    void prepareListener(ulong uIndex, UIMachineWindow *pMachineWindow);
     56    void cleanupListener(ulong uIndex);
    5657
    5758    /* Commands to capture/release mouse: */
     
    122123    UIMachineLogic *m_pMachineLogic;
    123124
     125    /* Registered machine-windows(s): */
     126    QMap<ulong, QWidget*> m_windows;
    124127    /* Registered machine-view(s): */
    125128    QMap<ulong, UIMachineView*> m_views;
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