Changeset 63579 in vbox
- Timestamp:
- Aug 17, 2016 3:45:21 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 6 edited
-
platform/darwin/CocoaEventHelper.h (modified) (1 diff)
-
platform/darwin/CocoaEventHelper.mm (modified) (2 diffs)
-
runtime/UIKeyboardHandler.cpp (modified) (2 diffs)
-
runtime/UIMachineView.cpp (modified) (3 diffs)
-
runtime/UIMouseHandler.cpp (modified) (3 diffs)
-
runtime/UIMouseHandler.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/CocoaEventHelper.h
r62493 r63579 36 36 const char *darwinEventTypeName(unsigned long eEvtType); 37 37 void darwinPrintEvent(const char *pszPrefix, ConstNativeNSEventRef pEvent); 38 void darwinPostStrippedMouseEvent(ConstNativeNSEventRef pEvent); 38 39 39 40 RT_C_DECLS_END -
trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/CocoaEventHelper.mm
r52727 r63579 21 21 22 22 /* Global includes */ 23 #import <Cocoa/Cocoa.h> 23 24 #import <AppKit/NSEvent.h> 24 25 #include <Carbon/Carbon.h> … … 293 294 } 294 295 296 void darwinPostStrippedMouseEvent(ConstNativeNSEventRef pEvent) 297 { 298 /* Create and post new stripped event: */ 299 NSEvent *pNewEvent = [NSEvent mouseEventWithType:[pEvent type] 300 location:[pEvent locationInWindow] 301 modifierFlags:0 302 timestamp:[pEvent timestamp] // [NSDate timeIntervalSinceReferenceDate] ? 303 windowNumber:[pEvent windowNumber] 304 context:[pEvent context] 305 eventNumber:[pEvent eventNumber] 306 clickCount:[pEvent clickCount] 307 pressure:[pEvent pressure]]; 308 [NSApp postEvent:pNewEvent atStart:YES]; 309 } 310 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp
r63578 r63579 593 593 /* Depending on event kind: */ 594 594 const UInt32 uEventKind = ::GetEventKind(event); 595 switch (uEventKind)595 switch (uEventKind) 596 596 { 597 597 /* Watch for simple key-events: */ … … 1045 1045 /* Depending on event kind: */ 1046 1046 const UInt32 uEventKind = ::GetEventKind(event); 1047 switch (uEventKind)1047 switch (uEventKind) 1048 1048 { 1049 1049 /* Watch for simple key-events: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r63578 r63579 1786 1786 * Returning @c false means passing event to Qt. */ 1787 1787 bool fResult = false; /* Pass to Qt by default. */ 1788 switch (::GetEventClass(event))1788 switch (::GetEventClass(event)) 1789 1789 { 1790 1790 /* Watch for keyboard-events: */ 1791 1791 case kEventClassKeyboard: 1792 1792 { 1793 switch (::GetEventKind(event))1793 switch (::GetEventKind(event)) 1794 1794 { 1795 1795 /* Watch for key-events: */ … … 1915 1915 EventRef event = static_cast<EventRef>(darwinCocoaToCarbonEvent(pMessage)); 1916 1916 1917 switch (::GetEventClass(event))1917 switch (::GetEventClass(event)) 1918 1918 { 1919 1919 /* Watch for keyboard-events: */ 1920 1920 case kEventClassKeyboard: 1921 1921 { 1922 switch (::GetEventKind(event))1922 switch (::GetEventKind(event)) 1923 1923 { 1924 1924 /* Watch for key-events: */ … … 1936 1936 break; 1937 1937 } 1938 /* Watch for mouse-events: */ 1939 case kEventClassMouse: 1940 { 1941 switch (::GetEventKind(event)) 1942 { 1943 /* Watch for button-events: */ 1944 case kEventMouseDown: 1945 case kEventMouseUp: 1946 { 1947 /* Delegate button-event handling to the mouse-handler: */ 1948 return machineLogic()->mouseHandler()->nativeEventFilter(pMessage, screenId()); 1949 } 1950 default: 1951 break; 1952 } 1953 break; 1954 } 1938 1955 default: 1939 1956 break; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp
r63175 r63579 55 55 #include <QTouchEvent> 56 56 57 /* GUI includes: */ 58 #if defined(VBOX_WS_MAC) && QT_VERSION >= 0x050000 59 # include "CocoaEventHelper.h" 60 #endif 61 57 62 /* COM includes: */ 58 63 #include "CMouse.h" … … 264 269 } 265 270 266 #ifdef VBOX_WS_X11 267 # if QT_VERSION < 0x050000 271 #if QT_VERSION < 0x050000 272 # ifdef VBOX_WS_X11 273 268 274 bool UIMouseHandler::x11EventFilter(XEvent *pEvent, ulong /* uScreenId */) 269 275 { … … 293 299 return fResult; 294 300 } 295 # endif /* QT_VERSION < 0x050000 */ 296 #endif /* VBOX_WS_X11 */ 301 302 # endif /* VBOX_WS_X11 */ 303 #else /* QT_VERSION >= 0x050000 */ 304 305 bool UIMouseHandler::nativeEventFilter(void *pMessage, ulong uScreenId) 306 { 307 /* Make sure view with passed index exists: */ 308 if (!m_views.contains(uScreenId)) 309 return false; 310 311 /* Check if some system event should be filtered out. 312 * Returning @c true means filtering-out, 313 * Returning @c false means passing event to Qt. */ 314 bool fResult = false; /* Pass to Qt by default. */ 315 316 # if defined(VBOX_WS_MAC) 317 318 /* Acquire carbon event reference from the cocoa one: */ 319 EventRef event = static_cast<EventRef>(darwinCocoaToCarbonEvent(pMessage)); 320 321 /* Depending on event kind: */ 322 const UInt32 uEventKind = ::GetEventKind(event); 323 switch (uEventKind) 324 { 325 /* Watch for button-events: */ 326 case kEventMouseDown: 327 case kEventMouseUp: 328 { 329 /* Acquire button number: */ 330 EventMouseButton enmButton = 0; 331 ::GetEventParameter(event, kEventParamMouseButton, typeMouseButton, 332 NULL, sizeof(enmButton), NULL, &enmButton); 333 /* If the event comes for primary mouse button: */ 334 if (enmButton == kEventMouseButtonPrimary) 335 { 336 /* Acquire modifiers: */ 337 UInt32 uKeyModifiers = ~0U; 338 ::GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, 339 NULL, sizeof(uKeyModifiers), NULL, &uKeyModifiers); 340 /* If the event comes with Control modifier: */ 341 if (uKeyModifiers == controlKey) 342 { 343 /* Replacing it with the stripped one: */ 344 darwinPostStrippedMouseEvent(pMessage); 345 /* And filter out initial one: */ 346 return true; 347 } 348 } 349 } 350 } 351 352 # elif defined(VBOX_WS_WIN) 353 354 /* Nothing for now. */ 355 356 # elif defined(VBOX_WS_X11) 357 358 /* Nothing for now. */ 359 360 # else 361 362 # warning "port me!" 363 364 # endif 365 366 /* Return result: */ 367 return fResult; 368 } 369 370 #endif /* QT_VERSION >= 0x050000 */ 297 371 298 372 /* Machine state-change handler: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.h
r62493 r63579 75 75 int state() const; 76 76 77 #if def VBOX_WS_X1178 # if QT_VERSION < 0x05000079 /** X11: Qt4: Handles allnative events. */77 #if QT_VERSION < 0x050000 78 # ifdef VBOX_WS_X11 79 /** Qt4: X11: Performs pre-processing of all the native events. */ 80 80 bool x11EventFilter(XEvent *pEvent, ulong uScreenId); 81 # endif /* QT_VERSION < 0x050000 */ 82 #endif /* VBOX_WS_X11 */ 81 # endif 82 #else 83 /** Qt5: Performs pre-processing of all the native events. */ 84 bool nativeEventFilter(void *pMessage, ulong uScreenId); 85 #endif 83 86 84 87 protected slots:
Note:
See TracChangeset
for help on using the changeset viewer.

