Changeset 61945 in vbox
- Timestamp:
- Jun 30, 2016 6:04:58 AM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 2 edited
-
UIKeyboardHandler.cpp (modified) (10 diffs)
-
UIMachineView.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp
r61745 r61945 315 315 * S.a. UIKeyboardHandler::eventFilter for more information. */ 316 316 317 #elif defined(VBOX_WS_X11) 317 #elif defined(VBOX_WS_X11) && QT_VERSION < 0x050000 318 318 319 319 /* On X11, we are using passive XGrabKey for normal (windowed) mode … … 328 328 case UIVisualStateType_Scale: 329 329 { 330 # if QT_VERSION >= 0x050000331 xcb_grab_key_checked(QX11Info::connection(), 0, m_windows.value(uScreenId)->winId(), XCB_MOD_MASK_ANY, XCB_GRAB_ANY, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);332 # else /* QT_VERSION < 0x050000 */333 330 XGrabKey(QX11Info::display(), AnyKey, AnyModifier, m_windows[uScreenId]->winId(), False, GrabModeAsync, GrabModeAsync); 334 # endif /* QT_VERSION < 0x050000 */335 331 break; 336 332 } … … 339 335 case UIVisualStateType_Seamless: 340 336 { 341 # if QT_VERSION >= 0x050000342 xcb_grab_keyboard(QX11Info::connection(), 0, m_windows.value(uScreenId)->winId(), XCB_CURRENT_TIME, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);343 # else /* QT_VERSION < 0x050000 */344 337 /* Keyboard grabbing can fail because of some keyboard shortcut is still grabbed by window manager. 345 338 * We can't be sure this shortcut will be released at all, so we will retry to grab keyboard for 50 times, … … 357 350 CurrentTime)) 358 351 --cTriesLeft; 359 # endif /* QT_VERSION < 0x050000 */360 352 break; 361 353 } … … 369 361 /* On other platforms we are just praying Qt method to work: */ 370 362 m_views[uScreenId]->grabKeyboard(); 363 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000 364 /* Mouse capture hack for when the keyboard is captured. We do not 365 * check for failure as we do not currently implement a back-up plan. */ 366 if (!uisession()->isMouseCaptured()) 367 xcb_grab_button_checked(QX11Info::connection(), 0, QX11Info::appRootWindow(), XCB_EVENT_MASK_BUTTON_PRESS, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE, XCB_BUTTON_INDEX_1, XCB_MOD_MASK_ANY); 368 #endif /* defined(VBOX_WS_X11) && QT_VERSION >= 0x050000 */ 371 369 372 370 #endif … … 414 412 * S.a. UIKeyboardHandler::eventFilter for more information. */ 415 413 416 #elif defined(VBOX_WS_X11) 414 #elif defined(VBOX_WS_X11) && QT_VERSION < 0x050000 417 415 418 416 /* On X11, we are using passive XGrabKey for normal (windowed) mode … … 427 425 case UIVisualStateType_Scale: 428 426 { 429 # if QT_VERSION >= 0x050000430 xcb_ungrab_key(QX11Info::connection(), XCB_GRAB_ANY, m_windows.value(m_iKeyboardCaptureViewIndex)->winId(), XCB_MOD_MASK_ANY);431 # else /* QT_VERSION < 0x050000 */432 427 XUngrabKey(QX11Info::display(), AnyKey, AnyModifier, m_windows[m_iKeyboardCaptureViewIndex]->winId()); 433 # endif /* QT_VERSION < 0x050000 */434 428 break; 435 429 } … … 438 432 case UIVisualStateType_Seamless: 439 433 { 440 # if QT_VERSION >= 0x050000441 xcb_ungrab_keyboard(QX11Info::connection(), CurrentTime);442 # else /* QT_VERSION < 0x050000 */443 434 XUngrabKeyboard(QX11Info::display(), CurrentTime); 444 # endif /* QT_VERSION < 0x050000 */445 435 break; 446 436 } … … 454 444 /* On other platforms we are just praying Qt method to work: */ 455 445 m_views[m_iKeyboardCaptureViewIndex]->releaseKeyboard(); 446 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000 447 /* Mouse capture hack for when the keyboard is captured. */ 448 if (!uisession()->isMouseCaptured()) 449 xcb_ungrab_button_checked(QX11Info::connection(), XCB_BUTTON_INDEX_1, QX11Info::appRootWindow(), XCB_MOD_MASK_ANY); 450 #endif /* defined(VBOX_WS_X11) && QT_VERSION >= 0x050000 */ 456 451 457 452 #endif … … 1386 1381 fResult = keyEvent(ks, uScan, iflags, uScreenId); 1387 1382 1383 break; 1384 } 1385 /* If we see a mouse press outside of our views while the mouse is not 1386 * captured, release the keyboard before letting the event owner see it. 1387 * This is because some owners cannot deal with failures to grab the 1388 * keyboard themselves (e.g. window managers dragging windows). Only 1389 * works if we have passively grabbed the mouse button. */ 1390 case XCB_BUTTON_PRESS: 1391 { 1392 /* Cast to XCB key-event: */ 1393 xcb_button_press_event_t *pButtonEvent = static_cast<xcb_button_press_event_t*>(pMessage); 1394 QWidget *pWidget = qApp->widgetAt(pButtonEvent->root_x, pButtonEvent->root_y); 1395 1396 if (uisession()->isMouseCaptured()) 1397 break; 1398 if (pWidget) 1399 { 1400 QPoint pos = pWidget->mapFromGlobal(QPoint(pButtonEvent->root_x, pButtonEvent->root_y)); 1401 pButtonEvent->event = pWidget->effectiveWinId(); 1402 pButtonEvent->event_x = pos.x(); 1403 pButtonEvent->event_y = pos.y(); 1404 xcb_allow_events_checked(QX11Info::connection(), XCB_ALLOW_REPLAY_POINTER, pButtonEvent->time); 1405 break; 1406 } 1407 m_views[m_iKeyboardCaptureViewIndex]->releaseKeyboard(); 1408 xcb_allow_events_checked(QX11Info::connection(), XCB_ALLOW_REPLAY_POINTER, pButtonEvent->time); 1388 1409 break; 1389 1410 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r61242 r61945 1909 1909 case XCB_KEY_PRESS: 1910 1910 case XCB_KEY_RELEASE: 1911 { 1912 /* Delegate key-event handling to the keyboard-handler: */ 1911 case XCB_BUTTON_PRESS: 1912 { 1913 /* Delegate key-event handling to the keyboard-handler and let it 1914 * filter out button presses out of the view windows: */ 1913 1915 return machineLogic()->keyboardHandler()->nativeEventPostprocessor(pMessage, screenId()); 1914 1916 }
Note:
See TracChangeset
for help on using the changeset viewer.

