VirtualBox

Changeset 53119 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Oct 22, 2014 3:08:07 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: UIKeyboardHandler: attempt to fix keyboard focus problem with Host-Home popup menu, restricted to multimonitor VMs

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
2 edited

Legend:

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

    r53079 r53119  
    208208                 * and after we will just ignore that issue: */
    209209                int cTriesLeft = 50;
    210                 XEvent dummy;
     210
     211                if (m_cMonitors > 1)
     212                {
     213                    /* Do this hack only for multimonitor VMs. */
     214                    XEvent dummy;
     215
     216                    /* If a grab succeeds, X11 will insert a FocusIn event for this
     217                     * window into the event queue.  If there is already a FocusOut
     218                     * event pending we do not want this to happen (this can
     219                     * actually cause two machine windows to fight for the focus).
     220                     * It would be nicer to put the event back to the right place
     221                     * in the queue, but X11 doesn't help us there, and even Qt
     222                     * does it like this. */
     223                    if (XCheckTypedWindowEvent(QX11Info::display(),
     224                                m_windows[m_iKeyboardCaptureViewIndex]->winId(),
     225                                XFocusOut, &dummy))
     226                    {
     227                        XPutBackEvent(QX11Info::display(), &dummy);
     228                        break;
     229                    }
     230                }
     231
    211232                while (cTriesLeft && XGrabKeyboard(QX11Info::display(), m_windows[m_iKeyboardCaptureViewIndex]->winId(), False, GrabModeAsync, GrabModeAsync, CurrentTime)) { --cTriesLeft; }
    212                 /* If the grab succeeds, X will insert a FocusIn event for this
    213                  * window into the event queue.  If we have two windows they can
    214                  * end up in an endless cycle of passing the focus back and
    215                  * forward as there is always a pending FocusIn for each, and we
    216                  * drop and re-take the grab each time the focus changes.  So we
    217                  * remove the event again before Qt can see it. */
    218                 if (cTriesLeft > 0)
    219                     XCheckTypedWindowEvent(QX11Info::display(),
    220                             m_windows[m_iKeyboardCaptureViewIndex]->winId(),
    221                             XFocusIn, &dummy);
    222233                break;
    223234            }
     
    791802    , m_iKeyboardGrabViewIndex(-1)
    792803#endif
     804    , m_cMonitors(1)
    793805{
    794806    /* Prepare: */
     
    816828    /* Pressed keys: */
    817829    ::memset(m_pressedKeys, 0, sizeof(m_pressedKeys));
     830
     831    m_cMonitors = uisession()->machine().GetMonitorCount();
    818832}
    819833
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.h

    r53079 r53119  
    196196    int m_iKeyboardGrabViewIndex;
    197197#endif
     198
     199    ULONG m_cMonitors;
    198200};
    199201
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