Mouse click stops working on host/guest due to window focusOutEvent problem in Qt GUI

Discussions related to using VirtualBox on Linux hosts.

Mouse click stops working on host/guest due to window focusOutEvent problem in Qt GUI

Postby Cryptkeeper » 7. May 2021, 17:37

Hi,

for more than two years now (so probably since VB version 6.0 or so) from time to time I am affected by a very anoying bug. Then mouse clicks stops working on the host and the guest as well. I can still move the mouse pointer but clicks are not recognized anymore. The only solution then is to shut down *all* running guest instances. Then the mouse clicks starts working again.

I am sure it is not a drag and drop problem like in https://www.virtualbox.org/ticket/14743

There will be no entry in the logs, when the bug occurs. It happend very randomly to me but after a while with a screen record I figured out the following steps to reliable reproduce the bug:

1) Click on the taskbar to restore VM window from minimized state
2) Press down the mouse button on the taskbar and keep it pressed
3) Release the mouse button and immediatly press it again
4) Now no further clicks are registered until VM is shut down

(I agree that this looks like a very special and rare circumstance - however I think that this bug is a race condition and as I often switch between different windows with the taskbar I'm hit by it very often.)

Here is a screencast of the bug as GIF: https://s3.gifyu.com/images/vbox-bug.gif

When the bug occurs *xprop* on the hosts exits with the error "xprop: error: Can't grab the mouse" - on the guest it just hangs as no click is registered. Also the bug only occurs with the Qt front end of VirtualBox - with the SDL front end I couldn't reproduce the error.

From the steps I assume that the bug is kind of a race condition on the minimize respectively focus out / focus in event of the window. So I tried to build VirtualBox from source and try to trace the bug. And indeed I figured out, that the bug does not occure if I comment out the following 3 lines in the file src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp.

Code: Select all   Expand viewCollapse view
void UIMachineView::focusOutEvent(QFocusEvent *pEvent)
{
    /* If native event filter exists: */
    if (m_pNativeEventFilter)
    {
        /* Uninstall/destroy existing native event filter: */
           
        //qApp->removeNativeEventFilter(m_pNativeEventFilter);
        //delete m_pNativeEventFilter;
        //m_pNativeEventFilter = 0;
    }

    /* Call to base-class: */
    QAbstractScrollArea::focusOutEvent(pEvent);
}


I tried to dig deeper but I'm kind of stuck. Because I don't know what this native event filter is used for and why it is destroyed on focus out event.

Can anyone help me to debug this further?

Thanks a lot!
Cryptkeeper
 
Posts: 1
Joined: 7. May 2021, 17:31

Re: Mouse click stops working on host/guest due to window focusOutEvent problem in Qt GUI

Postby scottgus1 » 9. May 2021, 15:16

Good detective work! This would be a good thing to post on the Bugtracker, for the devs to see. Most of us, especially me, haven't gone that deep into the code to know how to fix this.
scottgus1
Site Moderator
 
Posts: 13005
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Mouse click stops working on host/guest due to window focusOutEvent problem in Qt GUI

Postby Seann » 3. Jun 2021, 15:24

I have been having the same problem as well for years. My temporary workaround was not to go into full screen mode. I recently upgraded to Fedora 33 and VirtualBox 6.1.22 and problem seemed to be fixed (or so I thought) because it usually happened right away. After running in full screen for three days my mouse pointer was hung. I tried xwininfo and xprop to determine which process had control of my mouse. With either command I received 'Can't grab the mouse'. When searching for the solution I was able to find this forum post.

I guess this is a long way of saying, "me too!"
Seann
 
Posts: 5
Joined: 28. Jan 2015, 19:41


Return to VirtualBox on Linux Hosts

Who is online

Users browsing this forum: Google [Bot] and 23 guests