- Timestamp:
- Jul 1, 2016 5:13:12 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp
r61954 r61987 315 315 * S.a. UIKeyboardHandler::eventFilter for more information. */ 316 316 317 #elif defined(VBOX_WS_X11) && QT_VERSION < 0x050000 317 #elif defined(VBOX_WS_X11) 318 # if QT_VERSION < 0x050000 318 319 319 320 /* On X11, we are using passive XGrabKey for normal (windowed) mode … … 357 358 } 358 359 360 # else /* QT_VERSION >= 0x050000 */ 361 362 /* On X11, we are using Qt5 method to grab the keyboard. 363 * This wrapper is using xcb_grab_keyboard function which is a part of active keyboard grabbing. 364 * Active keyboard grabbing causes a problems on certain old window managers - a window cannot 365 * be moved using the mouse. So we additionally grabbing the mouse as well to detect that user 366 * is trying to click outside of internal window geometry. */ 367 368 /* Use the Qt5 keyboard grabbing: */ 369 m_views[uScreenId]->grabKeyboard(); 370 /* And grab the mouse button (if mouse is not captured), 371 * We do not check for failure as we do not currently implement a back-up plan. */ 372 if (!uisession()->isMouseCaptured()) 373 xcb_grab_button_checked(QX11Info::connection(), 0, QX11Info::appRootWindow(), 374 XCB_EVENT_MASK_BUTTON_PRESS, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, 375 XCB_NONE, XCB_NONE, XCB_BUTTON_INDEX_1, XCB_MOD_MASK_ANY); 376 377 # endif /* QT_VERSION >= 0x050000 */ 359 378 #else 360 379 361 380 /* On other platforms we are just praying Qt method to work: */ 362 381 m_views[uScreenId]->grabKeyboard(); 363 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000364 /* Mouse capture hack for when the keyboard is captured. We do not365 * 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 */369 382 370 383 #endif … … 412 425 * S.a. UIKeyboardHandler::eventFilter for more information. */ 413 426 414 #elif defined(VBOX_WS_X11) && QT_VERSION < 0x050000 427 #elif defined(VBOX_WS_X11) 428 # if QT_VERSION < 0x050000 415 429 416 430 /* On X11, we are using passive XGrabKey for normal (windowed) mode … … 440 454 } 441 455 456 # else /* QT_VERSION >= 0x050000 */ 457 458 /* On X11, we are using Qt5 method to release the keyboard. 459 * This wrapper is using xcb_ungrab_keyboard function which is a part of active keyboard grabbing. 460 * Active keyboard grabbing causes a problems on certain old window managers - a window cannot 461 * be moved using the mouse. So we finally releasing additionally grabbed mouse as well to 462 * allow further user interactions. */ 463 464 /* Use the Qt5 keyboard releasing: */ 465 m_views[m_iKeyboardCaptureViewIndex]->releaseKeyboard(); 466 /* And release the mouse button, 467 * We do not check for failure as we do not currently implement a back-up plan. */ 468 xcb_ungrab_button_checked(QX11Info::connection(), XCB_BUTTON_INDEX_1, QX11Info::appRootWindow(), XCB_MOD_MASK_ANY); 469 470 # endif /* QT_VERSION >= 0x050000 */ 442 471 #else 443 472 444 473 /* On other platforms we are just praying Qt method to work: */ 445 474 m_views[m_iKeyboardCaptureViewIndex]->releaseKeyboard(); 446 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000447 /* 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 */451 475 452 476 #endif … … 1385 1409 break; 1386 1410 } 1387 /* If we see a mouse press outside of our views while the mouse is not 1388 * captured, release the keyboard before letting the event owner see it. 1389 * This is because some owners cannot deal with failures to grab the 1390 * keyboard themselves (e.g. window managers dragging windows). Only 1391 * works if we have passively grabbed the mouse button. */ 1411 /* Watch for mouse-events: */ 1392 1412 case XCB_BUTTON_PRESS: 1393 1413 { 1414 /* Do nothing if mouse is actively grabbed: */ 1415 if (uisession()->isMouseCaptured()) 1416 break; 1417 1418 /* If we see a mouse press outside of our views while the mouse is not 1419 * captured, release the keyboard before letting the event owner see it. 1420 * This is because some owners cannot deal with failures to grab the 1421 * keyboard themselves (e.g. window managers dragging windows). 1422 * Only works if we have passively grabbed the mouse button. */ 1423 1394 1424 /* Cast to XCB key-event: */ 1395 1425 xcb_button_press_event_t *pButtonEvent = static_cast<xcb_button_press_event_t*>(pMessage); 1396 QWidget *pWidget = qApp->widgetAt(pButtonEvent->root_x, pButtonEvent->root_y); 1397 1398 if (uisession()->isMouseCaptured()) 1399 break; 1426 1427 /* Detect the widget which should receive the event actually: */ 1428 const QWidget *pWidget = qApp->widgetAt(pButtonEvent->root_x, pButtonEvent->root_y); 1400 1429 if (pWidget) 1401 1430 { 1402 QPoint pos = pWidget->mapFromGlobal(QPoint(pButtonEvent->root_x, pButtonEvent->root_y)); 1431 /* Redirect the event to corresponding widget: */ 1432 const QPoint pos = pWidget->mapFromGlobal(QPoint(pButtonEvent->root_x, pButtonEvent->root_y)); 1403 1433 pButtonEvent->event = pWidget->effectiveWinId(); 1404 1434 pButtonEvent->event_x = pos.x(); … … 1407 1437 break; 1408 1438 } 1409 m_views[m_iKeyboardCaptureViewIndex]->releaseKeyboard(); 1439 /* Release the keyboard finally: */ 1440 releaseKeyboard(); 1410 1441 xcb_allow_events_checked(QX11Info::connection(), XCB_ALLOW_REPLAY_POINTER, pButtonEvent->time); 1411 1442 break;
Note:
See TracChangeset
for help on using the changeset viewer.