{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE PatternGuards #-}
module XMonad.Hooks.EwmhDesktops (
ewmh,
ewmhFullscreen,
ewmhDesktopsManageHook,
ewmhDesktopsMaybeManageHook,
addEwmhWorkspaceSort, setEwmhWorkspaceSort,
addEwmhWorkspaceRename, setEwmhWorkspaceRename,
setEwmhActivateHook,
setEwmhFullscreenHooks,
disableEwmhManageDesktopViewport,
ewmhDesktopsStartup,
ewmhDesktopsLogHook,
ewmhDesktopsLogHookCustom,
ewmhDesktopsEventHook,
ewmhDesktopsEventHookCustom,
fullscreenEventHook,
fullscreenStartup,
) where
import Codec.Binary.UTF8.String (encode)
import Data.Bits
import qualified Data.Map.Strict as M
import XMonad
import XMonad.Prelude
import qualified XMonad.StackSet as W
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.SetWMName
import XMonad.Util.WorkspaceCompare
import XMonad.Util.WindowProperties (getProp32)
import qualified XMonad.Util.ExtensibleConf as XC
import qualified XMonad.Util.ExtensibleState as XS
ewmh :: XConfig a -> XConfig a
ewmh :: forall (a :: * -> *). XConfig a -> XConfig a
ewmh XConfig a
c = XConfig a
c { startupHook :: X ()
startupHook = X ()
ewmhDesktopsStartup forall a. Semigroup a => a -> a -> a
<> forall (l :: * -> *). XConfig l -> X ()
startupHook XConfig a
c
, handleEventHook :: Event -> X All
handleEventHook = Event -> X All
ewmhDesktopsEventHook forall a. Semigroup a => a -> a -> a
<> forall (l :: * -> *). XConfig l -> Event -> X All
handleEventHook XConfig a
c
, logHook :: X ()
logHook = X ()
ewmhDesktopsLogHook forall a. Semigroup a => a -> a -> a
<> forall (l :: * -> *). XConfig l -> X ()
logHook XConfig a
c }
data EwmhDesktopsConfig =
EwmhDesktopsConfig
{ EwmhDesktopsConfig -> X WorkspaceSort
workspaceSort :: X WorkspaceSort
, EwmhDesktopsConfig -> X (WorkspaceId -> WindowSpace -> WorkspaceId)
workspaceRename :: X (String -> WindowSpace -> String)
, EwmhDesktopsConfig -> Query (Endo WindowSet)
activateHook :: ManageHook
, EwmhDesktopsConfig
-> (Query (Endo WindowSet), Query (Endo WindowSet))
fullscreenHooks :: (ManageHook, ManageHook)
, EwmhDesktopsConfig -> Bool
manageDesktopViewport :: Bool
}
instance Default EwmhDesktopsConfig where
def :: EwmhDesktopsConfig
def = EwmhDesktopsConfig
{ workspaceSort :: X WorkspaceSort
workspaceSort = X WorkspaceSort
getSortByIndex
, workspaceRename :: X (WorkspaceId -> WindowSpace -> WorkspaceId)
workspaceRename = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall (f :: * -> *) a. Applicative f => a -> f a
pure
, activateHook :: Query (Endo WindowSet)
activateHook = Query (Endo WindowSet)
doFocus
, fullscreenHooks :: (Query (Endo WindowSet), Query (Endo WindowSet))
fullscreenHooks = (Query (Endo WindowSet)
doFullFloat, Query (Endo WindowSet)
doSink)
, manageDesktopViewport :: Bool
manageDesktopViewport = Bool
True
}
addEwmhWorkspaceSort :: X WorkspaceSort -> XConfig l -> XConfig l
addEwmhWorkspaceSort :: forall (l :: * -> *). X WorkspaceSort -> XConfig l -> XConfig l
addEwmhWorkspaceSort X WorkspaceSort
f = forall a (l :: * -> *).
(Default a, Typeable a) =>
(a -> a) -> XConfig l -> XConfig l
XC.modifyDef forall a b. (a -> b) -> a -> b
$ \EwmhDesktopsConfig
c -> EwmhDesktopsConfig
c{ workspaceSort :: X WorkspaceSort
workspaceSort = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) X WorkspaceSort
f (EwmhDesktopsConfig -> X WorkspaceSort
workspaceSort EwmhDesktopsConfig
c) }
setEwmhWorkspaceSort :: X WorkspaceSort -> XConfig l -> XConfig l
setEwmhWorkspaceSort :: forall (l :: * -> *). X WorkspaceSort -> XConfig l -> XConfig l
setEwmhWorkspaceSort X WorkspaceSort
f = forall a (l :: * -> *).
(Default a, Typeable a) =>
(a -> a) -> XConfig l -> XConfig l
XC.modifyDef forall a b. (a -> b) -> a -> b
$ \EwmhDesktopsConfig
c -> EwmhDesktopsConfig
c{ workspaceSort :: X WorkspaceSort
workspaceSort = X WorkspaceSort
f }
addEwmhWorkspaceRename :: X (String -> WindowSpace -> String) -> XConfig l -> XConfig l
addEwmhWorkspaceRename :: forall (l :: * -> *).
X (WorkspaceId -> WindowSpace -> WorkspaceId)
-> XConfig l -> XConfig l
addEwmhWorkspaceRename X (WorkspaceId -> WindowSpace -> WorkspaceId)
f = forall a (l :: * -> *).
(Default a, Typeable a) =>
(a -> a) -> XConfig l -> XConfig l
XC.modifyDef forall a b. (a -> b) -> a -> b
$ \EwmhDesktopsConfig
c -> EwmhDesktopsConfig
c{ workspaceRename :: X (WorkspaceId -> WindowSpace -> WorkspaceId)
workspaceRename = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
(<=<) X (WorkspaceId -> WindowSpace -> WorkspaceId)
f (EwmhDesktopsConfig -> X (WorkspaceId -> WindowSpace -> WorkspaceId)
workspaceRename EwmhDesktopsConfig
c) }
setEwmhWorkspaceRename :: X (String -> WindowSpace -> String) -> XConfig l -> XConfig l
setEwmhWorkspaceRename :: forall (l :: * -> *).
X (WorkspaceId -> WindowSpace -> WorkspaceId)
-> XConfig l -> XConfig l
setEwmhWorkspaceRename X (WorkspaceId -> WindowSpace -> WorkspaceId)
f = forall a (l :: * -> *).
(Default a, Typeable a) =>
(a -> a) -> XConfig l -> XConfig l
XC.modifyDef forall a b. (a -> b) -> a -> b
$ \EwmhDesktopsConfig
c -> EwmhDesktopsConfig
c{ workspaceRename :: X (WorkspaceId -> WindowSpace -> WorkspaceId)
workspaceRename = X (WorkspaceId -> WindowSpace -> WorkspaceId)
f }
setEwmhActivateHook :: ManageHook -> XConfig l -> XConfig l
setEwmhActivateHook :: forall (l :: * -> *).
Query (Endo WindowSet) -> XConfig l -> XConfig l
setEwmhActivateHook Query (Endo WindowSet)
h = forall a (l :: * -> *).
(Default a, Typeable a) =>
(a -> a) -> XConfig l -> XConfig l
XC.modifyDef forall a b. (a -> b) -> a -> b
$ \EwmhDesktopsConfig
c -> EwmhDesktopsConfig
c{ activateHook :: Query (Endo WindowSet)
activateHook = Query (Endo WindowSet)
h }
setEwmhFullscreenHooks :: ManageHook -> ManageHook -> XConfig l -> XConfig l
setEwmhFullscreenHooks :: forall (l :: * -> *).
Query (Endo WindowSet)
-> Query (Endo WindowSet) -> XConfig l -> XConfig l
setEwmhFullscreenHooks Query (Endo WindowSet)
f Query (Endo WindowSet)
uf = forall a (l :: * -> *).
(Default a, Typeable a) =>
(a -> a) -> XConfig l -> XConfig l
XC.modifyDef forall a b. (a -> b) -> a -> b
$ \EwmhDesktopsConfig
c -> EwmhDesktopsConfig
c{ fullscreenHooks :: (Query (Endo WindowSet), Query (Endo WindowSet))
fullscreenHooks = (Query (Endo WindowSet)
f, Query (Endo WindowSet)
uf) }
disableEwmhManageDesktopViewport :: XConfig l -> XConfig l
disableEwmhManageDesktopViewport :: forall (a :: * -> *). XConfig a -> XConfig a
disableEwmhManageDesktopViewport = forall a (l :: * -> *).
(Default a, Typeable a) =>
(a -> a) -> XConfig l -> XConfig l
XC.modifyDef forall a b. (a -> b) -> a -> b
$ \EwmhDesktopsConfig
c -> EwmhDesktopsConfig
c{ manageDesktopViewport :: Bool
manageDesktopViewport = Bool
False }
{-# DEPRECATED ewmhDesktopsStartup "Use ewmh instead." #-}
ewmhDesktopsStartup :: X ()
ewmhDesktopsStartup :: X ()
ewmhDesktopsStartup = X ()
setSupported
{-# DEPRECATED ewmhDesktopsLogHook "Use ewmh instead." #-}
ewmhDesktopsLogHook :: X ()
ewmhDesktopsLogHook :: X ()
ewmhDesktopsLogHook = forall (m :: * -> *) a b.
(MonadReader XConf m, Typeable a, Default a) =>
(a -> m b) -> m b
XC.withDef EwmhDesktopsConfig -> X ()
ewmhDesktopsLogHook'
{-# DEPRECATED ewmhDesktopsLogHookCustom "Use ewmh and addEwmhWorkspaceSort instead." #-}
ewmhDesktopsLogHookCustom :: WorkspaceSort -> X ()
ewmhDesktopsLogHookCustom :: WorkspaceSort -> X ()
ewmhDesktopsLogHookCustom WorkspaceSort
f =
EwmhDesktopsConfig -> X ()
ewmhDesktopsLogHook' forall a. Default a => a
def{ workspaceSort :: X WorkspaceSort
workspaceSort = (WorkspaceSort
f forall b c a. (b -> c) -> (a -> b) -> a -> c
.) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> EwmhDesktopsConfig -> X WorkspaceSort
workspaceSort forall a. Default a => a
def }
{-# DEPRECATED ewmhDesktopsEventHook "Use ewmh instead." #-}
ewmhDesktopsEventHook :: Event -> X All
ewmhDesktopsEventHook :: Event -> X All
ewmhDesktopsEventHook = forall (m :: * -> *) a b.
(MonadReader XConf m, Typeable a, Default a) =>
(a -> m b) -> m b
XC.withDef forall b c a. (b -> c) -> (a -> b) -> a -> c
. Event -> EwmhDesktopsConfig -> X All
ewmhDesktopsEventHook'
{-# DEPRECATED ewmhDesktopsEventHookCustom "Use ewmh and addEwmhWorkspaceSort instead." #-}
ewmhDesktopsEventHookCustom :: WorkspaceSort -> Event -> X All
ewmhDesktopsEventHookCustom :: WorkspaceSort -> Event -> X All
ewmhDesktopsEventHookCustom WorkspaceSort
f Event
e =
Event -> EwmhDesktopsConfig -> X All
ewmhDesktopsEventHook' Event
e forall a. Default a => a
def{ workspaceSort :: X WorkspaceSort
workspaceSort = (WorkspaceSort
f forall b c a. (b -> c) -> (a -> b) -> a -> c
.) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> EwmhDesktopsConfig -> X WorkspaceSort
workspaceSort forall a. Default a => a
def }
newtype DesktopNames = DesktopNames [String] deriving DesktopNames -> DesktopNames -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DesktopNames -> DesktopNames -> Bool
$c/= :: DesktopNames -> DesktopNames -> Bool
== :: DesktopNames -> DesktopNames -> Bool
$c== :: DesktopNames -> DesktopNames -> Bool
Eq
instance ExtensionClass DesktopNames where initialValue :: DesktopNames
initialValue = [WorkspaceId] -> DesktopNames
DesktopNames []
newtype ClientList = ClientList [Window] deriving ClientList -> ClientList -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ClientList -> ClientList -> Bool
$c/= :: ClientList -> ClientList -> Bool
== :: ClientList -> ClientList -> Bool
$c== :: ClientList -> ClientList -> Bool
Eq
instance ExtensionClass ClientList where initialValue :: ClientList
initialValue = [Atom] -> ClientList
ClientList [Atom
none]
newtype ClientListStacking = ClientListStacking [Window] deriving ClientListStacking -> ClientListStacking -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ClientListStacking -> ClientListStacking -> Bool
$c/= :: ClientListStacking -> ClientListStacking -> Bool
== :: ClientListStacking -> ClientListStacking -> Bool
$c== :: ClientListStacking -> ClientListStacking -> Bool
Eq
instance ExtensionClass ClientListStacking where initialValue :: ClientListStacking
initialValue = [Atom] -> ClientListStacking
ClientListStacking [Atom
none]
newtype CurrentDesktop = CurrentDesktop Int deriving CurrentDesktop -> CurrentDesktop -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CurrentDesktop -> CurrentDesktop -> Bool
$c/= :: CurrentDesktop -> CurrentDesktop -> Bool
== :: CurrentDesktop -> CurrentDesktop -> Bool
$c== :: CurrentDesktop -> CurrentDesktop -> Bool
Eq
instance ExtensionClass CurrentDesktop where initialValue :: CurrentDesktop
initialValue = Int -> CurrentDesktop
CurrentDesktop (forall a. Bits a => a -> a
complement Int
0)
newtype WindowDesktops = WindowDesktops (M.Map Window Int) deriving WindowDesktops -> WindowDesktops -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WindowDesktops -> WindowDesktops -> Bool
$c/= :: WindowDesktops -> WindowDesktops -> Bool
== :: WindowDesktops -> WindowDesktops -> Bool
$c== :: WindowDesktops -> WindowDesktops -> Bool
Eq
instance ExtensionClass WindowDesktops where initialValue :: WindowDesktops
initialValue = Map Atom Int -> WindowDesktops
WindowDesktops (forall k a. k -> a -> Map k a
M.singleton Atom
none (forall a. Bits a => a -> a
complement Int
0))
newtype ActiveWindow = ActiveWindow Window deriving ActiveWindow -> ActiveWindow -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActiveWindow -> ActiveWindow -> Bool
$c/= :: ActiveWindow -> ActiveWindow -> Bool
== :: ActiveWindow -> ActiveWindow -> Bool
$c== :: ActiveWindow -> ActiveWindow -> Bool
Eq
instance ExtensionClass ActiveWindow where initialValue :: ActiveWindow
initialValue = Atom -> ActiveWindow
ActiveWindow (forall a. Bits a => a -> a
complement Atom
none)
newtype MonitorTags = MonitorTags [WorkspaceId] deriving (Int -> MonitorTags -> ShowS
[MonitorTags] -> ShowS
MonitorTags -> WorkspaceId
forall a.
(Int -> a -> ShowS)
-> (a -> WorkspaceId) -> ([a] -> ShowS) -> Show a
showList :: [MonitorTags] -> ShowS
$cshowList :: [MonitorTags] -> ShowS
show :: MonitorTags -> WorkspaceId
$cshow :: MonitorTags -> WorkspaceId
showsPrec :: Int -> MonitorTags -> ShowS
$cshowsPrec :: Int -> MonitorTags -> ShowS
Show,MonitorTags -> MonitorTags -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MonitorTags -> MonitorTags -> Bool
$c/= :: MonitorTags -> MonitorTags -> Bool
== :: MonitorTags -> MonitorTags -> Bool
$c== :: MonitorTags -> MonitorTags -> Bool
Eq)
instance ExtensionClass MonitorTags where initialValue :: MonitorTags
initialValue = [WorkspaceId] -> MonitorTags
MonitorTags []
whenChanged :: (Eq a, ExtensionClass a) => a -> X () -> X ()
whenChanged :: forall a. (Eq a, ExtensionClass a) => a -> X () -> X ()
whenChanged = X Bool -> X () -> X ()
whenX forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a (m :: * -> *).
(ExtensionClass a, Eq a, XLike m) =>
(a -> a) -> m Bool
XS.modified forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. a -> b -> a
const
ewmhDesktopsLogHook' :: EwmhDesktopsConfig -> X ()
ewmhDesktopsLogHook' :: EwmhDesktopsConfig -> X ()
ewmhDesktopsLogHook' EwmhDesktopsConfig{X WorkspaceSort
workspaceSort :: X WorkspaceSort
workspaceSort :: EwmhDesktopsConfig -> X WorkspaceSort
workspaceSort, X (WorkspaceId -> WindowSpace -> WorkspaceId)
workspaceRename :: X (WorkspaceId -> WindowSpace -> WorkspaceId)
workspaceRename :: EwmhDesktopsConfig -> X (WorkspaceId -> WindowSpace -> WorkspaceId)
workspaceRename, Bool
manageDesktopViewport :: Bool
manageDesktopViewport :: EwmhDesktopsConfig -> Bool
manageDesktopViewport} = forall a. (WindowSet -> X a) -> X a
withWindowSet forall a b. (a -> b) -> a -> b
$ \WindowSet
s -> do
WorkspaceSort
sort' <- X WorkspaceSort
workspaceSort
let ws :: [WindowSpace]
ws = WorkspaceSort
sort' forall a b. (a -> b) -> a -> b
$ forall i l a s sd. StackSet i l a s sd -> [Workspace i l a]
W.workspaces WindowSet
s
WorkspaceId -> WindowSpace -> WorkspaceId
rename <- X (WorkspaceId -> WindowSpace -> WorkspaceId)
workspaceRename
let desktopNames :: [WorkspaceId]
desktopNames = [ WorkspaceId -> WindowSpace -> WorkspaceId
rename (forall i l a. Workspace i l a -> i
W.tag WindowSpace
w) WindowSpace
w | WindowSpace
w <- [WindowSpace]
ws ]
forall a. (Eq a, ExtensionClass a) => a -> X () -> X ()
whenChanged ([WorkspaceId] -> DesktopNames
DesktopNames [WorkspaceId]
desktopNames) forall a b. (a -> b) -> a -> b
$ do
forall a. Integral a => a -> X ()
setNumberOfDesktops (forall (t :: * -> *) a. Foldable t => t a -> Int
length [WorkspaceId]
desktopNames)
[WorkspaceId] -> X ()
setDesktopNames [WorkspaceId]
desktopNames
let clientList :: [Atom]
clientList = forall a. Eq a => [a] -> [a]
nub forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (forall a. Maybe (Stack a) -> [a]
W.integrate' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a. Workspace i l a -> Maybe (Stack a)
W.stack) forall a b. (a -> b) -> a -> b
$ [WindowSpace]
ws
forall a. (Eq a, ExtensionClass a) => a -> X () -> X ()
whenChanged ([Atom] -> ClientList
ClientList [Atom]
clientList) forall a b. (a -> b) -> a -> b
$ [Atom] -> X ()
setClientList [Atom]
clientList
let clientListStacking :: [Atom]
clientListStacking =
let wsInFocusOrder :: [WindowSpace]
wsInFocusOrder = forall i l a s sd. StackSet i l a s sd -> [Workspace i l a]
W.hidden WindowSet
s
forall a. [a] -> [a] -> [a]
++ (forall a b. (a -> b) -> [a] -> [b]
map forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
W.workspace forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a sid sd. StackSet i l a sid sd -> [Screen i l a sid sd]
W.visible) WindowSet
s
forall a. [a] -> [a] -> [a]
++ [forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
W.workspace forall a b. (a -> b) -> a -> b
$ forall i l a sid sd. StackSet i l a sid sd -> Screen i l a sid sd
W.current WindowSet
s]
stackWindows :: Stack a -> [a]
stackWindows (W.Stack a
cur [a]
up [a]
down) = forall a. [a] -> [a]
reverse [a]
up forall a. [a] -> [a] -> [a]
++ [a]
down forall a. [a] -> [a] -> [a]
++ [a
cur]
workspaceWindows :: Workspace i l a -> [a]
workspaceWindows = forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] forall {a}. Stack a -> [a]
stackWindows forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a. Workspace i l a -> Maybe (Stack a)
W.stack
uniqueKeepLast :: [Atom] -> [Atom]
uniqueKeepLast = forall a. [a] -> [a]
reverse forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => [a] -> [a]
nub forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [a] -> [a]
reverse
in [Atom] -> [Atom]
uniqueKeepLast forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap forall {i} {l} {a}. Workspace i l a -> [a]
workspaceWindows [WindowSpace]
wsInFocusOrder
forall a. (Eq a, ExtensionClass a) => a -> X () -> X ()
whenChanged ([Atom] -> ClientListStacking
ClientListStacking [Atom]
clientListStacking) forall a b. (a -> b) -> a -> b
$
[Atom] -> X ()
setClientListStacking [Atom]
clientListStacking
let current :: Maybe Int
current = forall i l a s sd. StackSet i l a s sd -> i
W.currentTag WindowSet
s forall a. Eq a => a -> [a] -> Maybe Int
`elemIndex` forall a b. (a -> b) -> [a] -> [b]
map forall i l a. Workspace i l a -> i
W.tag [WindowSpace]
ws
forall a. (Eq a, ExtensionClass a) => a -> X () -> X ()
whenChanged (Int -> CurrentDesktop
CurrentDesktop forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a -> a
fromMaybe Int
0 Maybe Int
current) forall a b. (a -> b) -> a -> b
$
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ forall a. Integral a => a -> X ()
setCurrentDesktop Maybe Int
current
let windowDesktops :: Map Atom Int
windowDesktops =
let f :: a -> Workspace i l k -> Map k a
f a
wsId Workspace i l k
workspace = forall k a. Ord k => [(k, a)] -> Map k a
M.fromList [ (k
winId, a
wsId) | k
winId <- forall a. Maybe (Stack a) -> [a]
W.integrate' forall a b. (a -> b) -> a -> b
$ forall i l a. Workspace i l a -> Maybe (Stack a)
W.stack Workspace i l k
workspace ]
in forall (f :: * -> *) k a.
(Foldable f, Ord k) =>
f (Map k a) -> Map k a
M.unions forall a b. (a -> b) -> a -> b
$ forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall {k} {a} {i} {l}. Ord k => a -> Workspace i l k -> Map k a
f [Int
0..] [WindowSpace]
ws
forall a. (Eq a, ExtensionClass a) => a -> X () -> X ()
whenChanged (Map Atom Int -> WindowDesktops
WindowDesktops Map Atom Int
windowDesktops) forall a b. (a -> b) -> a -> b
$
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry forall a. Integral a => Atom -> a -> X ()
setWindowDesktop) (forall k a. Map k a -> [(k, a)]
M.toList Map Atom Int
windowDesktops)
let activeWindow' :: Atom
activeWindow' = forall a. a -> Maybe a -> a
fromMaybe Atom
none (forall i l a s sd. StackSet i l a s sd -> Maybe a
W.peek WindowSet
s)
forall a. (Eq a, ExtensionClass a) => a -> X () -> X ()
whenChanged (Atom -> ActiveWindow
ActiveWindow Atom
activeWindow') forall a b. (a -> b) -> a -> b
$ Atom -> X ()
setActiveWindow Atom
activeWindow'
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
manageDesktopViewport forall a b. (a -> b) -> a -> b
$ do
let visibleScreens :: [Screen WorkspaceId (Layout Atom) Atom ScreenId ScreenDetail]
visibleScreens = forall i l a sid sd. StackSet i l a sid sd -> Screen i l a sid sd
W.current WindowSet
s forall a. a -> [a] -> [a]
: forall i l a sid sd. StackSet i l a sid sd -> [Screen i l a sid sd]
W.visible WindowSet
s
currentTags :: [WorkspaceId]
currentTags = forall a b. (a -> b) -> [a] -> [b]
map (forall i l a. Workspace i l a -> i
W.tag forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
W.workspace) [Screen WorkspaceId (Layout Atom) Atom ScreenId ScreenDetail]
visibleScreens
forall a. (Eq a, ExtensionClass a) => a -> X () -> X ()
whenChanged ([WorkspaceId] -> MonitorTags
MonitorTags [WorkspaceId]
currentTags) forall a b. (a -> b) -> a -> b
$ WindowSet -> [WorkspaceId] -> X ()
mkViewPorts WindowSet
s (forall a b. (a -> b) -> [a] -> [b]
map forall i l a. Workspace i l a -> i
W.tag [WindowSpace]
ws)
mkViewPorts :: WindowSet -> [WorkspaceId] -> X ()
mkViewPorts :: WindowSet -> [WorkspaceId] -> X ()
mkViewPorts WindowSet
winset = [Position] -> X ()
setDesktopViewport forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (Map WorkspaceId [Position]
viewPorts forall k a. Ord k => Map k a -> k -> Maybe a
M.!?)
where
foc :: Screen WorkspaceId (Layout Atom) Atom ScreenId ScreenDetail
foc = forall i l a sid sd. StackSet i l a sid sd -> Screen i l a sid sd
W.current WindowSet
winset
viewPorts :: M.Map WorkspaceId [Position]
viewPorts :: Map WorkspaceId [Position]
viewPorts = forall k a. Ord k => [(k, a)] -> Map k a
M.fromList forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map Screen WorkspaceId (Layout Atom) Atom ScreenId ScreenDetail
-> (WorkspaceId, [Position])
mkVisibleViewPort (Screen WorkspaceId (Layout Atom) Atom ScreenId ScreenDetail
foc forall a. a -> [a] -> [a]
: forall i l a sid sd. StackSet i l a sid sd -> [Screen i l a sid sd]
W.visible WindowSet
winset)
forall a. [a] -> [a] -> [a]
++ forall a b. (a -> b) -> [a] -> [b]
map (Screen WorkspaceId (Layout Atom) Atom ScreenId ScreenDetail
-> WindowSpace -> (WorkspaceId, [Position])
mkViewPort Screen WorkspaceId (Layout Atom) Atom ScreenId ScreenDetail
foc) (forall i l a s sd. StackSet i l a s sd -> [Workspace i l a]
W.hidden WindowSet
winset)
mkViewPort :: WindowScreen -> WindowSpace -> (WorkspaceId, [Position])
mkViewPort :: Screen WorkspaceId (Layout Atom) Atom ScreenId ScreenDetail
-> WindowSpace -> (WorkspaceId, [Position])
mkViewPort Screen WorkspaceId (Layout Atom) Atom ScreenId ScreenDetail
scr WindowSpace
w = (forall i l a. Workspace i l a -> i
W.tag WindowSpace
w, Screen WorkspaceId (Layout Atom) Atom ScreenId ScreenDetail
-> [Position]
mkPos Screen WorkspaceId (Layout Atom) Atom ScreenId ScreenDetail
scr)
mkVisibleViewPort :: WindowScreen -> (WorkspaceId, [Position])
mkVisibleViewPort :: Screen WorkspaceId (Layout Atom) Atom ScreenId ScreenDetail
-> (WorkspaceId, [Position])
mkVisibleViewPort Screen WorkspaceId (Layout Atom) Atom ScreenId ScreenDetail
x = Screen WorkspaceId (Layout Atom) Atom ScreenId ScreenDetail
-> WindowSpace -> (WorkspaceId, [Position])
mkViewPort Screen WorkspaceId (Layout Atom) Atom ScreenId ScreenDetail
x (forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
W.workspace Screen WorkspaceId (Layout Atom) Atom ScreenId ScreenDetail
x)
mkPos :: WindowScreen -> [Position]
mkPos :: Screen WorkspaceId (Layout Atom) Atom ScreenId ScreenDetail
-> [Position]
mkPos Screen WorkspaceId (Layout Atom) Atom ScreenId ScreenDetail
scr = [Rectangle -> Position
rect_x (forall {i} {l} {a} {sid}.
Screen i l a sid ScreenDetail -> Rectangle
rect Screen WorkspaceId (Layout Atom) Atom ScreenId ScreenDetail
scr), Rectangle -> Position
rect_y (forall {i} {l} {a} {sid}.
Screen i l a sid ScreenDetail -> Rectangle
rect Screen WorkspaceId (Layout Atom) Atom ScreenId ScreenDetail
scr)]
where rect :: Screen i l a sid ScreenDetail -> Rectangle
rect = ScreenDetail -> Rectangle
screenRect forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a sid sd. Screen i l a sid sd -> sd
W.screenDetail
ewmhDesktopsEventHook' :: Event -> EwmhDesktopsConfig -> X All
ewmhDesktopsEventHook' :: Event -> EwmhDesktopsConfig -> X All
ewmhDesktopsEventHook'
ClientMessageEvent{ev_window :: Event -> Atom
ev_window = Atom
w, ev_message_type :: Event -> Atom
ev_message_type = Atom
mt, ev_data :: Event -> [CInt]
ev_data = [CInt]
d}
EwmhDesktopsConfig{X WorkspaceSort
workspaceSort :: X WorkspaceSort
workspaceSort :: EwmhDesktopsConfig -> X WorkspaceSort
workspaceSort, Query (Endo WindowSet)
activateHook :: Query (Endo WindowSet)
activateHook :: EwmhDesktopsConfig -> Query (Endo WindowSet)
activateHook} =
forall a. (WindowSet -> X a) -> X a
withWindowSet forall a b. (a -> b) -> a -> b
$ \WindowSet
s -> do
WorkspaceSort
sort' <- X WorkspaceSort
workspaceSort
let ws :: [WindowSpace]
ws = WorkspaceSort
sort' forall a b. (a -> b) -> a -> b
$ forall i l a s sd. StackSet i l a s sd -> [Workspace i l a]
W.workspaces WindowSet
s
Atom
a_cd <- WorkspaceId -> X Atom
getAtom WorkspaceId
"_NET_CURRENT_DESKTOP"
Atom
a_d <- WorkspaceId -> X Atom
getAtom WorkspaceId
"_NET_WM_DESKTOP"
Atom
a_aw <- WorkspaceId -> X Atom
getAtom WorkspaceId
"_NET_ACTIVE_WINDOW"
Atom
a_cw <- WorkspaceId -> X Atom
getAtom WorkspaceId
"_NET_CLOSE_WINDOW"
if | Atom
mt forall a. Eq a => a -> a -> Bool
== Atom
a_cd, CInt
n : [CInt]
_ <- [CInt]
d, Just WindowSpace
ww <- [WindowSpace]
ws forall a. [a] -> Int -> Maybe a
!? forall a b. (Integral a, Num b) => a -> b
fi CInt
n ->
if forall i l a s sd. StackSet i l a s sd -> i
W.currentTag WindowSet
s forall a. Eq a => a -> a -> Bool
== forall i l a. Workspace i l a -> i
W.tag WindowSpace
ww then forall a. Monoid a => a
mempty else (WindowSet -> WindowSet) -> X ()
windows forall a b. (a -> b) -> a -> b
$ forall s i l a sd.
(Eq s, Eq i) =>
i -> StackSet i l a s sd -> StackSet i l a s sd
W.view (forall i l a. Workspace i l a -> i
W.tag WindowSpace
ww)
| Atom
mt forall a. Eq a => a -> a -> Bool
== Atom
a_cd ->
forall (m :: * -> *). MonadIO m => WorkspaceId -> m ()
trace forall a b. (a -> b) -> a -> b
$ WorkspaceId
"Bad _NET_CURRENT_DESKTOP with data=" forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> WorkspaceId
show [CInt]
d
| Atom
mt forall a. Eq a => a -> a -> Bool
== Atom
a_d, CInt
n : [CInt]
_ <- [CInt]
d, Just WindowSpace
ww <- [WindowSpace]
ws forall a. [a] -> Int -> Maybe a
!? forall a b. (Integral a, Num b) => a -> b
fi CInt
n ->
if forall a i l s sd. Eq a => a -> StackSet i l a s sd -> Maybe i
W.findTag Atom
w WindowSet
s forall a. Eq a => a -> a -> Bool
== forall a. a -> Maybe a
Just (forall i l a. Workspace i l a -> i
W.tag WindowSpace
ww) then forall a. Monoid a => a
mempty else (WindowSet -> WindowSet) -> X ()
windows forall a b. (a -> b) -> a -> b
$ forall a s i l sd.
(Ord a, Eq s, Eq i) =>
i -> a -> StackSet i l a s sd -> StackSet i l a s sd
W.shiftWin (forall i l a. Workspace i l a -> i
W.tag WindowSpace
ww) Atom
w
| Atom
mt forall a. Eq a => a -> a -> Bool
== Atom
a_d ->
forall (m :: * -> *). MonadIO m => WorkspaceId -> m ()
trace forall a b. (a -> b) -> a -> b
$ WorkspaceId
"Bad _NET_WM_DESKTOP with data=" forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> WorkspaceId
show [CInt]
d
| Atom
mt forall a. Eq a => a -> a -> Bool
== Atom
a_aw, CInt
2 : [CInt]
_ <- [CInt]
d ->
if forall i l a s sd. StackSet i l a s sd -> Maybe a
W.peek WindowSet
s forall a. Eq a => a -> a -> Bool
== forall a. a -> Maybe a
Just Atom
w then forall a. Monoid a => a
mempty else (WindowSet -> WindowSet) -> X ()
windows forall a b. (a -> b) -> a -> b
$ forall s a i l sd.
(Eq s, Eq a, Eq i) =>
a -> StackSet i l a s sd -> StackSet i l a s sd
W.focusWindow Atom
w
| Atom
mt forall a. Eq a => a -> a -> Bool
== Atom
a_aw -> do
if forall i l a s sd. StackSet i l a s sd -> Maybe a
W.peek WindowSet
s forall a. Eq a => a -> a -> Bool
== forall a. a -> Maybe a
Just Atom
w then forall a. Monoid a => a
mempty else (WindowSet -> WindowSet) -> X ()
windows forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Endo a -> a -> a
appEndo forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall a. Query a -> Atom -> X a
runQuery Query (Endo WindowSet)
activateHook Atom
w
| Atom
mt forall a. Eq a => a -> a -> Bool
== Atom
a_cw ->
Atom -> X ()
killWindow Atom
w
| Bool
otherwise ->
forall a. Monoid a => a
mempty
forall a. Monoid a => a
mempty
ewmhDesktopsEventHook' Event
_ EwmhDesktopsConfig
_ = forall a. Monoid a => a
mempty
ewmhDesktopsManageHook :: ManageHook
ewmhDesktopsManageHook :: Query (Endo WindowSet)
ewmhDesktopsManageHook = forall a (m :: * -> *). (Monoid a, Functor m) => m (Maybe a) -> m a
maybeToDefinite MaybeManageHook
ewmhDesktopsMaybeManageHook
ewmhDesktopsMaybeManageHook :: MaybeManageHook
ewmhDesktopsMaybeManageHook :: MaybeManageHook
ewmhDesktopsMaybeManageHook = Query (Maybe Int)
desktop forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Int -> Query (Endo WindowSet)
doShiftI
where
doShiftI :: Int -> ManageHook
doShiftI :: Int -> Query (Endo WindowSet)
doShiftI Int
d = do
WorkspaceSort
sort' <- forall a. X a -> Query a
liftX forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a b.
(MonadReader XConf m, Typeable a, Default a) =>
(a -> m b) -> m b
XC.withDef forall a b. (a -> b) -> a -> b
$ \EwmhDesktopsConfig{X WorkspaceSort
workspaceSort :: X WorkspaceSort
workspaceSort :: EwmhDesktopsConfig -> X WorkspaceSort
workspaceSort} -> X WorkspaceSort
workspaceSort
[WorkspaceId]
ws <- forall a. X a -> Query a
liftX forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map forall i l a. Workspace i l a -> i
W.tag forall b c a. (b -> c) -> (a -> b) -> a -> c
. WorkspaceSort
sort' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a s sd. StackSet i l a s sd -> [Workspace i l a]
W.workspaces forall b c a. (b -> c) -> (a -> b) -> a -> c
. XState -> WindowSet
windowset
forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. Monoid a => a
idHook WorkspaceId -> Query (Endo WindowSet)
doShift forall a b. (a -> b) -> a -> b
$ [WorkspaceId]
ws forall a. [a] -> Int -> Maybe a
!? Int
d
ewmhFullscreen :: XConfig a -> XConfig a
ewmhFullscreen :: forall (a :: * -> *). XConfig a -> XConfig a
ewmhFullscreen XConfig a
c = XConfig a
c { startupHook :: X ()
startupHook = forall (l :: * -> *). XConfig l -> X ()
startupHook XConfig a
c forall a. Semigroup a => a -> a -> a
<> X ()
fullscreenStartup
, handleEventHook :: Event -> X All
handleEventHook = forall (l :: * -> *). XConfig l -> Event -> X All
handleEventHook XConfig a
c forall a. Semigroup a => a -> a -> a
<> Event -> X All
fullscreenEventHook }
{-# DEPRECATED fullscreenStartup "Use ewmhFullscreen instead." #-}
fullscreenStartup :: X ()
fullscreenStartup :: X ()
fullscreenStartup = X ()
setFullscreenSupported
{-# DEPRECATED fullscreenEventHook "Use ewmhFullscreen instead." #-}
fullscreenEventHook :: Event -> X All
fullscreenEventHook :: Event -> X All
fullscreenEventHook = forall (m :: * -> *) a b.
(MonadReader XConf m, Typeable a, Default a) =>
(a -> m b) -> m b
XC.withDef forall b c a. (b -> c) -> (a -> b) -> a -> c
. Event -> EwmhDesktopsConfig -> X All
fullscreenEventHook'
fullscreenEventHook' :: Event -> EwmhDesktopsConfig -> X All
fullscreenEventHook' :: Event -> EwmhDesktopsConfig -> X All
fullscreenEventHook'
ClientMessageEvent{ev_event_display :: Event -> Display
ev_event_display = Display
dpy, ev_window :: Event -> Atom
ev_window = Atom
win, ev_message_type :: Event -> Atom
ev_message_type = Atom
typ, ev_data :: Event -> [CInt]
ev_data = CInt
action:[CInt]
dats}
EwmhDesktopsConfig{fullscreenHooks :: EwmhDesktopsConfig
-> (Query (Endo WindowSet), Query (Endo WindowSet))
fullscreenHooks = (Query (Endo WindowSet)
fullscreenHook, Query (Endo WindowSet)
unFullscreenHook)} = do
Bool
managed <- Atom -> X Bool
isClient Atom
win
Atom
wmstate <- WorkspaceId -> X Atom
getAtom WorkspaceId
"_NET_WM_STATE"
Atom
fullsc <- WorkspaceId -> X Atom
getAtom WorkspaceId
"_NET_WM_STATE_FULLSCREEN"
[CLong]
wstate <- forall a. a -> Maybe a -> a
fromMaybe [] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Atom -> Atom -> X (Maybe [CLong])
getProp32 Atom
wmstate Atom
win
let isFull :: Bool
isFull = forall a b. (Integral a, Num b) => a -> b
fromIntegral Atom
fullsc forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [CLong]
wstate
remove :: CInt
remove = CInt
0
add :: CInt
add = CInt
1
toggle :: CInt
toggle = CInt
2
chWstate :: ([CLong] -> [CLong]) -> m ()
chWstate [CLong] -> [CLong]
f = forall (m :: * -> *) a. MonadIO m => IO a -> m a
io forall a b. (a -> b) -> a -> b
$ Display -> Atom -> Atom -> Atom -> CInt -> [CLong] -> IO ()
changeProperty32 Display
dpy Atom
win Atom
wmstate Atom
aTOM CInt
propModeReplace ([CLong] -> [CLong]
f [CLong]
wstate)
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Bool
managed Bool -> Bool -> Bool
&& Atom
typ forall a. Eq a => a -> a -> Bool
== Atom
wmstate Bool -> Bool -> Bool
&& forall a b. (Integral a, Num b) => a -> b
fi Atom
fullsc forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [CInt]
dats) forall a b. (a -> b) -> a -> b
$ do
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Bool -> Bool
not Bool
isFull Bool -> Bool -> Bool
&& (CInt
action forall a. Eq a => a -> a -> Bool
== CInt
add Bool -> Bool -> Bool
|| CInt
action forall a. Eq a => a -> a -> Bool
== CInt
toggle)) forall a b. (a -> b) -> a -> b
$ do
forall {m :: * -> *}. MonadIO m => ([CLong] -> [CLong]) -> m ()
chWstate (forall a b. (Integral a, Num b) => a -> b
fi Atom
fullscforall a. a -> [a] -> [a]
:)
(WindowSet -> WindowSet) -> X ()
windows forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Endo a -> a -> a
appEndo forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall a. Query a -> Atom -> X a
runQuery Query (Endo WindowSet)
fullscreenHook Atom
win
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Bool
isFull Bool -> Bool -> Bool
&& (CInt
action forall a. Eq a => a -> a -> Bool
== CInt
remove Bool -> Bool -> Bool
|| CInt
action forall a. Eq a => a -> a -> Bool
== CInt
toggle)) forall a b. (a -> b) -> a -> b
$ do
forall {m :: * -> *}. MonadIO m => ([CLong] -> [CLong]) -> m ()
chWstate forall a b. (a -> b) -> a -> b
$ forall a. Eq a => a -> [a] -> [a]
delete (forall a b. (Integral a, Num b) => a -> b
fi Atom
fullsc)
(WindowSet -> WindowSet) -> X ()
windows forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Endo a -> a -> a
appEndo forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall a. Query a -> Atom -> X a
runQuery Query (Endo WindowSet)
unFullscreenHook Atom
win
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Bool -> All
All Bool
True
fullscreenEventHook' Event
_ EwmhDesktopsConfig
_ = forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Bool -> All
All Bool
True
setNumberOfDesktops :: (Integral a) => a -> X ()
setNumberOfDesktops :: forall a. Integral a => a -> X ()
setNumberOfDesktops a
n = forall a. (Display -> X a) -> X a
withDisplay forall a b. (a -> b) -> a -> b
$ \Display
dpy -> do
Atom
a <- WorkspaceId -> X Atom
getAtom WorkspaceId
"_NET_NUMBER_OF_DESKTOPS"
Atom
r <- forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks XConf -> Atom
theRoot
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io forall a b. (a -> b) -> a -> b
$ Display -> Atom -> Atom -> Atom -> CInt -> [CLong] -> IO ()
changeProperty32 Display
dpy Atom
r Atom
a Atom
cARDINAL CInt
propModeReplace [forall a b. (Integral a, Num b) => a -> b
fromIntegral a
n]
setCurrentDesktop :: (Integral a) => a -> X ()
setCurrentDesktop :: forall a. Integral a => a -> X ()
setCurrentDesktop a
i = forall a. (Display -> X a) -> X a
withDisplay forall a b. (a -> b) -> a -> b
$ \Display
dpy -> do
Atom
a <- WorkspaceId -> X Atom
getAtom WorkspaceId
"_NET_CURRENT_DESKTOP"
Atom
r <- forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks XConf -> Atom
theRoot
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io forall a b. (a -> b) -> a -> b
$ Display -> Atom -> Atom -> Atom -> CInt -> [CLong] -> IO ()
changeProperty32 Display
dpy Atom
r Atom
a Atom
cARDINAL CInt
propModeReplace [forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i]
setDesktopNames :: [String] -> X ()
setDesktopNames :: [WorkspaceId] -> X ()
setDesktopNames [WorkspaceId]
names = forall a. (Display -> X a) -> X a
withDisplay forall a b. (a -> b) -> a -> b
$ \Display
dpy -> do
Atom
r <- forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks XConf -> Atom
theRoot
Atom
a <- WorkspaceId -> X Atom
getAtom WorkspaceId
"_NET_DESKTOP_NAMES"
Atom
c <- WorkspaceId -> X Atom
getAtom WorkspaceId
"UTF8_STRING"
let names' :: [CChar]
names' = forall a b. (a -> b) -> [a] -> [b]
map forall a b. (Integral a, Num b) => a -> b
fromIntegral forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap ((forall a. [a] -> [a] -> [a]
++[Word8
0]) forall b c a. (b -> c) -> (a -> b) -> a -> c
. WorkspaceId -> [Word8]
encode) [WorkspaceId]
names
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io forall a b. (a -> b) -> a -> b
$ Display -> Atom -> Atom -> Atom -> CInt -> [CChar] -> IO ()
changeProperty8 Display
dpy Atom
r Atom
a Atom
c CInt
propModeReplace [CChar]
names'
setClientList :: [Window] -> X ()
setClientList :: [Atom] -> X ()
setClientList [Atom]
wins = forall a. (Display -> X a) -> X a
withDisplay forall a b. (a -> b) -> a -> b
$ \Display
dpy -> do
Atom
r <- forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks XConf -> Atom
theRoot
Atom
a <- WorkspaceId -> X Atom
getAtom WorkspaceId
"_NET_CLIENT_LIST"
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io forall a b. (a -> b) -> a -> b
$ Display -> Atom -> Atom -> Atom -> CInt -> [CLong] -> IO ()
changeProperty32 Display
dpy Atom
r Atom
a Atom
wINDOW CInt
propModeReplace (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (Integral a, Num b) => a -> b
fromIntegral [Atom]
wins)
setClientListStacking :: [Window] -> X ()
setClientListStacking :: [Atom] -> X ()
setClientListStacking [Atom]
wins = forall a. (Display -> X a) -> X a
withDisplay forall a b. (a -> b) -> a -> b
$ \Display
dpy -> do
Atom
r <- forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks XConf -> Atom
theRoot
Atom
a <- WorkspaceId -> X Atom
getAtom WorkspaceId
"_NET_CLIENT_LIST_STACKING"
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io forall a b. (a -> b) -> a -> b
$ Display -> Atom -> Atom -> Atom -> CInt -> [CLong] -> IO ()
changeProperty32 Display
dpy Atom
r Atom
a Atom
wINDOW CInt
propModeReplace (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (Integral a, Num b) => a -> b
fromIntegral [Atom]
wins)
setWindowDesktop :: (Integral a) => Window -> a -> X ()
setWindowDesktop :: forall a. Integral a => Atom -> a -> X ()
setWindowDesktop Atom
win a
i = forall a. (Display -> X a) -> X a
withDisplay forall a b. (a -> b) -> a -> b
$ \Display
dpy -> do
Atom
a <- WorkspaceId -> X Atom
getAtom WorkspaceId
"_NET_WM_DESKTOP"
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io forall a b. (a -> b) -> a -> b
$ Display -> Atom -> Atom -> Atom -> CInt -> [CLong] -> IO ()
changeProperty32 Display
dpy Atom
win Atom
a Atom
cARDINAL CInt
propModeReplace [forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i]
setActiveWindow :: Window -> X ()
setActiveWindow :: Atom -> X ()
setActiveWindow Atom
w = forall a. (Display -> X a) -> X a
withDisplay forall a b. (a -> b) -> a -> b
$ \Display
dpy -> do
Atom
r <- forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks XConf -> Atom
theRoot
Atom
a <- WorkspaceId -> X Atom
getAtom WorkspaceId
"_NET_ACTIVE_WINDOW"
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io forall a b. (a -> b) -> a -> b
$ Display -> Atom -> Atom -> Atom -> CInt -> [CLong] -> IO ()
changeProperty32 Display
dpy Atom
r Atom
a Atom
wINDOW CInt
propModeReplace [forall a b. (Integral a, Num b) => a -> b
fromIntegral Atom
w]
setDesktopViewport :: [Position] -> X ()
setDesktopViewport :: [Position] -> X ()
setDesktopViewport [Position]
positions = forall a. (Display -> X a) -> X a
withDisplay forall a b. (a -> b) -> a -> b
$ \Display
dpy -> do
Atom
r <- forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks XConf -> Atom
theRoot
Atom
a <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
io forall a b. (a -> b) -> a -> b
$ Display -> WorkspaceId -> Bool -> IO Atom
internAtom Display
dpy WorkspaceId
"_NET_DESKTOP_VIEWPORT" Bool
True
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io forall a b. (a -> b) -> a -> b
$ Display -> Atom -> Atom -> Atom -> CInt -> [CLong] -> IO ()
changeProperty32 Display
dpy Atom
r Atom
a Atom
cARDINAL CInt
propModeReplace (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (Integral a, Num b) => a -> b
fi [Position]
positions)
setSupported :: X ()
setSupported :: X ()
setSupported = forall a. (Display -> X a) -> X a
withDisplay forall a b. (a -> b) -> a -> b
$ \Display
dpy -> do
Atom
r <- forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks XConf -> Atom
theRoot
Atom
a <- WorkspaceId -> X Atom
getAtom WorkspaceId
"_NET_SUPPORTED"
[Atom]
supp <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM WorkspaceId -> X Atom
getAtom [WorkspaceId
"_NET_WM_STATE_HIDDEN"
,WorkspaceId
"_NET_WM_STATE_DEMANDS_ATTENTION"
,WorkspaceId
"_NET_NUMBER_OF_DESKTOPS"
,WorkspaceId
"_NET_CLIENT_LIST"
,WorkspaceId
"_NET_CLIENT_LIST_STACKING"
,WorkspaceId
"_NET_CURRENT_DESKTOP"
,WorkspaceId
"_NET_DESKTOP_NAMES"
,WorkspaceId
"_NET_ACTIVE_WINDOW"
,WorkspaceId
"_NET_WM_DESKTOP"
,WorkspaceId
"_NET_WM_STRUT"
,WorkspaceId
"_NET_WM_STRUT_PARTIAL"
,WorkspaceId
"_NET_DESKTOP_VIEWPORT"
]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io forall a b. (a -> b) -> a -> b
$ Display -> Atom -> Atom -> Atom -> CInt -> [CLong] -> IO ()
changeProperty32 Display
dpy Atom
r Atom
a Atom
aTOM CInt
propModeReplace (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (Integral a, Num b) => a -> b
fromIntegral [Atom]
supp)
WorkspaceId -> X ()
setWMName WorkspaceId
"xmonad"
addSupported :: [String] -> X ()
addSupported :: [WorkspaceId] -> X ()
addSupported [WorkspaceId]
props = forall a. (Display -> X a) -> X a
withDisplay forall a b. (a -> b) -> a -> b
$ \Display
dpy -> do
Atom
r <- forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks XConf -> Atom
theRoot
Atom
a <- WorkspaceId -> X Atom
getAtom WorkspaceId
"_NET_SUPPORTED"
[CLong]
newSupportedList <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (Integral a, Num b) => a -> b
fromIntegral forall b c a. (b -> c) -> (a -> b) -> a -> c
. WorkspaceId -> X Atom
getAtom) [WorkspaceId]
props
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io forall a b. (a -> b) -> a -> b
$ do
[CLong]
supportedList <- forall (m :: * -> *) a. Monad m => m (m a) -> m a
join forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Maybe a -> [a]
maybeToList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Display -> Atom -> Atom -> IO (Maybe [CLong])
getWindowProperty32 Display
dpy Atom
a Atom
r
Display -> Atom -> Atom -> Atom -> CInt -> [CLong] -> IO ()
changeProperty32 Display
dpy Atom
r Atom
a Atom
aTOM CInt
propModeReplace (forall a. Eq a => [a] -> [a]
nub forall a b. (a -> b) -> a -> b
$ [CLong]
newSupportedList forall a. [a] -> [a] -> [a]
++ [CLong]
supportedList)
setFullscreenSupported :: X ()
setFullscreenSupported :: X ()
setFullscreenSupported = [WorkspaceId] -> X ()
addSupported [WorkspaceId
"_NET_WM_STATE", WorkspaceId
"_NET_WM_STATE_FULLSCREEN"]