[vbox-dev] Regression with Qt 5.13 - guest steals focus

Larry Finger Larry.Finger at lwfinger.net
Thu Jul 4 17:16:16 GMT 2019


When a Linux host runs Qt 5.13, any VB guest will constantly steal the focus 
making it nearly impossible to do anything with the host. The problem was 
reported by an openSUSE user at https://bugzilla.suse.com/show_bug.cgi?id=1140084.

The bug is discussed at https://bugreports.qt.io/browse/QTBUG-76742. A fix that 
reduces a focusinTimer timeout from 400 to 200 msec fixes the problem. A comment 
in VB's captureKeyboard() helps explain why that works:

/* On X11, we do not grab the keyboard as soon as it is captured, but delay it
  * for 300 milliseconds after the formal capture. We do this for several reasons:
  * - First, when several windows are created they all try to capture the 
keyboard when
  *   they get the focus. Due to the asynchronous nature of X11 the first window 
may only
  *   gets notified after the last is created, and there is a dance if they 
respond to
  *   the notifications by grabbing the keyboard and trigger new focus changes 
in the process.
  * - Second, grabbing the keyboard immediately on focus change upsets some 
window managers,
  *   they give us the focus then try to grab the keyboard themselves, and sulk 
if they fail
  *   by refusing to e.g. drag a window using its title bar.
  *
  * IMPORTANT! We do the same under all other hosts as well mainly to have the
  *            common behavior everywhere while X11 is forced to behave that way. */

The final statement shows why this 300 msec should not be changed in VB, thus 
the problem needs to fixed in Qt 5.13.

While the Qt developers are deciding what the "correct" fix should be, openSUSE 
has changed the Qt package in Tumbleweed to reduce the focusinTimer timeout from 
400 to 200 msec. Thus far, no adverse effects have been noted.

To reiterate, no changes are needed for VirtualBox. I have posted this so that 
other distro maintainers will be aware of the problem in case their distro 
switches to Qt 5.13.

Thanks to SUSE's Fabian Vogt for his help in solving this problem.

Larry




More information about the vbox-dev mailing list