diff options
| author | tv <tv@krebsco.de> | 2026-11-12 02:35:57 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-12 02:35:57 +0000 |
| commit | 252f3c6f4728c19a7ee171b446e1ce168686b44b (patch) | |
| tree | 1e930362ed70ee3258168dbf3ff421d02acc895b /src/Pager/Backend/Rivermonad.hs | |
| parent | e974ac31ff1e08ca681db3c4108ae2a596e5655c (diff) | |
desktop-pager and desktops now also work on rivermonad, a window manager
for the river Wayland compositor, over its IPC socket.
The window manager access of desktop-pager moves behind Pager.Backend,
with the existing code in Pager.Backend.X11 and the new one in
Pager.Backend.Rivermonad. desktops gets the same choice. rivermonad is
used when its socket for this Wayland display exists;
DESKTOP_PAGER_BACKEND=x11 or =rivermonad overrides that.
Rivermonad.Client, in the library, is the IPC client: a snapshot of all
workspaces and windows, and actions to view a workspace, move a window
and set the list of workspaces.
On X11, desktops are now looked up by name when the pager acts instead
of in the list read at startup.
Diffstat (limited to 'src/Pager/Backend/Rivermonad.hs')
| -rw-r--r-- | src/Pager/Backend/Rivermonad.hs | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/Pager/Backend/Rivermonad.hs b/src/Pager/Backend/Rivermonad.hs new file mode 100644 index 0000000..b2d6365 --- /dev/null +++ b/src/Pager/Backend/Rivermonad.hs @@ -0,0 +1,61 @@ +-- | The pager on rivermonad (a window manager for the river Wayland +-- compositor), over its IPC socket. +module Pager.Backend.Rivermonad + ( getScreenGeometry + , getWorkspaces + , viewWorkspace + , shiftWindowToWorkspace + ) where + +import Data.Text (Text) +import Pager.Types +import qualified Data.List as List +import qualified Rivermonad.Client as Client + + +geometry :: Client.Rect -> Geometry +geometry r = + Geometry + { geometry_x = Client.rect_x r + , geometry_y = Client.rect_y r + , geometry_width = Client.rect_width r + , geometry_height = Client.rect_height r + } + +getScreenGeometry :: IO Geometry +getScreenGeometry = + geometry . Client.snapshot_screen <$> Client.getSnapshot + +-- The window manager knows which window every workspace focuses, so the +-- window ids from the command line are not needed here. +getWorkspaces :: Geometry -> [Int] -> IO [Workspace] +getWorkspaces screenGeometry _focusWindows = + map workspace . Client.snapshot_workspaces <$> Client.getSnapshot + where + workspace ws = + Workspace + { workspace_geometry = screenGeometry + , workspace_focused = Client.workspace_focused ws + , workspace_name = Client.workspace_name ws + , workspace_windows = + uncurry (<>) $ + List.partition window_focused $ + map window (Client.workspace_windows ws) + } + + window w = + Window + { window_id = Client.window_id w + , window_title = Client.window_title w + , window_geometry = geometry (Client.window_rect w) + , window_focused = Client.window_focused w + -- River cannot tell the window manager yet that a window wants + -- attention. + , window_urgent = False + } + +viewWorkspace :: Text -> IO () +viewWorkspace = Client.viewWorkspace + +shiftWindowToWorkspace :: Int -> Text -> IO () +shiftWindowToWorkspace = Client.shiftWindow |
