Discussion:
FVWM: Creating an UrgencyFunc that de-iconifies a window and keeps focus
Adam Sjøgren
2012-09-13 11:47:34 UTC
Permalink
Usually I have my Pidgin window iconified. I have configured Pidgin to
set the URGENT hint when a new message arrives. I would like the window
to be de-iconified when that happens.

My first attempt to write an UrgencyFunc to achieve this was:

DestroyFunc UrgencyFunc
AddToFunc UrgencyFunc
+ I Iconify off

This works, but has the drawback that the de-iconified window gains
focus - which I do not want (I'm often typing into another window when
this happens).

So I tried this instead:

DestroyFunc UrgencyFunc
AddToFunc UrgencyFunc
+ I FlipFocus
+ I Iconify off
+ I Prev (AcceptsFocus) Focus

This works as I want it to _except_ when the Pidgin window is already
de-iconified and has focus.

In that case, when a new message is received, the previous window gains
focus, and I end up typing into another window than the Pidgin window.
Usually mid-sentence.

I am probably going about this in a backwards way, so any ideas for a
good solution are very welcome.

If I could test whether the window with the URGENT hint has focus and do
nothing in the UrgencyFunc, I think I would be home free - but there are
probably other solutions.


Best regards,

Adam
--
"Hur långt man än har kommit Adam Sjøgren
är det alltid längre kvar" ***@koldfront.dk
Thomas Adam
2012-09-13 12:56:38 UTC
Permalink
Post by Adam Sjøgren
Usually I have my Pidgin window iconified. I have configured Pidgin to
set the URGENT hint when a new message arrives. I would like the window
to be de-iconified when that happens.
In addition to the UrgencyFunc function, what have you defined for the
EWMHActivateWindowFunc, if anything?

-- Thomas Adam
Adam Sjøgren
2012-09-13 13:03:37 UTC
Permalink
Post by Thomas Adam
Post by Adam Sjøgren
Usually I have my Pidgin window iconified. I have configured Pidgin to
set the URGENT hint when a new message arrives. I would like the window
to be de-iconified when that happens.
In addition to the UrgencyFunc function, what have you defined for the
EWMHActivateWindowFunc, if anything?
I haven't defined anything for that.

(I have a comment in my config about seeing EWMHActivateWindowFunc only
being applied to new windows and not windows being de-iconified; it has
been a while since I played with it, so that might be inaccurate.)


Best regards,

Adam
--
"Hur långt man än har kommit Adam Sjøgren
är det alltid längre kvar" ***@koldfront.dk
Reid Priedhorsky
2012-09-13 15:31:34 UTC
Permalink
Post by Adam Sjøgren
Usually I have my Pidgin window iconified. I have configured Pidgin to
set the URGENT hint when a new message arrives. I would like the window
to be de-iconified when that happens.
I've had exactly the same problem with Pidgin. I have the following:

Style "*" SloppyFocus, !FPFocusByProgram

DestroyFunc UrgencyFunc
AddToFunc UrgencyFunc
+ I Iconify off
+ I Raise

I don't recall if this solves the focus grabbing upon de-iconification,
or if I just iconify chat windows infrequently enough that it's less of
a bother.

It's from: http://fvwmwiki.xteddy.org/Tips/FocusStealing/

With this, there are still a few problems with focus grabbing, though
they are limited to the password dialogs IIRC.

HTH,
Reid
--
IM (Google Chat): ***@gmail.com (not a valid e-mail)

E-mail response time: I check e-mail periodically throughout the day,
not continually, so I might not see your note for several hours.
Please use IM or phone if you need an immediate response.
Adam Sjøgren
2012-09-13 15:57:19 UTC
Permalink
Post by Reid Priedhorsky
Style "*" SloppyFocus, !FPFocusByProgram
I use SloppyFocus, but not "!FPFocusByProgram".
Post by Reid Priedhorsky
DestroyFunc UrgencyFunc
AddToFunc UrgencyFunc
+ I Iconify off
+ I Raise
Adding Raise compared to mine; ok.
Post by Reid Priedhorsky
I don't recall if this solves the focus grabbing upon
de-iconification, or if I just iconify chat windows infrequently
enough that it's less of a bother.
I have my window iconified almost all the time.
Post by Reid Priedhorsky
It's from: http://fvwmwiki.xteddy.org/Tips/FocusStealing/
I hadn't found the wiki; cool.


Best regards,

Adam
--
"Hur långt man än har kommit Adam Sjøgren
är det alltid längre kvar" ***@koldfront.dk
Adam Sjøgren
2012-09-19 11:16:57 UTC
Permalink
Post by Adam Sjøgren
DestroyFunc UrgencyFunc
AddToFunc UrgencyFunc
+ I Iconify off
This works, but has the drawback that the de-iconified window gains
focus - which I do not want
After failing to find a way to detect whether the window that gets the
URGENT hint set already had focus (and then not doing the "switch focus
back to the previous window that had it"-trick), I looked at the source
code to see if I couldn't patch "Iconify off" to not focus the window.

In the DeIconify() function in icons.c there are two calls to
SetFocusWindow(). A little printf debugging revealed that the first is
called when I de-iconify using the mouse and the second is called when
Iconify off is called from my UrgencyFunc.

Also, the second call is only done if the focus style is
'SortWindowListByOpen'(ish). Aha!

So adding:

FocusStyle * SortWindowListByFocus

to my configuration turns out to fix my problem (I don't use windowlists
so I don't care about that setting).

Sweet!


Best regards,

Adam
--
"Hur långt man än har kommit Adam Sjøgren
Är det alltid längre kvar" ***@koldfront.dk
Loading...