Skip to content

Commit

Permalink
X.H.EwmhDesktops: renamed setEwmhSwitchDesktopAction to setEwmhSwitch…
Browse files Browse the repository at this point in the history
…DesktopHook.
  • Loading branch information
m1mir committed Jan 24, 2025
1 parent 6fd934a commit 618dec7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

- Added a customization option for the action that gets executed when
a client sends a **_NET_CURRENT_DESKTOP** request. It is now possible
to change it using the `setEwmhSwitchDesktopAction`.
to change it using the `setEwmhSwitchDesktopHook`.

* `XMonad.Layout.IndependentScreens`

Expand Down
16 changes: 8 additions & 8 deletions XMonad/Hooks/EwmhDesktops.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module XMonad.Hooks.EwmhDesktops (

-- ** Workspace switching
-- $customWorkspaceSwitch
setEwmhSwitchDesktopAction,
setEwmhSwitchDesktopHook,

-- ** Fullscreen
-- $customFullscreen
Expand Down Expand Up @@ -118,7 +118,7 @@ data EwmhDesktopsConfig =
-- ^ configurable handling of window activation requests
, fullscreenHooks :: (ManageHook, ManageHook)
-- ^ configurable handling of fullscreen state requests
, switchDesktopAction :: WorkspaceId -> WindowSet -> WindowSet
, switchDesktopHook :: WorkspaceId -> WindowSet -> WindowSet
-- ^ configurable action for handling _NET_CURRENT_DESKTOP
, manageDesktopViewport :: Bool
-- ^ manage @_NET_DESKTOP_VIEWPORT@?
Expand All @@ -130,7 +130,7 @@ instance Default EwmhDesktopsConfig where
, workspaceRename = pure pure
, activateHook = doFocus
, fullscreenHooks = (doFullFloat, doSink)
, switchDesktopAction = W.view
, switchDesktopHook = W.view
, manageDesktopViewport = True
}

Expand Down Expand Up @@ -264,7 +264,7 @@ setEwmhActivateHook h = XC.modifyDef $ \c -> c{ activateHook = h }
-- > import XMonad.Actions.OnScreen
-- > import XMonad.Layout.IndependentScreens
-- >
-- > main = xmonad $ ... . setEwmhSwitchDesktopAction focusWorkspace . ewmh . ... $
-- > main = xmonad $ ... . setEwmhSwitchDesktopHook focusWorkspace . ewmh . ... $
-- > def{
-- > ...
-- > workspaces = withScreens 2 (workspaces def)
Expand All @@ -273,8 +273,8 @@ setEwmhActivateHook h = XC.modifyDef $ \c -> c{ activateHook = h }

-- | Set (replace) the action which is invoked when a client sends a
-- @_NET_CURRENT_DESKTOP@ request to switch workspace.
setEwmhSwitchDesktopAction :: (WorkspaceId -> WindowSet -> WindowSet) -> XConfig l -> XConfig l
setEwmhSwitchDesktopAction action = XC.modifyDef $ \c -> c{ switchDesktopAction = action }
setEwmhSwitchDesktopHook :: (WorkspaceId -> WindowSet -> WindowSet) -> XConfig l -> XConfig l
setEwmhSwitchDesktopHook action = XC.modifyDef $ \c -> c{ switchDesktopHook = action }


-- $customFullscreen
Expand Down Expand Up @@ -481,7 +481,7 @@ mkViewPorts winset = setDesktopViewport . concat . mapMaybe (viewPorts M.!?)
ewmhDesktopsEventHook' :: Event -> EwmhDesktopsConfig -> X All
ewmhDesktopsEventHook'
ClientMessageEvent{ev_window = w, ev_message_type = mt, ev_data = d}
EwmhDesktopsConfig{workspaceSort, activateHook, switchDesktopAction} =
EwmhDesktopsConfig{workspaceSort, activateHook, switchDesktopHook} =
withWindowSet $ \s -> do
sort' <- workspaceSort
let ws = sort' $ W.workspaces s
Expand All @@ -494,7 +494,7 @@ ewmhDesktopsEventHook'
if | mt == a_cw ->
killWindow w
| mt == a_cd, n : _ <- d, Just ww <- ws !? fi n ->
if W.currentTag s == W.tag ww then mempty else windows $ switchDesktopAction (W.tag ww)
if W.currentTag s == W.tag ww then mempty else windows $ switchDesktopHook (W.tag ww)
| mt == a_cd ->
trace $ "Bad _NET_CURRENT_DESKTOP with data=" ++ show d
| not (w `W.member` s) ->
Expand Down
2 changes: 1 addition & 1 deletion XMonad/Layout/IndependentScreens.hs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ 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.setEwmhSwitchDesktopAction`
-- An example usage can be found at `XMonad.Hooks.EwmhDesktops.setEwmhSwitchDesktopHook`
focusWorkspace :: WorkspaceId -> WindowSet -> WindowSet
focusWorkspace workspaceId = viewOnScreen (unmarshallS workspaceId) workspaceId

Expand Down

0 comments on commit 618dec7

Please sign in to comment.