From fa76527abf2da5fb38b8fd65a1c7fd57d4c1d8c8 Mon Sep 17 00:00:00 2001 From: m1mir Date: Fri, 24 Jan 2025 02:52:40 +0100 Subject: [PATCH] X.L.IndependentScreens: Added focusWorkspace function. --- CHANGES.md | 5 +++++ XMonad/Layout/IndependentScreens.hs | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 86640753f..6cd65e9b6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -45,6 +45,11 @@ a client sends a **_NET_CURRENT_DESKTOP** request. It is now possible to change it using the `setEwmhSwitchDesktopHook`. + * `XMonad.Layout.IndependentScreens` + + - Added `focusWorkspace` for focusing workspaces on the screen that they + belong to. + ## 0.18.1 (August 20, 2024) ### Breaking Changes diff --git a/XMonad/Layout/IndependentScreens.hs b/XMonad/Layout/IndependentScreens.hs index 49f110197..a84f604cf 100644 --- a/XMonad/Layout/IndependentScreens.hs +++ b/XMonad/Layout/IndependentScreens.hs @@ -27,7 +27,7 @@ module XMonad.Layout.IndependentScreens ( whenCurrentOn, countScreens, workspacesOn, - workspaceOnScreen, focusWindow', focusScreen, nthWorkspace, withWspOnScreen, + workspaceOnScreen, focusWindow', focusScreen, focusWorkspace, nthWorkspace, withWspOnScreen, -- * Converting between virtual and physical workspaces -- $converting marshall, unmarshall, unmarshallS, unmarshallW, @@ -40,6 +40,7 @@ import XMonad import XMonad.Hooks.StatusBar.PP import XMonad.Prelude import qualified XMonad.StackSet as W +import XMonad.Actions.OnScreen (viewOnScreen) -- $usage -- You can use this module with the following in your @xmonad.hs@: @@ -163,6 +164,11 @@ focusWindow' window ws focusScreen :: ScreenId -> WindowSet -> WindowSet focusScreen screenId = withWspOnScreen screenId W.view +-- | Focus the given workspace on the correct Xinerama screen. +-- An example usage can be found at `XMonad.Hooks.EwmhDesktops.setEwmhSwitchDesktopHook` +focusWorkspace :: WorkspaceId -> WindowSet -> WindowSet +focusWorkspace workspaceId = viewOnScreen (unmarshallS workspaceId) workspaceId + -- | Get the nth virtual workspace nthWorkspace :: Int -> X (Maybe VirtualWorkspace) nthWorkspace n = (!? n) . workspaces' <$> asks config