If you use VirtualBox 5.1.x with a GNOME desktop (GNOME Shell, Unity and possibly other GTK-based desktops as well), you may have noticed that there are some focus-related issues:
- in GNOME Shell (host), virtual machine windows can't be moved unless clicking on another window, then moving the virtual machine window;
- in GNOME Shell (host), the Activities Overview can't be accessed if a virtual machine is focused;
- in Unity (host), clicking on an indicator while a virtual machine is focused results in the indicator menus not being displayed.
Here's a screenshot showing what happens in Unity when indicators are clicked while a VirtualBox 5.1.x virtual machine is focused:
I'm not sure if this issue is related to a specific GTK or Qt (VirtualBox 5.1.x uses Qt5) version. It occurs on my laptop running Ubuntu 16.10 (64bit), but other Ubuntu flavors as well as other Linux distributions might be affected as well.
The fix / workaround for the VirtualBox focus issue is very simple. All you have to do is open the VirtualBox preferences (File > Preferences) and on the "Input" tab, disable the "Auto Capture Keyboard" option:
The workaround mentioned above has a drawback though: some keyboard shortcuts will not work in the guest virtual machine while the "Auto Capture Keyboard" option is disabled. For example, using Ctrl + Alt + T to open a new terminal window won't work in the guest virtual machine. Other shortcuts, such as Ctrl + C, Ctrl + Shift + C, etc. will continue to work though.