blob: 2cec02592e81b5233a86711ffc8a63dd6a50351f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
{-# LANGUAGE TemplateHaskell #-}
module Pager.Types where
import Data.Aeson.TH (Options(fieldLabelModifier), deriveJSON, defaultOptions)
import Data.Text (Text)
data Action
= None
-- | FocusWindow Int (Maybe Text)
| FocusWorkspace Text
-- | MoveWindowToWorkspace Int Text
-- | CopyWindowToWorkspace Int Text
| Batch Action Action
instance Monoid Action where
mempty = None
instance Semigroup Action where
x <> None = x
None <> x = x
Batch x1 x2 <> Batch x3 x4 = x1 <> x2 <> x3 <> x4
Batch x1 x2 <> x3 = x1 <> x2 <> x3
x1 <> x2 = Batch x1 x2
data Geometry = Geometry
{ geometry_x :: Int
, geometry_y :: Int
, geometry_width :: Int
, geometry_height :: Int
}
data Window = Window
{ window_id :: Int
, window_title :: Text
, window_geometry :: Geometry
, window_focused :: Bool
, window_urgent :: Bool
}
data Workspace = Workspace
{ workspace_geometry :: Geometry
, workspace_focused :: Bool
, workspace_name :: Text
, workspace_windows :: [Window] -- sorted by z-order, earlier windows overlap later ones
}
$(deriveJSON defaultOptions { fieldLabelModifier = tail . dropWhile (/='_') } ''Geometry)
$(deriveJSON defaultOptions { fieldLabelModifier = tail . dropWhile (/='_') } ''Window)
$(deriveJSON defaultOptions { fieldLabelModifier = tail . dropWhile (/='_') } ''Workspace)
|