Ubuntu – What do I do when Minecraft in fullscreen loses focus

fullscreenlauncherminecraftmouse

When playing Minecraft in fullscreen, if another application takes focus, or a desktop notification appears, Minecraft "minimizes" but still has control of my mouse. My keyboard works fine, applications keep running, and I can even move my mouse, but mouse clicks don't register. The only options I've found are to…

a) Regain Minecraft's focus with a hotkey (Super + number key; the same as clicking an icon in the launcher). The problem with this is that if the Minecraft icon is too far down the launcher, there's no hotkey to launch it.

b) Kill the application. Since my keyboard still works, I can hit Alt + F2 and killall java without much hassle. The cons of this method are obvious.

So I need two solutions:

  • How do I prevent this from happening?

  • How do I more reliably give the focus back to my Minecraft (java) process should this happen again, without relying on it being higher up on my launcher?

I don't have any issues running Minecraft in a window, even if it's been maximized by clicking the square icon.

Best Answer

wmctrl tool provides command line access to window manager (not installed by default, the package is named wmctrl). The -a flag permits a user to Activate the window by switching to its desktop and raising it. (Note that you can find the window name with -f option)

$ wmctrl -l
0x01600007 -1 hostname Desktop
0x04200002  0 hostname mouse - What do I do when Minecraft in fullscreen loses focus? - Ask Ubuntu - Google Chrome
0x03200007  0 hostname Terminal
0x03e00015  0 hostname Minecraft 1.10.2
$ wmctrl -a "Minecraft 1.10"

Thus a complete recipe could be

  • Switch to virtual console Ctrl+Alt+F1
  • Login
  • DISPLAY=:0 wmctrl -a "Minecraft 1.10"
  • Switch to x server console Ctrl+Alt+F7 (or F8)

See this other answer for more details on wmctrl.

Related Question