X.A.CycleRecentWS: Revert setOption changes

These are remnants of the first fix attempt, but are no longer
necessary. This reduces the diff to `view . unview` instead of `const`.
This commit is contained in:
Tomas Janousek 2021-05-14 00:36:58 +01:00 committed by slotThe
parent b65b83661b
commit 1e2e1273b8

View File

@ -1,5 +1,4 @@
{-# LANGUAGE CPP #-} {-# LANGUAGE CPP #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE PatternGuards #-} {-# LANGUAGE PatternGuards #-}
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
@ -117,18 +116,15 @@ cycleWindowSets genOptions mods keyNext keyPrev = do
KeyEvent {ev_event_type = t, ev_keycode = c} <- getEvent p KeyEvent {ev_event_type = t, ev_keycode = c} <- getEvent p
s <- keycodeToKeysym d c 0 s <- keycodeToKeysym d c 0
return (t, s) return (t, s)
let setOption n = do let setOption n = do windows $ view (options `cycref` n) . unView'
let nextWs = options `cycref` n (t, s) <- io event
syncW ws = windows $ view ws . unView' case () of
(t, s) <- io event () | t == keyPress && s == keyNext -> setOption (n+1)
if | t == keyPress && s == keyNext -> syncW nextWs >> setOption (n + 1) | t == keyPress && s == keyPrev -> setOption (n-1)
| t == keyPress && s == keyPrev -> syncW nextWs >> setOption (n - 1) | t == keyRelease && s `elem` mods -> return ()
| t == keyRelease && s `elem` mods -> | otherwise -> setOption n
syncW =<< gets (tag . workspace . current . windowset)
| otherwise -> setOption n
io $ grabKeyboard d root False grabModeAsync grabModeAsync currentTime io $ grabKeyboard d root False grabModeAsync grabModeAsync currentTime
windows $ view (options `cycref` 0) -- view the first ws setOption 0
setOption 1
io $ ungrabKeyboard d currentTime io $ ungrabKeyboard d currentTime
where where
cycref :: [a] -> Int -> a cycref :: [a] -> Int -> a