31

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.

4 Answers 4

17

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

7
  • 1
    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, 2010 at 15:24
  • What kind of test you are doing and what kind of new windows are opened? Oct 20, 2010 at 22:20
  • 1
    @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, 2010 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, 2012 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, 2012 at 4:39
2

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!)

0

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...

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .