Changing focus with alt-tab as in Windows

Hello, is it possible to configure xmonad, to move the focus with alt-tab exactly as in Windows? As far as I could understand, only keyPress events are dispatched. But it seems keyUp events are required for this. Or maybe there are much more simpler solutions? Regards Alex

On Mon, Jan 05, 2009 at 06:00:04PM +0100, Alex Samokhvalov wrote:
Hello,
is it possible to configure xmonad, to move the focus with alt-tab exactly as in Windows? As far as I could understand, only keyPress events are dispatched. But it seems keyUp events are required for this. Or maybe there are much more simpler solutions?
Can you be more specific? What is it exactly about the way Windows does things that you would like to see implemented? The default configuration already includes a binding for mod-Tab to cycle through windows. -Brent

Brent Yorgey wrote:
On Mon, Jan 05, 2009 at 06:00:04PM +0100, Alex Samokhvalov wrote:
Hello,
is it possible to configure xmonad, to move the focus with alt-tab exactly as in Windows? As far as I could understand, only keyPress events are dispatched. But it seems keyUp events are required for this. Or maybe there are much more simpler solutions?
Can you be more specific? What is it exactly about the way Windows does things that you would like to see implemented? The default configuration already includes a binding for mod-Tab to cycle through windows.
After the alt button has been pressed down, pressing tab switches the focus to the first previously focused window. The second tab press selects the second previously focused window. And so on until the alt button is released. For example, a workspace contains 5 windows: A,B,C,D,E. The first window in the list is selected, in this case - A. Then as in the following scenario: - alt button down: * pressing the tab results in the following window order: B,A,C,D,E (whereby B is focused) * tab pressed again -> C,A,B,D,E - alt button up -> "commit" C,A,B,D,E - alt button down * tab pressed -> A,C,B,D,E * tab pressed -> B,C,A,D,E * tab pressed -> D,C,A,B,E - alt button up -> "commit" D,C,A,B,E I find such behavior convenient because usually you work with only a couple of windows. All others are just for logging, reporting, etc.

Alex Samokhvalov
For example, a workspace contains 5 windows: A,B,C,D,E. The first window in the list is selected, in this case - A. Then as in the following scenario: - alt button down: * pressing the tab results in the following window order: B,A,C,D,E (whereby B is focused) * tab pressed again -> C,A,B,D,E - alt button up -> "commit" C,A,B,D,E - alt button down * tab pressed -> A,C,B,D,E * tab pressed -> B,C,A,D,E * tab pressed -> D,C,A,B,E - alt button up -> "commit" D,C,A,B,E
I find such behavior convenient because usually you work with only a couple of windows. All others are just for logging, reporting, etc.
This is not an easy behaviour to emulate in xmonad, since we don't keep track of the order in which we have focused various windows: we normally only know what the currently focused window is.

* mail@justinbogner.com
Alex Samokhvalov
writes: For example, a workspace contains 5 windows: A,B,C,D,E. The first window in the list is selected, in this case - A. Then as in the following scenario: - alt button down: * pressing the tab results in the following window order: B,A,C,D,E (whereby B is focused) * tab pressed again -> C,A,B,D,E - alt button up -> "commit" C,A,B,D,E - alt button down * tab pressed -> A,C,B,D,E * tab pressed -> B,C,A,D,E * tab pressed -> D,C,A,B,E - alt button up -> "commit" D,C,A,B,E
I find such behavior convenient because usually you work with only a couple of windows. All others are just for logging, reporting, etc.
This is not an easy behaviour to emulate in xmonad, since we don't keep track of the order in which we have focused various windows: we normally only know what the currently focused window is.
We can store this information in a layout modifier. alt-tab would send a message to that layout, and message handler would change the focus. Has not anybody written this already? P.S. I think we should have a wiki page which describes tasks that are solved by each module. -- Roman I. Cheplyaka (aka Feuerbach @ IRC) http://ro-che.info/docs/xmonad.hs

Roman Cheplyaka wrote:
* mail@justinbogner.com
[2009-01-05 21:41:07-0700] For example, a workspace contains 5 windows: A,B,C,D,E. The first window in the list is selected, in this case - A. Then as in the following scenario: - alt button down: * pressing the tab results in the following window order: B,A,C,D,E (whereby B is focused) * tab pressed again -> C,A,B,D,E - alt button up -> "commit" C,A,B,D,E - alt button down * tab pressed -> A,C,B,D,E * tab pressed -> B,C,A,D,E * tab pressed -> D,C,A,B,E - alt button up -> "commit" D,C,A,B,E
I find such behavior convenient because usually you work with only a couple of windows. All others are just for logging, reporting, etc. This is not an easy behaviour to emulate in xmonad, since we don't keep
Alex Samokhvalov
writes: track of the order in which we have focused various windows: we normally only know what the currently focused window is. We can store this information in a layout modifier. alt-tab would send a message to that layout, and message handler would change the focus. Has not anybody written this already?
It seems there are two "problems". The first is the dispatching of the keyUp/keyDown event. And the second is how to handle such focus changing. I don't know but suppose it's not very difficult to add the keyUp event dispatching and key binding. The second "problem" can be eventually solved with the present StackSet.Stack data. Currently, the Stack contains the focused window, a list of the "windows" above the focused window and a list of the "windows" below: data Stack a = Stack { focus :: !a -- focused thing in this set , up :: [a] -- clowns to the left , down :: [a] } -- jokers to the right deriving (Show, Read, Eq) So we can just use one of the lists to save the focus history. Going further, the current Stack could become just a class Stack, something like this: class StackClass a where focused :: !a -- currently focused window others :: [a] -- other windows And the current data Stack could be the default implementation of StackClass and the function from StackSet focusUp',focusDown',etc would just work with StackClass instances. What do you think about? Regards Alex

Excerpts from Alex Samokhvalov's message of Mon Jan 05 14:47:43 -0700 2009:
is it possible to configure xmonad, to move the focus with alt-tab exactly as in Windows? As far as I could understand, only keyPress events are dispatched. But it seems keyUp events are required for this. Or maybe there are much more simpler solutions?
After the alt button has been pressed down, pressing tab switches the focus to the first previously focused window. The second tab press selects the second previously focused window. And so on until the alt button is released.
Alex, The new Actions.CycleWindows provides this, along with a few other useful bindings for this sort of workflow. It is in darcs, or you can copy the functions cycleRecentWindows, cycleStacks', and shiftToFocus' into your xmonad.hs, import Actions.RotSlaves, and XMonad.StackSet as W, and set up as in comments. http://code.haskell.org/XMonadContrib/XMonad/Actions/CycleWindows.hs regards, -- wmw
participants (5)
-
Alex Samokhvalov
-
Brent Yorgey
-
mail@justinbogner.com
-
Roman Cheplyaka
-
Wirt Wolff