aboutsummaryrefslogtreecommitdiff
path: root/src/Internal/Layout.hs
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2020-02-06 15:25:31 -0700
committerJosh Rahm <rahm@google.com>2020-02-06 15:25:31 -0700
commit8c6abcaebc16c8dd805a3a8f9cc57e35890c3bc5 (patch)
tree06bf11d9bd386c4b0ca7f35793d71fa3b5955cac /src/Internal/Layout.hs
parent9169597a7dcef8046f415b77e0e6cbad696ff5a2 (diff)
downloadrde-8c6abcaebc16c8dd805a3a8f9cc57e35890c3bc5.tar.gz
rde-8c6abcaebc16c8dd805a3a8f9cc57e35890c3bc5.tar.bz2
rde-8c6abcaebc16c8dd805a3a8f9cc57e35890c3bc5.zip
Multiple changes. Mostly added a prompt to quickly switch between windows by fuzzy-finding them
Diffstat (limited to 'src/Internal/Layout.hs')
-rw-r--r--src/Internal/Layout.hs87
1 files changed, 35 insertions, 52 deletions
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)