diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Internal/Keys.hs | 2 | ||||
| -rw-r--r-- | src/Internal/Layout.hs | 87 | ||||
| -rw-r--r-- | src/Main.hs | 8 |
3 files changed, 42 insertions, 55 deletions
diff --git a/src/Internal/Keys.hs b/src/Internal/Keys.hs index fe13cc7..b710acf 100644 --- a/src/Internal/Keys.hs +++ b/src/Internal/Keys.hs @@ -16,6 +16,7 @@ import qualified XMonad.StackSet as W import XMonad.Prompt.Input import XMonad.Prompt.Shell import XMonad.Prompt +import XMonad.Util.Scratchpad import Data.Char type KeyMap l = XConfig l -> Map (KeyMask, KeySym) (X ()) @@ -85,6 +86,7 @@ newKeys = Map.fromList [ ((modm, xK_F12), (void $ spawn "spotify-control next")) , ((modm, xK_F11), (void $ spawn "spotify-control prev")) + , ((modm, xK_semicolon), scratchpadSpawnActionTerminal "scratchpad") , ((modm, xK_F10), (void $ spawn "spotify-control play")) , ((modm, xK_r), (void $ spawn "dmenu_run")) , ((modm .|. shiftMask, xK_r), (void $ spawn "gmrun")) diff --git a/src/Internal/Layout.hs b/src/Internal/Layout.hs index 08aaa7a..bdac6d1 100644 --- a/src/Internal/Layout.hs +++ b/src/Internal/Layout.hs @@ -11,66 +11,49 @@ import qualified XMonad.StackSet as W myLayout = spiral (6/7) ||| - Center 0.7 ||| Tall 1 (3/100) (1/2) ||| ThreeCol 1 (3/100) (1/2) ||| Grid +data Manual = Manual RectSet -data Center a = - Center { - proportion :: Float -- between 0 and 1 - } - deriving (Show, Read) +data RectSet = + RectSet { + rectSetWidth :: Float -- 0.0 - 1.0 fraction of the float. + , rectSetHeight :: Float + , subRects :: RectChildren + } -instance (Show a) => LayoutClass Center a where - doLayout l r@(Rectangle x y w h) stack = do - let wf = fromIntegral w - hf = fromIntegral h - x' = (wf - wf * proportion l) / 2 - y' = (hf - hf * proportion l) / 2 - w' = wf * proportion l - h' = hf * proportion l - middleRect = Rectangle (floor x') (floor y') (floor w') (floor h') - topRect = Rectangle 0 0 (floor wf) (floor y') - rightRect = Rectangle (floor (x' + w')) (floor y') (floor x') (floor h') - bottomRect = Rectangle 0 (floor $ y' + h') (floor wf) (floor y') - leftRect = Rectangle 0 (floor y') (floor x') (floor h') +data RectChildren = + Leaf { boundWindow :: Maybe Window } | + Children { children :: [RectSet] } - nWin = length (W.integrate stack) - winsTop = nWin `div` 8 +data RectSetD = + LeafD { + boundWindowD :: Maybe Window + , parent :: RectParentD + } | + Parent { self :: RectParentD } - portion = fromIntegral $ (guard 1 (nWin `div` 6)) - winRem = fromIntegral $ nWin `mod` 6 - in do - let ret = - (zip (W.integrate stack) ( - (:) middleRect $ - (divRect topRect (portion * 2)) - ++ (divRect rightRect portion) - ++ (divRect bottomRect (portion * 2)) - ++ (divRect leftRect (portion + winRem))), Just l) - return ret - where - guard n 0 = n - guard _ n = n +data RectParentD = + RectParentD { + currentChild :: RectSetD - divRect (Rectangle x y w h) n = - if h > w - then - let h' = h `div` n - in flip map [0..(n - 1)] $ \mul -> - Rectangle x (y + fromIntegral (h' * mul)) w h' - else - let w' = w `div` n - in flip map [0..(n - 1)] $ \mul -> - Rectangle (x + fromIntegral (w' * mul)) y w' h + , leftChildren :: [RectSetD] + , rightChildren :: [RectSetD] - handleMessage (Center prop) m = - return $ fmap resize (fromMessage m) - where - resize Shrink = (Center (prop - 0.05)) - resize Expand = (Center (prop + 0.05)) - + , rectSetDWidth :: Float + , rectSetDHeight :: Float - emptyLayout c root = return ([], Just c) + , parentRect :: Maybe RectParentD + } + +derive :: RectSet -> Window -> Maybe RectSetD +derive (RectSet w h sub) = undefined + +getWindowRect :: Window -> X (Maybe Rectangle) +getWindowRect win = withDisplay $ \dpy -> do + (_, x, y, w, h, bw, _) <- liftIO $ getGeometry dpy win + catchX + (return $ Just $ Rectangle x y (w + 2 * bw) (h + 2 * bw)) + (return Nothing) diff --git a/src/Main.hs b/src/Main.hs index e3c1cc1..acde5a2 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -33,19 +33,20 @@ main = do , normalBorderColor = "#000000" , layoutHook = spacingRaw True (Border 5 5 5 5) True (Border 5 5 5 5) True $ - InterceptLayout $ myLayout , startupHook = do spawn fp , manageHook = composeAll [ isFullscreen --> doFullFloat , className =? "Tilda" --> doFloat + , className =? "yakuake" --> doFloat , className =? "MPlayer" --> doFloat , className =? "mpv" --> doFloat , className =? "gnubby_ssh_prompt" --> doFloat ] , workspaces = map return (['0'..'9'] ++ ['a'..'z']) - , handleEventHook = fullscreenEventHook + , handleEventHook = fullscreenEventHook + , focusFollowsMouse = False } let toggleStructsKey XConfig {XMonad.modMask = modMask} = (modMask, xK_b) @@ -66,7 +67,8 @@ main = do , ppLayout = const "" , ppExtras = [showLayout] , ppOrder = \ss -> - let (icons, etc) = partition ("<icon"`isPrefixOf`) ss in icons ++ etc + let (icons, etc) = partition ("<icon"`isPrefixOf`) ss + in icons ++ etc } toggleStructsKey config { modMask = mod4Mask } |