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