Intellij IDEA losing focus in stumpwm on Linux

Or why Oracle sucks!

I just installed Intellij today, not to replace Emacs (or Eclipse for Liferay stuff), but to use for things like PHP (which sucks) that Emacs doesn't have very good modes for. In addition in Liferay I often have to use Freemarker and Velocity templates, and neither Eclipse or Emacs handle them well (I want debugging).

Anyhow. When ever switching windows in Stumpwm away from Intellij and back, Intellij loses focus and doesn't regain focus until I click at a specific place. Basically the problem is that Stumpwm is not a reparenting window manager, combined with the fact that Oracle sucks. Basically they have hard coded a couple of window managers in swing that they support. Anything else, your basically screwed. Furthermore, Oracle say they only support Gnome and KDE. So if you don't use a mainstream DE, you are basically out in the cold. Here is a bug report that they have marked as "Not an issue". This doesn't really come as a surprise. Java GUI has always sucked. Java is fine for backend applications, for desktop applications, not so much. Though, in all fairness they have gotten better over time, but still are barely usable. I really wish people simply would stop making desktop applications in Java.

Article continues after ad

I spent a whole weekend trying to fix the issue, but came up blank. And yes, I've tried both the wmname LG3D trick and setting _JAVA_AWT_WM_NONREPARENTING=1, but nothing works. I finally gave up, and made a really hacky run and raise command that emulates a mouse click in the correct place. It's really bad, but it works for now. If anybody has a suggestion how to fix this, please, please leave a comment.

Update

I got this sort of working using a really nasty hack I wrote. It fixes most of the focus issues, but not all. It also causes issues with copy/paste from other applications so I have to use xclip to sync clipboards. Basically I start an xterm, start Xephyr and hijack the xterm window. Inside Xephyr I start metacity, and use devilspie to remove window decorations from metacity. Finally I start Intellij inside. Yeah!

killall -9 devilspie & killall -9 Xephyr & xterm -class intellij -name intellij & sleep 1 && Xephyr -keybd ephyr,,,xkbmodel=pc105,xkblayout=us,xkbvariant=altgr-intl,xkboptions=ctrl:nocaps -ac -br :1.0 -parent `xprop -notype -name intellij WM_CLIENT_LEADER | awk '{ print $5 }'` & sleep 2 && DISPLAY=:1.0 /usr/bin/metacity & sleep 3 && DISPLAY=:1.0 /usr/bin/devilspie & sleep 4 && DISPLAY=:1.0 /usr/bin/intellij

Photo by Ilya Pavlov / Unsplash