- Timestamp:
- Nov 29, 2010 3:28:36 PM (14 years ago)
- 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 474 474 machineLogic()->keyboardHandler()->prepareListener(m_uScreenId, this); 475 475 476 /* Register m achine-view in mouse-handler: */477 machineLogic()->mouseHandler()-> addMachineView(m_uScreenId, this->machineView());476 /* Register mouse-handler: */ 477 machineLogic()->mouseHandler()->prepareListener(m_uScreenId, this); 478 478 } 479 479 480 480 void UIMachineWindow::cleanupHandlers() 481 481 { 482 /* Unregister m achine-view from mouse-handler: */483 machineLogic()->mouseHandler()-> delMachineView(m_uScreenId);482 /* Unregister mouse-handler: */ 483 machineLogic()->mouseHandler()->cleanupListener(m_uScreenId); 484 484 485 485 /* Unregister keyboard-handler: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp
r33540 r34471 29 29 #include "UISession.h" 30 30 #include "UIMachineLogic.h" 31 #include "UIMachineWindow.h" 31 32 #include "UIMachineView.h" 32 33 #include "UIFrameBuffer.h" … … 80 81 } 81 82 82 /* Registers new machine-view: */ 83 void UIMouseHandler::addMachineView(ulong uViewIndex, UIMachineView *pMachineView) 84 { 83 /* Prepare listener for particular machine-window: */ 84 void 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 85 95 /* If that view is NOT registered yet: */ 86 if (!m_views.contains(u ViewIndex))96 if (!m_views.contains(uIndex)) 87 97 { 88 98 /* Register machine-view: */ 89 m_views.insert(u ViewIndex, pMachineView);99 m_views.insert(uIndex, pMachineWindow->machineView()); 90 100 /* Install event-filter for machine-view: */ 91 m_views[u ViewIndex]->installEventFilter(this);101 m_views[uIndex]->installEventFilter(this); 92 102 /* Make machine-view notify mouse-handler about resizeHintDone(): */ 93 connect(m_views[u ViewIndex], SIGNAL(resizeHintDone()), this, SLOT(sltMousePointerShapeChanged()));103 connect(m_views[uIndex], SIGNAL(resizeHintDone()), this, SLOT(sltMousePointerShapeChanged())); 94 104 } 95 105 96 106 /* If that viewport is NOT registered yet: */ 97 if (!m_viewports.contains(u ViewIndex))107 if (!m_viewports.contains(uIndex)) 98 108 { 99 109 /* Register machine-view-viewport: */ 100 m_viewports.insert(u ViewIndex, pMachineView->viewport());110 m_viewports.insert(uIndex, pMachineWindow->machineView()->viewport()); 101 111 /* 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: */ 117 void 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)) 111 128 { 112 129 /* Unregister machine-view: */ 113 m_views.remove(u ViewIndex);114 } 115 116 /* If that viewport is registered yet: */117 if (m_viewports.contains(u ViewIndex))130 m_views.remove(uIndex); 131 } 132 133 /* If that viewport still registered: */ 134 if (m_viewports.contains(uIndex)) 118 135 { 119 136 /* Unregister machine-view-viewport: */ 120 m_viewports.remove(u ViewIndex);137 m_viewports.remove(uIndex); 121 138 } 122 139 } … … 427 444 if (QWidget *pWatchedWidget = qobject_cast<QWidget*>(pWatched)) 428 445 { 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: */ 430 492 if (m_viewports.values().contains(pWatchedWidget)) 431 493 { … … 547 609 } 548 610 } 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 }566 611 } 567 612 return QObject::eventFilter(pWatched, pEvent); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.h
r30637 r34471 35 35 class UISession; 36 36 class UIMachineLogic; 37 class UIMachineWindow; 37 38 class UIMachineView; 38 39 #ifdef Q_WS_X11 … … 51 52 static void destroy(UIMouseHandler *pMouseHandler); 52 53 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); 56 57 57 58 /* Commands to capture/release mouse: */ … … 122 123 UIMachineLogic *m_pMachineLogic; 123 124 125 /* Registered machine-windows(s): */ 126 QMap<ulong, QWidget*> m_windows; 124 127 /* Registered machine-view(s): */ 125 128 QMap<ulong, UIMachineView*> m_views;
Note:
See TracChangeset
for help on using the changeset viewer.