VirtualBox

Changeset 66495 in vbox


Ignore:
Timestamp:
Apr 10, 2017 10:02:09 AM (7 years ago)
Author:
vboxsync
Message:

bugref:8151: FE/Qt: improve X11 keyboard capturing: check whether a mouse button grab is in process before attempting a new one and release it if so.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp

    r66389 r66495  
    371371         * the same problem. At present we just let that problem be.) */
    372372
    373          /* Grab the mouse button.
    374           * We do not check for failure as we do not currently implement a back-up plan. */
    375          m_hButtonGrabWindow = QX11Info::appRootWindow();
    376          xcb_grab_button_checked(QX11Info::connection(), 0, m_hButtonGrabWindow,
    377                                  XCB_EVENT_MASK_BUTTON_PRESS, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC,
    378                                  XCB_NONE, XCB_NONE, XCB_BUTTON_INDEX_ANY, XCB_MOD_MASK_ANY);
     373        /* Grab the mouse button.
     374         * We do not check for failure as we do not currently implement a back-up plan. */
     375        /* If any previous grab is still in process, release it. */
     376        if (m_hButtonGrabWindow != 0)
     377            xcb_ungrab_button_checked(QX11Info::connection(), XCB_BUTTON_INDEX_ANY,
     378                                      m_hButtonGrabWindow, XCB_MOD_MASK_ANY);
     379        m_hButtonGrabWindow = QX11Info::appRootWindow();
     380        xcb_grab_button_checked(QX11Info::connection(), 0, m_hButtonGrabWindow,
     381                                XCB_EVENT_MASK_BUTTON_PRESS, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC,
     382                                XCB_NONE, XCB_NONE, XCB_BUTTON_INDEX_ANY, XCB_MOD_MASK_ANY);
    379383        /* And grab the keyboard, using XCB directly, as Qt does not report failure. */
    380384        xcb_grab_keyboard_cookie_t xcbGrabCookie = xcb_grab_keyboard(QX11Info::connection(), false, m_views[m_iKeyboardCaptureViewIndex]->winId(),
     
    387391            xcb_ungrab_button_checked(QX11Info::connection(), XCB_BUTTON_INDEX_ANY,
    388392                                      m_hButtonGrabWindow, XCB_MOD_MASK_ANY);
     393            m_hButtonGrabWindow = 0;
    389394            /* Try again later: */
    390395            free(pGrabReply);
     
    489494        xcb_ungrab_button_checked(QX11Info::connection(), XCB_BUTTON_INDEX_ANY,
    490495                                  m_hButtonGrabWindow, XCB_MOD_MASK_ANY);
     496        m_hButtonGrabWindow = 0;
    491497
    492498# endif /* QT_VERSION >= 0x050000 */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette