conformal / spectrwm

A small dynamic tiling window manager for X11.
ISC License
1.33k stars 97 forks source link

google-chrome always steals focus #28

Closed levaidaniel closed 10 years ago

levaidaniel commented 10 years ago

Even though I have this in ~/.spectrwm.conf: quirk[.:.] = NOFOCUSONMAP

... this doesn't prevent google-chrome from stealing the focus every time it opens a new tab, or when I start it with a spectrwm bind. If I call chrome from terminal, from mutt or wherever, chrome always steals the focus from anything. And it also doesn't matter if it is already running or not.

Shouldn't the above quirk prevent this?

levaidaniel commented 10 years ago

Although, I think it's worth mentioning, that while using only one Screen with Spectrwm, google-chrome indeed always steals the focus (having eg. the terminal and the browser on one screen and one workspace), using two Screens, and having the terminal on one Screen and WS, and having the browser on another Screen and WS, this does not happen.

LordReg commented 10 years ago

The reason for this behavior is that google-chrome sends a focus change request (_NET_ACTIVE_WINDOW client message) whenever it wants to bring focus to its window. spectrwm currently accepts all such focus change requests. The EWMH spec states that a source indication of 1 (normal) means an application is wanting to change focus. A source indication of 2 (pagers/other) means that the focus request is a result of direct user action. A source indication of 0 is from old applications that don't specify the value. The requests from google-chrome are type 1.

It seems to me that all requests of type 1 should be denied by spectrwm since applications shouldn't be able to spontaneously steal focus. I have committed this change to my ewmh_improvements branch.

levaidaniel commented 10 years ago

The diff works here, but: Do you really think, that if one doesn't define a quirk to prevent applications from stealing focus, this should be how spectrwm handles such a request? I mean, okay, if I don't want google-chrome to steal focus, I turn on the NOFOCUSONMAP quirk for google-chrome, or if don't want any application to steal focus, I use the [.:.] regex to match any window. But if I don't specify explicitly that I hate window stealing, then google-chrome should get the focus, if it wants it, no?

levaidaniel commented 10 years ago

Further testing shows that this does not work, if:

If the focus is on, and the active window is the terminal, but the mouse cursor is over the google-chrome window, then chrome still steals the focus. Otherwise, if the mouse is over the terminal, or eg. the spectrwm status bar, only then the focus stealing prevention works.

dajohi commented 10 years ago

fixed in master

LordReg commented 10 years ago

This should be fixed now.

levaidaniel commented 10 years ago

Indeed! Thanks!