diff options
author | tv <tv@krebsco.de> | 2023-02-07 03:01:37 +0100 |
---|---|---|
committer | tv <tv@krebsco.de> | 2023-02-07 03:34:12 +0100 |
commit | fe48ecd3b1cc11f176c1080539b70abac956f0a0 (patch) | |
tree | 896a7153a5dc9b861e4321a44f925e97a696648a /src | |
parent | f28825e471e206bcb7e6dc8e4874c2b771f7d24c (diff) |
move EWMH-related stuff to Graphics.X11.EWMH
Diffstat (limited to 'src')
-rw-r--r-- | src/main.hs | 44 |
1 files changed, 6 insertions, 38 deletions
diff --git a/src/main.hs b/src/main.hs index 39f5491..2c500c7 100644 --- a/src/main.hs +++ b/src/main.hs @@ -6,7 +6,6 @@ module Main (main) where import Blessings.Text (Blessings(Plain,SGR),pp) -import Control.Applicative ((<|>)) import Control.Concurrent import Control.Monad (forM) import Control.Monad (forever) @@ -37,35 +36,15 @@ import qualified Data.Text.Extra as Text import qualified Data.Text.IO as Text import qualified Data.Text.Read as Text import qualified Graphics.X11 as X11 +import qualified Graphics.X11.EWMH as X11; import qualified Graphics.X11.Extra as X11 import qualified Graphics.X11.Xlib.Extras as X11 -import qualified Graphics.X11.Xlib.Extras.Extra as X11 import qualified Hack.Buffer as Buffer import qualified Hack.Buffer.Extra as Buffer import qualified Pager.Sixelerator as Pager import qualified System.Console.Terminal.Size as Term -getActiveWindow :: X11.Display -> IO (Maybe X11.Window) -getActiveWindow d = - (fmap (fromIntegral . head) <$>) $ - 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 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 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 getGeometry d w = do (_, x, y, width, height, _, _) <- X11.getGeometry d w @@ -76,25 +55,14 @@ getGeometry d w = do , geometry_height = fromIntegral height } -getWindowDesktop :: X11.Display -> X11.Window -> IO (Maybe CLong) -getWindowDesktop d w = - (fmap head <$>) $ - 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 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 let rootWindow = X11.defaultRootWindow display - currentDesktop <- fromMaybe 0 <$> getCurrentDesktop display + currentDesktop <- fromMaybe 0 <$> X11.getCurrentDesktop display workspaces <- do - names <- zip [0..] . fromMaybe [] <$> getDesktopNames display + names <- zip [0..] . fromMaybe [] <$> X11.getDesktopNames display ws <- forM names $ \(index, name) -> do return Workspace @@ -111,8 +79,8 @@ getWorkspaces display screenGeometry focusWindows = do let f w = do - title <- getWindowTitle display w - desktop <- fromMaybe 0 <$> getWindowDesktop display w + title <- X11.getWindowTitle display w + desktop <- fromMaybe 0 <$> X11.getWindowDesktop display w geometry <- getGeometry display w wm_hints <- X11.getWMHints display w @@ -173,7 +141,7 @@ main = do error $ "bad arguments: " <> show args - Just activeWindow <- X11.withDefaultDisplay getActiveWindow + Just activeWindow <- X11.withDefaultDisplay X11.getActiveWindow screenGeometry <- X11.withDefaultDisplay $ \display -> do |