Changeset 63599 in vbox
- Timestamp:
- Aug 19, 2016 1:19:42 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 110298
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp
r63587 r63599 39 39 # ifdef VBOX_WS_X11 40 40 # include <QX11Info> 41 # endif /* VBOX_WS_X11 */ 41 # if QT_VERSION >= 0x050000 42 # include <QTimer> 43 # endif 44 # endif 42 45 43 46 /* GUI includes: */ … … 255 258 } 256 259 257 /* If suchview exists: */260 /* If the view exists: */ 258 261 if (m_views.contains(uScreenId)) 259 262 { … … 326 329 327 330 /* On X11, we do not grab the keyboard as soon as it is captured, but delay it 328 * until the first keypress after thecapture. We do this for several reasons:331 * for 300 milliseconds after the formal capture. We do this for several reasons: 329 332 * - First, when several windows are created they all try to capture the keyboard when 330 333 * they get the focus. Due to the asynchronous nature of X11 the first window may only … … 335 338 * by refusing to e.g. drag a window using its title bar. */ 336 339 340 /* Delay finalising capture for 300 milliseconds: */ 341 QTimer::singleShot(300, this, SLOT(sltFinaliseCaptureKeyboard())); 342 337 343 # endif /* QT_VERSION >= 0x050000 */ 338 344 #else … … 343 349 #endif 344 350 345 /* Remember which screen wish to capture the keyboard: */351 /* Remember which screen wishes to capture the keyboard: */ 346 352 m_iKeyboardCaptureViewIndex = uScreenId; 347 353 348 354 #if !defined(VBOX_WS_X11) || QT_VERSION < 0x050000 349 /* Finalis ingkeyboard capture: */355 /* Finalise keyboard capture: */ 350 356 finaliseCaptureKeyboard(); 351 357 #endif … … 353 359 } 354 360 355 voidUIKeyboardHandler::finaliseCaptureKeyboard()361 bool UIKeyboardHandler::finaliseCaptureKeyboard() 356 362 { 357 363 /* Do NOT capture the keyboard if it is already captured: */ 358 364 if (m_fIsKeyboardCaptured) 359 return ;365 return true; 360 366 361 367 /* Make sure capture was really requested: */ 362 368 if (m_iKeyboardCaptureViewIndex == -1) 363 return ;364 365 /* If suchview exists: */369 return true; 370 371 /* If the view exists: */ 366 372 if (m_views.contains(m_iKeyboardCaptureViewIndex)) 367 373 { … … 386 392 /* Try again later: */ 387 393 free(pGrabReply); 388 return ;394 return false; 389 395 } 390 396 free(pGrabReply); … … 397 403 /* Notify all the listeners: */ 398 404 emit sigStateChange(state()); 399 } 405 406 return true; 407 } 408 409 return false; 400 410 } 401 411 … … 410 420 } 411 421 412 /* If suchview exists: */422 /* If the view exists: */ 413 423 if (m_views.contains(m_iKeyboardCaptureViewIndex)) 414 424 { … … 1356 1366 case XCB_KEY_RELEASE: 1357 1367 { 1358 /* If we were asked to grab the keyboard previously but had to delay it1359 * then try again on every key press and release event until we manage: */1360 finaliseCaptureKeyboard();1361 1362 1368 /* Cast to XCB key-event: */ 1363 1369 xcb_key_press_event_t *pKeyEvent = static_cast<xcb_key_press_event_t*>(pMessage); … … 1539 1545 popupCenter().forgetAboutPausedVMInput(machineLogic()->activeMachineWindow()); 1540 1546 } 1547 1548 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000 1549 void UIKeyboardHandler::sltFinaliseCaptureKeyboard() 1550 { 1551 /* Try to finalise keyboard capture: */ 1552 if (!finaliseCaptureKeyboard()) 1553 { 1554 /* Try again in another 300 milliseconds in case of failure: */ 1555 QTimer::singleShot(300, this, SLOT(sltFinaliseCaptureKeyboard())); 1556 } 1557 } 1558 #endif 1541 1559 1542 1560 /* Keyboard-handler constructor: */ … … 2102 2120 { 2103 2121 captureKeyboard(uScreenId); 2104 finaliseCaptureKeyboard();2105 2122 #ifdef VBOX_WS_X11 2106 2123 /* Make sure that pending FocusOut events from the … … 2110 2127 qApp->processEvents(); 2111 2128 #endif /* VBOX_WS_X11 */ 2129 finaliseCaptureKeyboard(); 2112 2130 if (fCaptureMouse) 2113 2131 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.h
r63587 r63599 83 83 /** Captures the keyboard for @a uScreenId. */ 84 84 void captureKeyboard(ulong uScreenId); 85 /** Finalises keyboard captur ing. */86 voidfinaliseCaptureKeyboard();85 /** Finalises keyboard capture. */ 86 bool finaliseCaptureKeyboard(); 87 87 /** Releases the keyboard. */ 88 88 void releaseKeyboard(); … … 133 133 virtual void sltMachineStateChanged(); 134 134 135 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000 136 /** Finalises keyboard capture. */ 137 void sltFinaliseCaptureKeyboard(); 138 #endif 139 135 140 protected: 136 141
Note:
See TracChangeset
for help on using the changeset viewer.