In Ubuntu (w/ Unity), some applications/windows open behind focused windows which can be annoying in some cases. Here are a few examples:
- clicking the "open containing folder" in the Firefox downloads menu, the file manager pops up behind the focused window;
- activating applications through indicators doesn't always bring them to the foreground, for instance Pidgin chat windows, the file manager opened via the "Open Dropbox folder" Dropbox AppIndicator menu item, Rhythmbox from the Ubuntu Sound Menu, etc.;
- if there's already a fileroller window open (Archive Manager, a compress/extract job, etc.), the second window you open is not focused.
I tested the examples above under Ubuntu 15.10 with Unity.
Some focus-related issues were marked as fixed a while back, but some continue to occur and there are comments, as well as bug reports, which suggest a simple solution which should fix this issue: setting "Focus Prevention level" to "Off" in CompizConfig Settings Manager (obviously you need to be using Compiz for this to work).
In case you're not aware, Ubuntu (with Unity) ships with "Focus Prevention level" set to "Low" by default. For instance, to work around this issue, Ubuntu MATE, which allows you to easily switch to Compiz via MATE Tweak, ships with this option set to "Off".
To apply the fix/workaround I mentioned above, firstly install CompizConfig Settings Manager:
sudo apt-get install compizconfig-settings-manager
Then open CompizConfig Settings Manager and under General Options > Focus & Raise Behaviour tab, set "Focus Prevention Level" to "Off":
That's it! If later on you decide you want to switch back to the default behaviour, simply set the "Focus Prevention Level" back to "Low".
As a bonus, this also fixes the issue with Nemo (with Unity patches) opening in the background when there's a focused window (which I think is a bug in Nemo).