Subject: FVWM: can't figure out how to refocus

From: "Stephen C. Koehler" <[email-masked]>
Date: Tue, 16 Mar 1999 09:08:36 -0600

I'm having trouble figuring out how to use the Current/None/Next commands 
to implement a smart refocus to a window on the current page.  

Here's the problem.  I have Iconify and Scroll bound to keys.  When I 
iconify a window, I want the next reasonable window on the current page 
to get focus.  Likewise, when I scroll to a different page, if the cursor 
is not over a window on that new page, I want the next reasonable window 
on the current page to get focus.  I'm having trouble getting both these 
to work at once.  One persistent problem is that I don't want the focus to 
change when it is already good, for example if I attempt to scroll off the 
edge of my desktop, I don't want focus to change.

I started out with a Refocus command that I slap on the front of any call 
to Iconfiy or Scroll:

    AddToFunc NextFocus
    +    "I" Next (!Iconic CurrentPage) WarpToWindow 10 10

    AddToFunc Refocus
    +    "I" $0 $1 $2 $3 $4 $5 $6 $7 $8 $9
    +    "I" <call NextFocus under the right conditions>

NextFocus properly selects a non-iconic window on the current page.  I 
only want to call it at the proper times, which is when there isn't already
a window on the current page that has focus.

What I want to do is

    +    "I" Current (!CurrentPage) NextFocus

However, CurrentPage is not negatable.  If I try

    +    "I" None (Visible CurrentPage) NextFocus

I don't refocus if there are any visible windows on the current page.

I have also tried experiments with conditions that use the current window 
number ($w), but I haven't gotten them to work, either.

Can anyone suggest a solution to this problem?
-- 
Steve Koehler               
Secure Computing Corporation
[email-masked] 

--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Tim Phipps <[email-masked]>
Date: Thu, 18 Mar 1999 17:16:21 +0000

"Stephen C. Koehler" wrote:
> to get focus.

This is fairly straight forward

AddToFunc my_iconify I Iconify on
+ I Prev (CurrentPage !Iconic) FlipFocus

>  Likewise, when I scroll to a different page, if the cursor

This is tough. I don't know of a way of telling that there isn't a
currently focussed window.

>     +    "I" None (Visible CurrentPage) NextFocus
Have you tried "Current (!Visible)"?

> number ($w), but I haven't gotten them to work, either.

This might be very convoluted but $w is zero if there isn't a focussed
window so you might be able to do something like 

+ I PipeRead <script> $w

and have a script that prints out "NextFocus" if arg1 is 0

> Can anyone suggest a solution to this problem?

You're not the first person to ask for a !CurrentPage test.  If you get
stuck enter a bug report (with a patch please).

Cheers,
Tim.

---

From: Adam Tla/lka <[email-masked]>
Date: Fri, 19 Mar 1999 09:59:46 +0100 (MET)

> to implement a smart refocus to a window on the current page.  

I have some propositions but working only with ClickToFocus and
FvwmButtons as Sticky window.
Try this:

Style "FvwmButtons" CirculateSkip

AddToFunc RaiseFocus            "I" Raise
+                               "I" Focus

AddToFunc RaiseFlip             "I" Raise
+                               "I" FlipFocus

AddToFunc TopToEnd "I" Prev (CurrentDesk CurrentPage !Iconic) FlipFocus
+                  "I" Prev (CurrentDesk CurrentPage !Iconic) FlipFocus
+                  "I" Prev (CurrentDesk CurrentPage !Iconic) Focus
+                  "I" Prev (CurrentDesk CurrentPage !Iconic) FlipFocus

AddToFunc NextFlip "I" Next (CurrentDesk CurrentPage !Iconic) RaiseFlip

AddToFunc PrevFlip "I" Current (CurrentDesk CurrentPage !Iconic !FvwmButtons)\
TopToEnd
+                  "I" Prev (CurrentDesk CurrentPage !Iconic) RaiseFlip

AddToFunc last_active "I" \
Prev (CurrentDesk CurrentPage CirculateHit FvwmButtons) FlipFocus
+ "I" Prev (CurrentDesk CurrentPage !Iconic) FlipFocus

AddToFunc scroll_rt     "I"     Scroll  100     0
+                       "I"     Function        last_active

AddToFunc scroll_lt     "I"     Scroll  -100    0
+                       "I"     Function        last_active

AddToFunc scroll_dn     "I"     Scroll  0       100
+                       "I"     Function        last_active

AddToFunc scroll_up     "I"     Scroll  0       -100
+                       "I"     Function        last_active

Key Left        A       1       scroll_lt
Key Right       A       1       scroll_rt
Key Up          A       1       scroll_up
Key Down        A       1       scroll_dn

Key Escape      A       1       WindowList Root c c \
"Prev (CurrentDesk CurrentPage !iconic) RaiseFlip"

Maybe this is a bit complicated but works quite good.
Order of windows on pages is saved and while iconifying active window
previous on the list is activated.
Switching pages by Alt-Cursors activates last active on that page and
while switching by mouse Alt-Tab does the same.

But generally speaking it will be nice to have additional function
in fvwm which places window on the top of window list like Focus but does
it by not changing order of other windows :

[a] <- top

[b]

[c]

[d]  - this I want to be active and on top

[e]

then

[d]  <- top

[b]

[c]

[e]

[a] - previous active goes to end of the list

It is not hard to do that. Just extract desired window from the list and
glue it after top and then switch top to this position and activate it.

I have "Style * NoIcons" and problem is that in my opinion Iconify
shouldn't switch focus to previous window on the list automatically.
I just want focus to stay on the same position and define:

AddToFunc Iconify-and-Prev "I" Iconify 1
+ "I" PrevFlip

Regards

 . .  Adam Tla/lka      mailto:[email-masked]    ^v^ ^v^ ^v^
  )   System  & Network Administration Group           ~~~~~~
  -  Computer Center,  Technical University of Gdansk, Poland
     PGP public key:   finger [email-masked]

---

From: Tim Phipps <[email-masked]>
Date: Fri, 19 Mar 1999 15:59:53 +0000

> it by not changing order of other windows :

This is what FlipFocus does and why it was invented.

> [a] - previous active goes to end of the list

The only thing that has happend here that wouldn't happen with FlipFocus
is that [a] has been moved to the bottom. The order becomes dabce rather
than dbcea. Why do you want [a] to go to the bottom?

> AddToFunc Iconify-and-Prev "I" Iconify 1

This sounds like you have ClickToFocus on. What happens with

AddToFunc Iconify-and-Prev "I" PrevFlip
+ I WindowId $w Iconify 1
?

I haven't tried this but I think it should do the focus changing stuff
before iconifying so the iconifying shouldn't invoke an automatic focus
change (that happens only when the current window is iconified).

Cheers,
Tim.

---

From: Adam Tla/lka <[email-masked]>
Date: Mon, 22 Mar 1999 09:07:20 +0100 (MET)

On Fri, 19 Mar 1999, Tim Phipps wrote:

> > ... a b c d e     d b c e a 

I want this to get behaviour similar to Prev and then Focus but without
reordering windows which are on other pages/desks. I need this 
to activate proper window (the last active one) after switching
pages/desks. Focus is bad in that situation because it changes order to
d e a b c which places e befor b and c.

> + I WindowId $w Iconify 1
OK, I'll try that.

Regards

---

From: Adam Tla/lka <[email-masked]>
Date: Mon, 22 Mar 1999 10:17:31 +0100 (MET)

> > + I WindowId $w Iconify 1
It doesn't work.
The one below works ok:

AddToFunc Iconify-and-Prev      "I" Iconify 1
+ "I" Prev (CurrentDesk CurrentPage CirculateHit FvwmButtons) FlipFocus
+ "I" PrevFlip

Regards

---

From: Dominik Vogt <[email-masked]>
Date: Mon, 22 Mar 1999 10:40:15 +0100

> + "I" Prev (CurrentDesk CurrentPage CirculateHit FvwmButtons) FlipFocus

Note that since 2.2 the correct syntax for iconify is

  Iconify on

The old syntax with numbers is obsolete and may be removed in
the future. I guess we should update all examples in the man page.

Bye

Dominik

-- 
Dominik Vogt, Hewlett-Packard GmbH, Dept. BVS
Herrenberger Str.130, 71034 Boeblingen, Germany
phone: 07031/14-4596, fax: 07031/14-3883, [email-masked]
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].