X.H.ManageHelpers: Factor doShiftTo out of transience and switch to W.shiftWin

Will be useful for shiftToLeader.

Use W.shiftWin instead of W.shift as it isn't guaranteed that the window
being managed by the ManageHook is still in focus.
This commit is contained in:
Tomas Janousek 2021-03-09 00:35:08 +00:00
parent 8202594b1d
commit 289c7e433a

View File

@ -217,10 +217,7 @@ ledFrom = ask >>= liftX . withWindowSet . findTagLeader
-- | A convenience 'MaybeManageHook' that will check to see if a window -- | A convenience 'MaybeManageHook' that will check to see if a window
-- is transient, and then move it to its parent. -- is transient, and then move it to its parent.
transience :: MaybeManageHook transience :: MaybeManageHook
transience = transientTo </=? Nothing -?>> move transience = transientTo </=? Nothing -?>> maybe idHook doShiftTo
where
move mw = maybe idHook (doF . move') mw
move' w s = maybe s (`W.shift` s) (W.findTag w s)
-- | 'transience' set to a 'ManageHook' -- | 'transience' set to a 'ManageHook'
transience' :: ManageHook transience' :: ManageHook
@ -239,6 +236,11 @@ shiftToLeader' = maybeToDefinite shiftToLeader
maybeToDefinite :: (Monoid a, Functor m) => m (Maybe a) -> m a maybeToDefinite :: (Monoid a, Functor m) => m (Maybe a) -> m a
maybeToDefinite = fmap (fromMaybe mempty) maybeToDefinite = fmap (fromMaybe mempty)
-- | Move the window to the same workspace as another window.
doShiftTo :: Window -> ManageHook
doShiftTo target = doF . shiftTo =<< ask
where shiftTo w s = maybe s (\t -> W.shiftWin t w s) (W.findTag target s)
-- | Floats the new window in the given rectangle. -- | Floats the new window in the given rectangle.
doRectFloat :: W.RationalRect -- ^ The rectangle to float the window in. 0 to 1; x, y, w, h. doRectFloat :: W.RationalRect -- ^ The rectangle to float the window in. 0 to 1; x, y, w, h.
-> ManageHook -> ManageHook