mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
Merge pull request #923 from m1mir/feat/setEwmhSwitchDesktopAction
X.H.EwmhDesktops: Add customization for handling the _NET_CURRENT_DESKTOP requests
This commit is contained in:
commit
6df1044265
11
CHANGES.md
11
CHANGES.md
@ -39,6 +39,17 @@
|
|||||||
`DestroyWindowEvent` messages instead, which are broadcast to layouts
|
`DestroyWindowEvent` messages instead, which are broadcast to layouts
|
||||||
since xmonad v0.17.0.
|
since xmonad v0.17.0.
|
||||||
|
|
||||||
|
* `XMonad.Hooks.EwmhDesktops`
|
||||||
|
|
||||||
|
- 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 `setEwmhSwitchDesktopHook`.
|
||||||
|
|
||||||
|
* `XMonad.Layout.IndependentScreens`
|
||||||
|
|
||||||
|
- Added `focusWorkspace` for focusing workspaces on the screen that they
|
||||||
|
belong to.
|
||||||
|
|
||||||
## 0.18.1 (August 20, 2024)
|
## 0.18.1 (August 20, 2024)
|
||||||
|
|
||||||
### Breaking Changes
|
### Breaking Changes
|
||||||
|
@ -42,6 +42,10 @@ module XMonad.Hooks.EwmhDesktops (
|
|||||||
-- $customActivate
|
-- $customActivate
|
||||||
setEwmhActivateHook,
|
setEwmhActivateHook,
|
||||||
|
|
||||||
|
-- ** Workspace switching
|
||||||
|
-- $customWorkspaceSwitch
|
||||||
|
setEwmhSwitchDesktopHook,
|
||||||
|
|
||||||
-- ** Fullscreen
|
-- ** Fullscreen
|
||||||
-- $customFullscreen
|
-- $customFullscreen
|
||||||
setEwmhFullscreenHooks,
|
setEwmhFullscreenHooks,
|
||||||
@ -114,6 +118,8 @@ data EwmhDesktopsConfig =
|
|||||||
-- ^ configurable handling of window activation requests
|
-- ^ configurable handling of window activation requests
|
||||||
, fullscreenHooks :: (ManageHook, ManageHook)
|
, fullscreenHooks :: (ManageHook, ManageHook)
|
||||||
-- ^ configurable handling of fullscreen state requests
|
-- ^ configurable handling of fullscreen state requests
|
||||||
|
, switchDesktopHook :: WorkspaceId -> WindowSet -> WindowSet
|
||||||
|
-- ^ configurable action for handling _NET_CURRENT_DESKTOP
|
||||||
, manageDesktopViewport :: Bool
|
, manageDesktopViewport :: Bool
|
||||||
-- ^ manage @_NET_DESKTOP_VIEWPORT@?
|
-- ^ manage @_NET_DESKTOP_VIEWPORT@?
|
||||||
}
|
}
|
||||||
@ -124,6 +130,7 @@ instance Default EwmhDesktopsConfig where
|
|||||||
, workspaceRename = pure pure
|
, workspaceRename = pure pure
|
||||||
, activateHook = doFocus
|
, activateHook = doFocus
|
||||||
, fullscreenHooks = (doFullFloat, doSink)
|
, fullscreenHooks = (doFullFloat, doSink)
|
||||||
|
, switchDesktopHook = W.view
|
||||||
, manageDesktopViewport = True
|
, manageDesktopViewport = True
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,6 +252,31 @@ setEwmhActivateHook :: ManageHook -> XConfig l -> XConfig l
|
|||||||
setEwmhActivateHook h = XC.modifyDef $ \c -> c{ activateHook = h }
|
setEwmhActivateHook h = XC.modifyDef $ \c -> c{ activateHook = h }
|
||||||
|
|
||||||
|
|
||||||
|
-- $customWorkspaceSwitch
|
||||||
|
-- When a client sends a @_NET_CURRENT_DESKTOP@ request to switch to a workspace,
|
||||||
|
-- the default action used to do that is the 'W.view' function.
|
||||||
|
-- This may not be the desired behaviour in all configurations.
|
||||||
|
--
|
||||||
|
-- For example if using the "XMonad.Layout.IndependentScreens" the default action
|
||||||
|
-- might move a workspace to a screen that it isn't supposed to be on.
|
||||||
|
-- This behaviour can be fixed using the following:
|
||||||
|
--
|
||||||
|
-- > import XMonad.Actions.OnScreen
|
||||||
|
-- > import XMonad.Layout.IndependentScreens
|
||||||
|
-- >
|
||||||
|
-- > main = xmonad $ ... . setEwmhSwitchDesktopHook focusWorkspace . ewmh . ... $
|
||||||
|
-- > def{
|
||||||
|
-- > ...
|
||||||
|
-- > workspaces = withScreens 2 (workspaces def)
|
||||||
|
-- > ...
|
||||||
|
-- > }
|
||||||
|
|
||||||
|
-- | Set (replace) the action which is invoked when a client sends a
|
||||||
|
-- @_NET_CURRENT_DESKTOP@ request to switch workspace.
|
||||||
|
setEwmhSwitchDesktopHook :: (WorkspaceId -> WindowSet -> WindowSet) -> XConfig l -> XConfig l
|
||||||
|
setEwmhSwitchDesktopHook action = XC.modifyDef $ \c -> c{ switchDesktopHook = action }
|
||||||
|
|
||||||
|
|
||||||
-- $customFullscreen
|
-- $customFullscreen
|
||||||
-- When a client sends a @_NET_WM_STATE@ request to add\/remove\/toggle the
|
-- When a client sends a @_NET_WM_STATE@ request to add\/remove\/toggle the
|
||||||
-- @_NET_WM_STATE_FULLSCREEN@ state, 'ewmhFullscreen' uses a pair of hooks to
|
-- @_NET_WM_STATE_FULLSCREEN@ state, 'ewmhFullscreen' uses a pair of hooks to
|
||||||
@ -449,7 +481,7 @@ mkViewPorts winset = setDesktopViewport . concat . mapMaybe (viewPorts M.!?)
|
|||||||
ewmhDesktopsEventHook' :: Event -> EwmhDesktopsConfig -> X All
|
ewmhDesktopsEventHook' :: Event -> EwmhDesktopsConfig -> X All
|
||||||
ewmhDesktopsEventHook'
|
ewmhDesktopsEventHook'
|
||||||
ClientMessageEvent{ev_window = w, ev_message_type = mt, ev_data = d}
|
ClientMessageEvent{ev_window = w, ev_message_type = mt, ev_data = d}
|
||||||
EwmhDesktopsConfig{workspaceSort, activateHook} =
|
EwmhDesktopsConfig{workspaceSort, activateHook, switchDesktopHook} =
|
||||||
withWindowSet $ \s -> do
|
withWindowSet $ \s -> do
|
||||||
sort' <- workspaceSort
|
sort' <- workspaceSort
|
||||||
let ws = sort' $ W.workspaces s
|
let ws = sort' $ W.workspaces s
|
||||||
@ -462,7 +494,7 @@ ewmhDesktopsEventHook'
|
|||||||
if | mt == a_cw ->
|
if | mt == a_cw ->
|
||||||
killWindow w
|
killWindow w
|
||||||
| mt == a_cd, n : _ <- d, Just ww <- ws !? fi n ->
|
| mt == a_cd, n : _ <- d, Just ww <- ws !? fi n ->
|
||||||
if W.currentTag s == W.tag ww then mempty else windows $ W.view (W.tag ww)
|
if W.currentTag s == W.tag ww then mempty else windows $ switchDesktopHook (W.tag ww)
|
||||||
| mt == a_cd ->
|
| mt == a_cd ->
|
||||||
trace $ "Bad _NET_CURRENT_DESKTOP with data=" ++ show d
|
trace $ "Bad _NET_CURRENT_DESKTOP with data=" ++ show d
|
||||||
| not (w `W.member` s) ->
|
| not (w `W.member` s) ->
|
||||||
|
@ -27,7 +27,7 @@ module XMonad.Layout.IndependentScreens (
|
|||||||
whenCurrentOn,
|
whenCurrentOn,
|
||||||
countScreens,
|
countScreens,
|
||||||
workspacesOn,
|
workspacesOn,
|
||||||
workspaceOnScreen, focusWindow', focusScreen, nthWorkspace, withWspOnScreen,
|
workspaceOnScreen, focusWindow', focusScreen, focusWorkspace, nthWorkspace, withWspOnScreen,
|
||||||
-- * Converting between virtual and physical workspaces
|
-- * Converting between virtual and physical workspaces
|
||||||
-- $converting
|
-- $converting
|
||||||
marshall, unmarshall, unmarshallS, unmarshallW,
|
marshall, unmarshall, unmarshallS, unmarshallW,
|
||||||
@ -40,6 +40,7 @@ import XMonad
|
|||||||
import XMonad.Hooks.StatusBar.PP
|
import XMonad.Hooks.StatusBar.PP
|
||||||
import XMonad.Prelude
|
import XMonad.Prelude
|
||||||
import qualified XMonad.StackSet as W
|
import qualified XMonad.StackSet as W
|
||||||
|
import XMonad.Actions.OnScreen (viewOnScreen)
|
||||||
|
|
||||||
-- $usage
|
-- $usage
|
||||||
-- You can use this module with the following in your @xmonad.hs@:
|
-- 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 -> WindowSet -> WindowSet
|
||||||
focusScreen screenId = withWspOnScreen screenId W.view
|
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
|
-- | Get the nth virtual workspace
|
||||||
nthWorkspace :: Int -> X (Maybe VirtualWorkspace)
|
nthWorkspace :: Int -> X (Maybe VirtualWorkspace)
|
||||||
nthWorkspace n = (!? n) . workspaces' <$> asks config
|
nthWorkspace n = (!? n) . workspaces' <$> asks config
|
||||||
|
Loading…
x
Reference in New Issue
Block a user