Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Maverick with Compiz enabled.

I've searched AskUbuntu and Google. AskUbuntu doesn't have anything on this topic and everything Google turns up is a couple years old.

I'm doing browser tests and my tests are constantly spawning new Firefox windows. The problem is, when the window is spawned it takes focus. This is incredibly annoying as I'm usually in the middle of typing somewhere else. This doesn't only happen with my tests, but is the most common example I run into. Sometimes my IDE decides it wants focus when something special happens (like when something is done compiling) and then later I'll find fragments of IM messages I've typed in my code. This is driving me crazy. I've looked in both Gnome settings and Compiz settings and can't find a way to prevent that from happening.

Does anyone know of a way to prevent an app from stealing focus when it is opened? I'd rather have the taskbar flash at me or something to get my attention.

share|improve this question
up vote 9 down vote accepted

The setting is in CompizConfig > General > Focus & Raise Behavior as so documented. The Window Matching rules are quite important.

share|improve this answer
Thanks, that helps. That keeps what I type going to the correct window, but the firefox windows that are being opened are still being opened ON TOP of what I'm working on... even though they don't have focus. Also, IntelliJ still ignores the rule. – Joel Oct 20 '10 at 15:24
What kind of test you are doing and what kind of new windows are opened? – lovinglinux Oct 20 '10 at 22:20
@lovinglinux: sorry just noticed you asked. I'm running selenium tests so Firefox windows open. Also, I'm running JUnit tests with a debugger so when a breakpoint is hit IntelliJ decides to take focus to tell me about it. The Firefox focus issue was resolved by tweaking Compiz as stated in msw's post. IntelliJ, however, tends to ignore the Compiz setting. – Joel Nov 16 '10 at 22:43
@Joel how did you setup it? What Focus Prevention Level are you using and how did you configure the "Focus Prevention Windows" matching rules? – blueyed Jul 21 '12 at 18:11
@blueyed, sorry, but it's been so long and I've since switched computers and don't remember what the settings were. – Joel Jul 22 '12 at 4:39

If you're working in one window most of the time you could right-click on the title bar and tell the window to be always on top... it's not a perfect solution, but you could shade the window when you're done, or minimize it then return to it...

share|improve this answer

You can change this setting in the gconf-editor also, in case you don't have CCSM installed. Navigate to /apps/compiz/general/screen0/options/focus_prevention_level key and set its value to 4.

For some people, 4 is too high. Eclipse users will find that various dialogs won't grab the keyboard focus correctly when this is set to 4, but will if set to 3.

share|improve this answer

This is not something you should configure globally. I.e. you don't really want no new windows to take focus: you want no test windows to take focus. To accomplish this, use the Compiz Window Rules plugin to prevent all "test" Firefox windows from taking focus.

You would need to write a rule to identify only "test" Firefox instances. If they all have a specific string in the title, that would work. Otherwise you could use wmctrl to set the WM_ICON_NAME X property. (I don't know how to easily set X properties for Firefox .. if anyone else does, please chime in!)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.