diff options
Diffstat (limited to 'src/main.hs')
-rw-r--r-- | src/main.hs | 52 |
1 files changed, 12 insertions, 40 deletions
diff --git a/src/main.hs b/src/main.hs index 669aedd..39f5491 100644 --- a/src/main.hs +++ b/src/main.hs @@ -46,52 +46,24 @@ import qualified Pager.Sixelerator as Pager import qualified System.Console.Terminal.Size as Term -atom_NET_ACTIVE_WINDOW :: X11.Atom -atom_NET_ACTIVE_WINDOW = X11.unsafeInternAtom "_NET_ACTIVE_WINDOW" True - -atom_NET_CLIENT_LIST :: X11.Atom -atom_NET_CLIENT_LIST = X11.unsafeInternAtom "_NET_CLIENT_LIST" True - -atom_NET_CURRENT_DESKTOP :: X11.Atom -atom_NET_CURRENT_DESKTOP = X11.unsafeInternAtom "_NET_CURRENT_DESKTOP" True - -atom_NET_DESKTOP_NAMES :: X11.Atom -atom_NET_DESKTOP_NAMES = X11.unsafeInternAtom "_NET_DESKTOP_NAMES" True - -atom_NET_WM_DESKTOP :: X11.Atom -atom_NET_WM_DESKTOP = X11.unsafeInternAtom "_NET_WM_DESKTOP" True - -atom_NET_WM_NAME :: X11.Atom -atom_NET_WM_NAME = X11.unsafeInternAtom "_NET_WM_NAME" True - -atom_WIN_WORKSPACE :: X11.Atom -atom_WIN_WORKSPACE = X11.unsafeInternAtom "_WIN_WORKSPACE" True - -atom_WIN_WORKSPACE_NAMES :: X11.Atom -atom_WIN_WORKSPACE_NAMES = X11.unsafeInternAtom "_WIN_WORKSPACE_NAMES" True - -atom_WM_NAME :: X11.Atom -atom_WM_NAME = X11.unsafeInternAtom "WM_NAME" True - - getActiveWindow :: X11.Display -> IO (Maybe X11.Window) getActiveWindow d = (fmap (fromIntegral . head) <$>) $ - X11.getWindowProperty32 d atom_NET_ACTIVE_WINDOW w + X11.getWindowProperty32 d X11._NET_ACTIVE_WINDOW w where w = X11.defaultRootWindow d getCurrentDesktop :: X11.Display -> IO (Maybe CLong) getCurrentDesktop d = (fmap head <$>) $ - X11.getWindowProperty32 d atom_NET_CURRENT_DESKTOP w <|> - X11.getWindowProperty32 d atom_WIN_WORKSPACE w + X11.getWindowProperty32 d X11._NET_CURRENT_DESKTOP w <|> + X11.getWindowProperty32 d X11._WIN_WORKSPACE w where w = X11.defaultRootWindow d getDesktopNames :: X11.Display -> IO (Maybe [Text]) getDesktopNames d = do (fmap (Text.split (=='\NUL')) <$>) $ - X11.getWindowPropertyText d atom_NET_DESKTOP_NAMES w <|> - X11.getWindowPropertyText d atom_WIN_WORKSPACE_NAMES w + X11.getWindowPropertyText d X11._NET_DESKTOP_NAMES w <|> + X11.getWindowPropertyText d X11._WIN_WORKSPACE_NAMES w where w = X11.defaultRootWindow d getGeometry :: X11.Display -> X11.Window -> IO Geometry @@ -107,13 +79,13 @@ getGeometry d w = do getWindowDesktop :: X11.Display -> X11.Window -> IO (Maybe CLong) getWindowDesktop d w = (fmap head <$>) $ - X11.getWindowProperty32 d atom_NET_WM_DESKTOP w <|> - X11.getWindowProperty32 d atom_WIN_WORKSPACE w + X11.getWindowProperty32 d X11._NET_WM_DESKTOP w <|> + X11.getWindowProperty32 d X11._WIN_WORKSPACE w getWindowTitle :: X11.Display -> X11.Window -> IO (Maybe Text) getWindowTitle d w = - X11.getWindowPropertyText d atom_NET_WM_NAME w <|> - X11.getWindowPropertyText d atom_WM_NAME w + X11.getWindowPropertyText d X11._NET_WM_NAME w <|> + X11.getWindowPropertyText d X11._WM_NAME w getWorkspaces :: X11.Display -> Geometry -> Set X11.Window -> IO [Workspace] getWorkspaces display screenGeometry focusWindows = do @@ -135,7 +107,7 @@ getWorkspaces display screenGeometry focusWindows = do clientList <- maybe [] (map fromIntegral) <$> - X11.getWindowProperty32 display atom_NET_CLIENT_LIST rootWindow + X11.getWindowProperty32 display X11._NET_CLIENT_LIST rootWindow let f w = do @@ -291,7 +263,7 @@ switchDesktop :: X11.Display -> CLong -> IO () switchDesktop d s = X11.allocaXEvent $ \e -> do X11.setEventType e X11.clientMessage - X11.setClientMessageEvent' e w atom_NET_CURRENT_DESKTOP 32 [fromIntegral s,0,0,0,0] + X11.setClientMessageEvent' e w X11._NET_CURRENT_DESKTOP 32 [fromIntegral s,0,0,0,0] X11.sendEvent d w False mask e where w = X11.defaultRootWindow d @@ -302,7 +274,7 @@ windowToDesktop :: X11.Display -> X11.Window -> CLong -> IO () windowToDesktop d w s = X11.allocaXEvent $ \e -> do X11.setEventType e X11.clientMessage - X11.setClientMessageEvent' e (fromIntegral w) atom_NET_WM_DESKTOP 32 [fromIntegral s,0,0,0,0] + X11.setClientMessageEvent' e (fromIntegral w) X11._NET_WM_DESKTOP 32 [fromIntegral s,0,0,0,0] X11.sendEvent d (fromIntegral w) True mask e where mask = X11.substructureRedirectMask .|. X11.substructureNotifyMask |