[xmonad] keeping focus on window after shifting to new screen
Ben Boeckel
mathstuf at gmail.com
Fri Aug 3 03:43:28 CEST 2012
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
On Thu, Aug 02, 2012 at 21:41:55 GMT, Bryan Huh wrote:
> Currently, I move my windows to the left and right screens using the
> following keybinding:
>
> [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows
> . f))
> | (key, sc) <- zip [xK_h, xK_l, xK_r] [0..]
> , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
>
> But if I try to move a window from one screen to the next using
> mod-shift-{h,l}, it annoys me that that window loses focus. I would like
> it for the window to remain in focus on the new screen (i.e. the new
> screen should be put in focus). I really like how when you shift a
> window up and down the stack with shift-mod-{j,k} that the same window
> remains in focus at all times. Is there an easy way to maintain this
> behavior across screens?
I have machines with 1, 2, and 3 monitors all using the same config (the
plan is to make the 3 monitor one a 4 monitor machine once I get an HDMI
cable for it). I have pretty much every binding you could want
controlling workspaces and screens done. Swapping screens or workspaces,
following with focus or not. It's modifier heavy, but the important
stuff is left alone (mainly Ctrl+Arrow, Alt+Arrow, and Ctrl+Alt+Fn, and
Alt+key (for rtorrent mainly, but I'm sure it makes conflicts with emacs
easier to avoid too)).
Here's the relevant section from my xmonad.hs:
myKeys conf = M.fromList $
-- ...
-------------------------------------------------------------------
-- ctrl+F[1 .. ], Switch to workspace N
-- ctrl+shift+F[1 .. ], View to workspace N
-- meta+F[1 .. ], Move client to workspace N and follow
-- meta+shift+F[1 .. ], Move client to workspace N
-- alt+F[1 .. ], Swap with workspace N and follow
-- alt+shift+F[1 .. ], Swap with workspace N
[ ((m, k), windows $ f i)
| (i, k) <- zip (workspaces conf) workspaceKeys
, (f, m) <- [ (W.greedyView , controlMask)
, (W.view , controlMask .|. shiftMask)
, (liftM2 (.) W.greedyView W.shift, mod4Mask)
, (W.shift , mod4Mask .|. shiftMask)
, (swapWithCurrent , mod1Mask)
, (silentSwapWithCurrent , mod1Mask .|. shiftMask)
]
]
++
-------------------------------------------------------------------
-- ctrl+meta+F[1 .. ], Switch to screen N
-- ctrl+meta+shift+F[1 .. ], Move client to screen N
-- alt+meta+F[1 .. ], Swap with screen N and follow
-- alt+meta+shift+F[1 .. ], Swap with screen N
[ ((m, k), screenWorkspace i >>= flip whenJust (windows . f))
| (i, k) <- zip [0 .. ] workspaceKeys
, (f, m) <- [ (W.view , controlMask .|. mod4Mask)
, (W.shift , controlMask .|. mod4Mask .|. shiftMask)
, (swapWithCurrent , mod1Mask .|. mod4Mask)
, (silentSwapWithCurrent, mod1Mask .|. mod4Mask .|. shiftMask)
]
]
++
-------------------------------------------------------------------
-- ctrl+alt+[left,right], Switch to workspace to the left or right
-- meta+[left,right], Move window to left or right and follow
-- meta+shift+[left,right], Move window to left or right
-- alt+meta+[left,right], Swap with workspace to left or right and follow
-- alt+meta+shift+[left,right], Swap with workspace to left or right
[ ((m, xK_Left ), c)
| (c, m) <- [ (prevWS , controlMask .|. mod1Mask)
, (shiftToPrev >> prevWS, mod4Mask)
, (shiftToPrev , mod4Mask .|. shiftMask)
, (swapTo Prev , mod1Mask .|. mod4Mask)
, (swapTo Prev >> nextWS, mod1Mask .|. mod4Mask .|. shiftMask)
]
]
++
[ ((m, xK_Right), c)
| (c, m) <- [ (nextWS , controlMask .|. mod1Mask)
, (shiftToNext >> nextWS, mod4Mask)
, (shiftToNext , mod4Mask .|. shiftMask)
, (swapTo Next , mod1Mask .|. mod4Mask)
, (swapTo Next >> prevWS, mod1Mask .|. mod4Mask .|. shiftMask)
]
]
++
-------------------------------------------------------------------
-- ctrl+alt+[up,down], Switch to next/previous screen
-- meta+[up,down], Move window to next/previous screen and follow
-- meta+shift+[up,down], Move window to next/previous screen
-- alt+meta+[up,down], Swap with next/previous screen and follow
-- alt+meta+shift+[up,down], Swap with next/previous screen
[ ((m, xK_Up ), c)
| (c, m) <- [ (prevScreen , controlMask .|. mod1Mask)
, (shiftPrevScreen >> prevScreen, mod4Mask)
, (shiftPrevScreen , mod4Mask .|. shiftMask)
, (swapPrevScreen >> nextScreen , mod1Mask .|. mod4Mask)
, (swapPrevScreen , mod1Mask .|. mod4Mask .|. shiftMask)
]
]
++
[ ((m, xK_Down ), c)
| (c, m) <- [ (nextScreen , controlMask .|. mod1Mask)
, (shiftNextScreen >> nextScreen, mod4Mask)
, (shiftNextScreen , mod4Mask .|. shiftMask)
, (swapNextScreen >> prevScreen , mod1Mask .|. mod4Mask)
, (swapNextScreen , mod1Mask .|. mod4Mask .|. shiftMask)
]
]
where
workspaceKeys = [xK_F1 .. xK_F12]
silentSwapWithCurrent i w = W.view (W.currentTag w) $ swapWithCurrent i w
- --Ben
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iQIcBAEBCgAGBQJQGyW7AAoJEKaxavVX4C1XPJIQAMg2x5PZ2pjtN2H4tqWLRWTH
czBWO3c50NgBao6Z6Gx2vI1ehTQMN8KPteQIA4lbveWg529gJWr4qaZW/vlCDtr4
6CPGsJX6pguYs8dhJgQyVrlb38Ii+1tZ/LolN9oVP1uCwmyWZD9s8QDojFJU0XX0
z4ZQS7pLJh4rWmlSt0xgN3L3+L6hrrQTbT1G8rb3UNYgKVnMTrwg20GsY2bfhLj4
h4sF0mweFXIq03n0jEwgxjXMAqQTG1KzaUVPgC2iF9q0sSZVCsnBNTwS8Gy7nhVW
6dzL5uPu/8P42rwDzzPUgEsGR8Lv11ra7RxEKlpGtJYtJuoeuODha3G++M2+vTMR
20MivbiVlPpizz0cYfQpgJ4cJowSbfAzCV2kC2dIciud5yg93JBGykRhVg4KzsyH
zR83G0G8XGxXUIOZaUcnn+AnxPdGIfK37PHUWyvP8dBW+BS+U8tNt3qqEowz7ZP9
z4HC/35XlX/DITpFJUHXi4vRg7O2DoiJA04uv6jh8/q9uBvlPN7JXdCAtN+USpIw
ygoriwpcrxpjWvy5OAbWVOFtM6xw3K/gK1Cf7nfCGWPZhRko1KmHm2YlgAU6BHyM
iFQYDgqt3qG/pOKJwZ4Rfmc8QCe7/q93lCuiUywtkGpw0XIiZUXL7S0qVAEsGD8J
Ce0H0tinAxjG5l6Nfzyk
=dl5T
-----END PGP SIGNATURE-----
More information about the xmonad
mailing list