From 252f3c6f4728c19a7ee171b446e1ce168686b44b Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 12 Nov 2026 02:35:57 +0000 Subject: add a rivermonad backend next to the EWMH one 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. --- src/Pager/Backend/Rivermonad.hs | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/Pager/Backend/Rivermonad.hs (limited to 'src/Pager/Backend/Rivermonad.hs') 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 -- cgit v1.3.1