Created
November 6, 2011 15:19
-
-
Save tkf/1343015 to your computer and use it in GitHub Desktop.
My absolute coordinate version of doFloat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import XMonad | |
| import qualified XMonad.StackSet as W | |
| main :: IO () | |
| main = xmonad defaultConfig | |
| { manageHook = composeAll | |
| [ className =? "XTerm" --> doFloatAbsRect 0 0 600 300 ] | |
| } | |
| doFloatAbsRect :: Rational -> Rational -> Rational -> Rational -> ManageHook | |
| doFloatAbsRect x y width height = do | |
| win <- ask -- get Window | |
| q <- liftX (floatLocation win) -- get (ScreenId, W.RationalRect) | |
| let sid = fst q :: ScreenId | |
| oirgRect = snd q :: W.RationalRect | |
| ss2ss ss = -- :: StackSet ... -> StackSet ... | |
| W.float win newRect ss where | |
| mapping = map (\s -> (W.screen s, W.screenDetail s)) (c:v) where | |
| c = W.current ss | |
| v = W.visible ss | |
| maybeSD = lookup sid mapping | |
| scRect = fmap screenRect maybeSD | |
| newRect = case scRect of | |
| Nothing -> oirgRect | |
| Just (Rectangle x0 y0 w0 h0) -> | |
| W.RationalRect x' y' w' h' where | |
| W.RationalRect x1 y1 w1 h1 = oirgRect | |
| x' = if x0 == 0 then x1 else x / (fromIntegral x0) | |
| y' = if y0 == 0 then y1 else y / (fromIntegral y0) | |
| w' = if w0 == 0 then w1 else width / (fromIntegral w0) | |
| h' = if h0 == 0 then h1 else height / (fromIntegral h0) | |
| doF ss2ss |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment