Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EWMH: Improve interface for custom sorting, filtering, renaming and window activation #626

Merged
merged 10 commits into from
Oct 20, 2021
27 changes: 18 additions & 9 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,18 @@
`XMonad.Layout.Fullscreen.fullscreenSupport` now advertises it as well,
and no configuration changes are required in this case.

- `ewmh` function will use `logHook` for handling activated window. And now
by default window activation will do nothing.

You can use regular `ManageHook` combinators for changing window
activation behavior and then add resulting `ManageHook` using
`activateLogHook` to your `logHook`. Also, module `X.H.Focus` provides
additional combinators.
- Deprecated `ewmhDesktopsLogHookCustom` and `ewmhDesktopsEventHookCustom`;
these are now replaced by a composable `XMonad.Util.ExtensibleConf`-based
interface. Users are advised to just use the `ewmh` XConfig combinator
and customize behaviour using the provided `addEwmhWorkspaceSort`,
`addEwmhWorkspaceRename` functions, or better still, use integrations
provided by modules such as `XMonad.Actions.WorkspaceNames`.

This interface now additionally allows customization of what happens
when clients request window activation. This can be used to ignore
activation of annoying applications, to mark windows as urgent instead
of focusing them, and more. There's also a new `XMonad.Hooks.Focus`
module extending the ManageHook EDSL with useful combinators.

- Ordering of windows that are set to `_NET_CLIENT_LIST` and `_NET_CLIENT_LIST_STACKING`
was changed to be closer to the spec. From now these two lists will have
Expand Down Expand Up @@ -538,8 +543,8 @@

* `XMonad.Actions.WorkspaceNames`

- Added `workspaceNamesListTransform` which makes workspace names visible
to external pagers.
- Added `workspaceNamesEwmh` which makes workspace names visible to
external pagers.

* `XMonad.Util.PureX`

Expand Down Expand Up @@ -637,6 +642,10 @@
- Added a variant of `filterUrgencyHook` that takes a generic `Query Bool`
to select which windows should never be marked urgent.

- Added `askUrgent` and a `doAskUrgent` manage hook helper for marking
windows as urgent from inside of xmonad. This can be used as a less
intrusive action for windows requesting focus.

* `XMonad.Hooks.ServerMode`

- To make it easier to use, the `xmonadctl` client is now included in
Expand Down
35 changes: 18 additions & 17 deletions XMonad/Actions/WorkspaceNames.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ module XMonad.Actions.WorkspaceNames (

-- * Workspace naming
renameWorkspace,
workspaceNamesPP,
getWorkspaceNames',
getWorkspaceNames,
getWorkspaceName,
Expand All @@ -38,8 +37,9 @@ module XMonad.Actions.WorkspaceNames (
-- * Workspace prompt
workspaceNamePrompt,

-- * EwmhDesktops integration
workspaceNamesListTransform
-- * StatusBar, EwmhDesktops integration
workspaceNamesPP,
workspaceNamesEwmh,
) where

import XMonad
Expand All @@ -50,6 +50,7 @@ import qualified XMonad.Util.ExtensibleState as XS
import XMonad.Actions.CycleWS (findWorkspace, WSType(..), Direction1D(..), anyWS)
import qualified XMonad.Actions.SwapWorkspaces as Swap
import XMonad.Hooks.StatusBar.PP (PP(..))
import XMonad.Hooks.EwmhDesktops (addEwmhWorkspaceRename)
import XMonad.Prompt (mkXPrompt, XPConfig)
import XMonad.Prompt.Workspace (Wor(Wor))
import XMonad.Util.WorkspaceCompare (getSortByIndex)
Expand All @@ -72,6 +73,11 @@ import qualified Data.Map as M
-- Check "XMonad.Hooks.StatusBar" for more information on how to incorprate
-- this into your status bar.
--
-- To expose workspace names to pagers and other EWMH clients, integrate this
-- with "XMonad.Hooks.EwmhDesktops":
--
-- > main = xmonad $ … . workspaceNamesEwmh . ewmh . … $ def{…}
--
-- We also provide a modification of "XMonad.Actions.SwapWorkspaces"\'s
-- functionality, which may be used this way:
--
Expand Down Expand Up @@ -135,11 +141,6 @@ renameWorkspace conf =
mkXPrompt pr conf (const (return [])) setCurrentWorkspaceName
where pr = Wor "Workspace name: "

-- | Modify 'XMonad.Hooks.StatusBar.PP.PP'\'s pretty-printing format to show
-- workspace names as well.
workspaceNamesPP :: PP -> X PP
workspaceNamesPP pp = getWorkspaceNames ":" <&> \ren -> pp{ ppRename = ppRename pp >=> ren }

-- | See 'XMonad.Actions.SwapWorkspaces.swapTo'. This is the same with names.
swapTo :: Direction1D -> X ()
swapTo dir = swapTo' dir anyWS
Expand Down Expand Up @@ -177,12 +178,12 @@ workspaceNamePrompt conf job = do
contains completions input =
return $ filter (isInfixOf input) completions

-- | Workspace list transformation for
-- 'XMonad.Hooks.EwmhDesktops.ewmhDesktopsLogHookCustom' that exposes
-- workspace names to pagers and other EWMH-aware clients.
--
-- Usage:
-- > logHook = (workspaceNamesListTransform >>= ewmhDesktopsLogHookCustom) <+> …
workspaceNamesListTransform :: X ([WindowSpace] -> [WindowSpace])
workspaceNamesListTransform =
getWorkspaceNames ":" <&> \names -> map $ \ws -> ws{ W.tag = names (W.tag ws) ws }
-- | Modify 'XMonad.Hooks.StatusBar.PP.PP'\'s pretty-printing format to show
-- workspace names as well.
workspaceNamesPP :: PP -> X PP
workspaceNamesPP pp = getWorkspaceNames ":" <&> \ren -> pp{ ppRename = ppRename pp >=> ren }

-- | Tell "XMonad.Hooks.EwmhDesktops" to append workspace names to desktop
-- names.
workspaceNamesEwmh :: XConfig l -> XConfig l
workspaceNamesEwmh = addEwmhWorkspaceRename $ getWorkspaceNames ":"
8 changes: 3 additions & 5 deletions XMonad/Config/Bluetile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,13 @@ bluetileLayoutHook = avoidStruts $ minimize $ boringWindows $
floatingDeco l = buttonDeco shrinkText defaultThemeWithButtons l

bluetileConfig =
docks $
docks . ewmhFullscreen . ewmh $
def
{ modMask = mod4Mask, -- logo key
manageHook = bluetileManageHook,
layoutHook = bluetileLayoutHook,
logHook = currentWorkspaceOnTop >> ewmhDesktopsLogHook,
handleEventHook = ewmhDesktopsEventHook
`mappend` fullscreenEventHook
`mappend` minimizeEventHook
logHook = currentWorkspaceOnTop,
handleEventHook = minimizeEventHook
`mappend` serverModeEventHook' bluetileCommands
`mappend` positionStoreEventHook,
workspaces = bluetileWorkspaces,
Expand Down
7 changes: 0 additions & 7 deletions XMonad/Config/Desktop.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ import XMonad.Hooks.ManageDocks
import XMonad.Hooks.EwmhDesktops
import XMonad.Layout.LayoutModifier (ModifiedLayout)
import XMonad.Util.Cursor
import qualified XMonad.StackSet as W

import qualified Data.Map as M

Expand Down Expand Up @@ -172,7 +171,6 @@ desktopConfig :: XConfig (ModifiedLayout AvoidStruts
desktopConfig = docks $ ewmh def
{ startupHook = setDefaultCursor xC_left_ptr <+> startupHook def
, layoutHook = desktopLayoutModifiers $ layoutHook def
, logHook = desktopLogHook <+> logHook def
, keys = desktopKeys <+> keys def }

desktopKeys :: XConfig l -> M.Map (KeyMask, KeySym) (X ())
Expand All @@ -181,8 +179,3 @@ desktopKeys XConfig{modMask = modm} = M.fromList

desktopLayoutModifiers :: LayoutClass l a => l a -> ModifiedLayout AvoidStruts l a
desktopLayoutModifiers = avoidStruts

-- | 'logHook' preserving old 'ewmh' behavior to switch workspace and focus to
-- activated window.
desktopLogHook :: X ()
desktopLogHook = activateLogHook (reader W.focusWindow >>= doF)