Return Window Focus Thread last updated on 2004-07-17 18:21:22

Posted by member 37809 on 2003-07-03 22:22:30

I desire some functionality to return focus to the last application window that's not related to litestep('s modules), preferably available in the form of a bang.

I imagine it could be added to WndMan (Vendicator) or subclass (ilmcuts), though I don't know what is required to make this possible; for all I know you might need to keep track of running tasks or something.

Scenarios in the context of modules:

1) User clicks on some label. It does something. Ok, it's done doing its thing. Now return focus to the previous non-litestep window.

2) User mouse enters a label. Using WndMan, give this label focus. This label has mouse wheel events, so now having focus, user may readily wheel up and down. On mouse leave, restore focus to the previous window.

3) User left clicks on the desktop. User's theme just so happens to not have any functionality associated with it. May as well give focus back to the last window.

4) User prepares to click on a something clickable, like a shortcut. This shortcut is special because it calls bangs that are applied to the current window (that which has focus). Normally, clicking on this shortcut will have the bang be applied to itself; instead when user clicks on the shortcut, return focus to the last application window and then call the intended bang(s). WndMan has many window-manipulating bangs which may be applied to the current window. Hotkeys are limited; shortcuts may be better, if also to justify this requested feature ;X

Posted by member 7223 on 2003-07-04 09:42:43 link

I've done some things this kind when I began to play with RabidVWM. At the begining, RabidVWM was buggy in a fine way:
VWMOnMoveWindow !VarSet WinTitle "^@wt^"
...used to be called on every focus change. Now, it has been fixed and you couldn't use it anymore for knowing the active window.

But you still could use a timer and VWMExec to ALWAYS know everything you want about the active window:
*Timer ActiveWnd #sl 250 '!VWMExec !VarSet WinHandle ^@wh^'

Then, you can do things like:
!Exec !VWMExec !One "^@wc (#h %{WinHandle})^" "^@wt (#h %{WinHandle})^"

Posted by member 99 on 2003-07-04 12:13:16 link

VWMOnRepaint might work instead of the timer.

Maybe !VWMDesk 0 (switch to current desk) if you have one of the VWMFocus... things set. Or hide and then show the label/shortcut that the user had clicked on, if a little flicker is acceptable.

Posted by member 37809 on 2003-07-04 13:29:00 link

sweet, thanks.
it looks hard to get consistent behavior without conflicts using this in specific places. controlling focus does seems more trouble than it's worth though, as people have said before. :/

Posted by member 2112 on 2004-07-17 18:03:28 link

The !VWMDesk 0 seems to work, though not consistantly. But I figured out a potentially better way using !VWMExec with "^@wt^". When !VWMExec !alert "^@wt^" is assigned to a button it gets the title of the active window, not LS (as I expected).

I was hoping to use this in conjunction with a WndMan bang but you can't target a window based on it's title. I know One can, but it doesn't "Shade" or the ability to "toggle" between Max/restore.

Posted by member 2112 on 2004-07-17 18:21:22 link

Woohoo! It's not pretty, but it appears to work flawlessly. I've used a combination of One and WndMan and assigned the following bang to a shortcut:
!VWMExec !execute [!One "^@wc^" "^@wt^" .none .focus][!WndMaxToggle %active%]


It's a shame I had to load 2 modules that do almost exactly the same thing, but it works.