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.hs | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/Pager/Backend.hs (limited to 'src/Pager/Backend.hs') diff --git a/src/Pager/Backend.hs b/src/Pager/Backend.hs new file mode 100644 index 0000000..e126dcc --- /dev/null +++ b/src/Pager/Backend.hs @@ -0,0 +1,43 @@ +-- | What the pager needs from a window manager. +module Pager.Backend + ( Backend(..) + , getBackend + ) where + +import Data.Text (Text) +import Pager.Types +import qualified Pager.Backend.Rivermonad +import qualified Pager.Backend.X11 +import qualified Rivermonad.Client + + +data Backend = Backend + { getScreenGeometry :: IO Geometry + , getWorkspaces :: Geometry -> [Int] -> IO [Workspace] + -- ^ Screen geometry and the focused window of every workspace, as + -- given on the command line. + , viewWorkspace :: Text -> IO () + , shiftWindowToWorkspace :: Int -> Text -> IO () + } + + +-- | rivermonad if its socket is there, EWMH on X11 otherwise. See +-- 'Rivermonad.Client.selected'. +getBackend :: IO Backend +getBackend = do + rivermonad <- Rivermonad.Client.selected + return $ + if rivermonad then + Backend + { getScreenGeometry = Pager.Backend.Rivermonad.getScreenGeometry + , getWorkspaces = Pager.Backend.Rivermonad.getWorkspaces + , viewWorkspace = Pager.Backend.Rivermonad.viewWorkspace + , shiftWindowToWorkspace = Pager.Backend.Rivermonad.shiftWindowToWorkspace + } + else + Backend + { getScreenGeometry = Pager.Backend.X11.getScreenGeometry + , getWorkspaces = Pager.Backend.X11.getWorkspaces + , viewWorkspace = Pager.Backend.X11.viewWorkspace + , shiftWindowToWorkspace = Pager.Backend.X11.shiftWindowToWorkspace + } -- cgit v1.3.1