CurrentPageFocusFunc (from wiki) issue [solved]

I saw this neat function on the wiki (via archive.org) that remembers the last window focused on a given page and returns the focus to that window upon returning to that page. I incorporated this into my config file, and it worked nicely, except for one small problem. If a window overlaps another page, and that other page doesn’t have any other windows on it, then function doesn’t behave as I desire.

So, here’s the offending function:

DestroyFunc CurrentPageFocusFunc
AddToFunc CurrentPageFocusFunc
+ "I" Next (CurrentPage, State 2) Focus
+ "I" None (CurrentPage, Focused) Prev (CurrentPage, !Iconified, !Sticky) Focus

The problem is that (CurrentPage, State 2) will match a window from a previous page when it overlaps the current page. If there isn’t another window on the current page, then the Focus is going to pull me back to the page on which the window more fully resides. I’d much rather it not yank me to the other page.

Any ideas?

[Edit: Upon reviewing the post, I saw the solution at the bottom… I’m an idiot.]
[Edit2: I’m still an idiot, and I couldn’t fix the issue.]
[Edit3: I was wrong. The culprit was the second line that specifically says what to do when no window is of state 2 on the current page. Removing the second line fixes the problem.]

Look at the Overlapped condition.

– Thomas Adam

Isn’t this for windows overlapping other windows? The man page does not imply that it has anything to do with windows overlapping pages…

It is, which is a possibility, of course.

Try something like this:

Current (!CurrentPage) Prev (CurrentPage) Focus NoWarp

It doesn’t rely on anything silly such as states – bind to FvwmEvent with new_{page,desk} as needed.

– Thomas Adam

I’m not sure I follow you, there.

That doesn’t look like it would remember the last window focused on a given page. It looks like it would just choose the next window and set it to be focused, which might just grab whatever window is under the cursor (using sloppy focus policy) where I would want it to return focus to the last window on that page that had focus before I left that page.

The solution appears to be removing the second line from the function which was the actual culprit that stated when nothing was state 2 on the current page, then choose the prev and focus & warp to it…

Rather than telling me what you think it’s doing – actually try it. The clue to why you’re wrong, is that “Prev (CurrentPage)” will act on the previous window on that page. Really, try it. You can change it to do whatever you like.

– Thomas Adam

Actually, I did try it before describing what I thought it was doing. Perhaps something else in my config was interfering, because it didn’t give me the behavior that you describe. I’ll try it again with a nearly empty config and see if it behaves like you describe and then go from there.