{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE PatternGuards #-}
module XMonad.Hooks.EwmhDesktops (
ewmh,
ewmhFullscreen,
addEwmhWorkspaceSort, setEwmhWorkspaceSort,
addEwmhWorkspaceRename, setEwmhWorkspaceRename,
setEwmhActivateHook,
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 :: XConfig a -> XConfig a
ewmh XConfig a
c = XConfig a
c { startupHook :: X ()
startupHook = X ()
ewmhDesktopsStartup X () -> X () -> X ()
forall m. Monoid m => m -> m -> m
<+> XConfig a -> X ()
forall (l :: * -> *). XConfig l -> X ()
startupHook XConfig a
c
, handleEventHook :: Event -> X All
handleEventHook = Event -> X All
ewmhDesktopsEventHook (Event -> X All) -> (Event -> X All) -> Event -> X All
forall m. Monoid m => m -> m -> m
<+> XConfig a -> Event -> X All
forall (l :: * -> *). XConfig l -> Event -> X All
handleEventHook XConfig a
c
, logHook :: X ()
logHook = X ()
ewmhDesktopsLogHook X () -> X () -> X ()
forall m. Monoid m => m -> m -> m
<+> XConfig a -> X ()
forall (l :: * -> *). XConfig l -> X ()
logHook XConfig a
c }
data EwmhDesktopsConfig =
EwmhDesktopsConfig
{ EwmhDesktopsConfig -> X WorkspaceSort
workspaceSort :: X WorkspaceSort
, EwmhDesktopsConfig -> X (String -> WindowSpace -> String)
workspaceRename :: X (String -> WindowSpace -> String)
, EwmhDesktopsConfig -> ManageHook
activateHook :: ManageHook
}
instance Default EwmhDesktopsConfig where
def :: EwmhDesktopsConfig
def = EwmhDesktopsConfig :: X WorkspaceSort
-> X (String -> WindowSpace -> String)
-> ManageHook
-> EwmhDesktopsConfig
EwmhDesktopsConfig
{ workspaceSort :: X WorkspaceSort
workspaceSort = X WorkspaceSort
getSortByIndex
, workspaceRename :: X (String -> WindowSpace -> String)
workspaceRename = (String -> WindowSpace -> String)
-> X (String -> WindowSpace -> String)
forall (f :: * -> *) a. Applicative f => a -> f a
pure String -> WindowSpace -> String
forall (f :: * -> *) a. Applicative f => a -> f a
pure
, activateHook :: ManageHook
activateHook = ManageHook
doFocus
}
addEwmhWorkspaceSort :: X WorkspaceSort -> XConfig l -> XConfig l
addEwmhWorkspaceSort :: X WorkspaceSort -> XConfig l -> XConfig l
addEwmhWorkspaceSort X WorkspaceSort
f = (EwmhDesktopsConfig -> EwmhDesktopsConfig)
-> XConfig l -> XConfig l
forall a (l :: * -> *).
(Default a, Typeable a) =>
(a -> a) -> XConfig l -> XConfig l
XC.modifyDef ((EwmhDesktopsConfig -> EwmhDesktopsConfig)
-> XConfig l -> XConfig l)
-> (EwmhDesktopsConfig -> EwmhDesktopsConfig)
-> XConfig l
-> XConfig l
forall a b. (a -> b) -> a -> b
$ \EwmhDesktopsConfig
c -> EwmhDesktopsConfig
c{ workspaceSort :: X WorkspaceSort
workspaceSort = (WorkspaceSort -> WorkspaceSort -> WorkspaceSort)
-> X WorkspaceSort -> X WorkspaceSort -> X WorkspaceSort
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 WorkspaceSort -> WorkspaceSort -> WorkspaceSort
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 :: X WorkspaceSort -> XConfig l -> XConfig l
setEwmhWorkspaceSort X WorkspaceSort
f = (EwmhDesktopsConfig -> EwmhDesktopsConfig)
-> XConfig l -> XConfig l
forall a (l :: * -> *).
(Default a, Typeable a) =>
(a -> a) -> XConfig l -> XConfig l
XC.modifyDef ((EwmhDesktopsConfig -> EwmhDesktopsConfig)
-> XConfig l -> XConfig l)
-> (EwmhDesktopsConfig -> EwmhDesktopsConfig)
-> XConfig l
-> XConfig l
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 :: X (String -> WindowSpace -> String) -> XConfig l -> XConfig l
addEwmhWorkspaceRename X (String -> WindowSpace -> String)
f = (EwmhDesktopsConfig -> EwmhDesktopsConfig)
-> XConfig l -> XConfig l
forall a (l :: * -> *).
(Default a, Typeable a) =>
(a -> a) -> XConfig l -> XConfig l
XC.modifyDef ((EwmhDesktopsConfig -> EwmhDesktopsConfig)
-> XConfig l -> XConfig l)
-> (EwmhDesktopsConfig -> EwmhDesktopsConfig)
-> XConfig l
-> XConfig l
forall a b. (a -> b) -> a -> b
$ \EwmhDesktopsConfig
c -> EwmhDesktopsConfig
c{ workspaceRename :: X (String -> WindowSpace -> String)
workspaceRename = ((String -> WindowSpace -> String)
-> (String -> WindowSpace -> String)
-> String
-> WindowSpace
-> String)
-> X (String -> WindowSpace -> String)
-> X (String -> WindowSpace -> String)
-> X (String -> WindowSpace -> String)
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (String -> WindowSpace -> String)
-> (String -> WindowSpace -> String)
-> String
-> WindowSpace
-> String
forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
(<=<) X (String -> WindowSpace -> String)
f (EwmhDesktopsConfig -> X (String -> WindowSpace -> String)
workspaceRename EwmhDesktopsConfig
c) }
setEwmhWorkspaceRename :: X (String -> WindowSpace -> String) -> XConfig l -> XConfig l
setEwmhWorkspaceRename :: X (String -> WindowSpace -> String) -> XConfig l -> XConfig l
setEwmhWorkspaceRename X (String -> WindowSpace -> String)
f = (EwmhDesktopsConfig -> EwmhDesktopsConfig)
-> XConfig l -> XConfig l
forall a (l :: * -> *).
(Default a, Typeable a) =>
(a -> a) -> XConfig l -> XConfig l
XC.modifyDef ((EwmhDesktopsConfig -> EwmhDesktopsConfig)
-> XConfig l -> XConfig l)
-> (EwmhDesktopsConfig -> EwmhDesktopsConfig)
-> XConfig l
-> XConfig l
forall a b. (a -> b) -> a -> b
$ \EwmhDesktopsConfig
c -> EwmhDesktopsConfig
c{ workspaceRename :: X (String -> WindowSpace -> String)
workspaceRename = X (String -> WindowSpace -> String)
f }
setEwmhActivateHook :: ManageHook -> XConfig l -> XConfig l
setEwmhActivateHook :: ManageHook -> XConfig l -> XConfig l
setEwmhActivateHook ManageHook
h = (EwmhDesktopsConfig -> EwmhDesktopsConfig)
-> XConfig l -> XConfig l
forall a (l :: * -> *).
(Default a, Typeable a) =>
(a -> a) -> XConfig l -> XConfig l
XC.modifyDef ((EwmhDesktopsConfig -> EwmhDesktopsConfig)
-> XConfig l -> XConfig l)
-> (EwmhDesktopsConfig -> EwmhDesktopsConfig)
-> XConfig l
-> XConfig l
forall a b. (a -> b) -> a -> b
$ \EwmhDesktopsConfig
c -> EwmhDesktopsConfig
c{ activateHook :: ManageHook
activateHook = ManageHook
h }
{-# DEPRECATED ewmhDesktopsStartup "Use ewmh instead." #-}
ewmhDesktopsStartup :: X ()
ewmhDesktopsStartup :: X ()
ewmhDesktopsStartup = X ()
setSupported
{-# DEPRECATED ewmhDesktopsLogHook "Use ewmh instead." #-}
ewmhDesktopsLogHook :: X ()
ewmhDesktopsLogHook :: X ()
ewmhDesktopsLogHook = (EwmhDesktopsConfig -> X ()) -> X ()
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' EwmhDesktopsConfig
forall a. Default a => a
def{ workspaceSort :: X WorkspaceSort
workspaceSort = (WorkspaceSort
f WorkspaceSort -> WorkspaceSort -> WorkspaceSort
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) (WorkspaceSort -> WorkspaceSort)
-> X WorkspaceSort -> X WorkspaceSort
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> EwmhDesktopsConfig -> X WorkspaceSort
workspaceSort EwmhDesktopsConfig
forall a. Default a => a
def }
{-# DEPRECATED ewmhDesktopsEventHook "Use ewmh instead." #-}
ewmhDesktopsEventHook :: Event -> X All
ewmhDesktopsEventHook :: Event -> X All
ewmhDesktopsEventHook = (EwmhDesktopsConfig -> X All) -> X All
forall (m :: * -> *) a b.
(MonadReader XConf m, Typeable a, Default a) =>
(a -> m b) -> m b
XC.withDef ((EwmhDesktopsConfig -> X All) -> X All)
-> (Event -> EwmhDesktopsConfig -> X All) -> Event -> X All
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 EwmhDesktopsConfig
forall a. Default a => a
def{ workspaceSort :: X WorkspaceSort
workspaceSort = (WorkspaceSort
f WorkspaceSort -> WorkspaceSort -> WorkspaceSort
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) (WorkspaceSort -> WorkspaceSort)
-> X WorkspaceSort -> X WorkspaceSort
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> EwmhDesktopsConfig -> X WorkspaceSort
workspaceSort EwmhDesktopsConfig
forall a. Default a => a
def }
newtype DesktopNames = DesktopNames [String] deriving DesktopNames -> DesktopNames -> Bool
(DesktopNames -> DesktopNames -> Bool)
-> (DesktopNames -> DesktopNames -> Bool) -> Eq DesktopNames
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 = [String] -> DesktopNames
DesktopNames []
newtype ClientList = ClientList [Window] deriving ClientList -> ClientList -> Bool
(ClientList -> ClientList -> Bool)
-> (ClientList -> ClientList -> Bool) -> Eq ClientList
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 = [Window] -> ClientList
ClientList [Window
none]
newtype ClientListStacking = ClientListStacking [Window] deriving ClientListStacking -> ClientListStacking -> Bool
(ClientListStacking -> ClientListStacking -> Bool)
-> (ClientListStacking -> ClientListStacking -> Bool)
-> Eq ClientListStacking
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 = [Window] -> ClientListStacking
ClientListStacking [Window
none]
newtype CurrentDesktop = CurrentDesktop Int deriving CurrentDesktop -> CurrentDesktop -> Bool
(CurrentDesktop -> CurrentDesktop -> Bool)
-> (CurrentDesktop -> CurrentDesktop -> Bool) -> Eq CurrentDesktop
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 (Int -> Int
forall a. Bits a => a -> a
complement Int
0)
newtype WindowDesktops = WindowDesktops (M.Map Window Int) deriving WindowDesktops -> WindowDesktops -> Bool
(WindowDesktops -> WindowDesktops -> Bool)
-> (WindowDesktops -> WindowDesktops -> Bool) -> Eq WindowDesktops
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 Window Int -> WindowDesktops
WindowDesktops (Window -> Int -> Map Window Int
forall k a. k -> a -> Map k a
M.singleton Window
none (Int -> Int
forall a. Bits a => a -> a
complement Int
0))
newtype ActiveWindow = ActiveWindow Window deriving ActiveWindow -> ActiveWindow -> Bool
(ActiveWindow -> ActiveWindow -> Bool)
-> (ActiveWindow -> ActiveWindow -> Bool) -> Eq ActiveWindow
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 = Window -> ActiveWindow
ActiveWindow (Window -> Window
forall a. Bits a => a -> a
complement Window
none)
whenChanged :: (Eq a, ExtensionClass a) => a -> X () -> X ()
whenChanged :: a -> X () -> X ()
whenChanged = X Bool -> X () -> X ()
whenX (X Bool -> X () -> X ()) -> (a -> X Bool) -> a -> X () -> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> a) -> X Bool
forall a (m :: * -> *).
(ExtensionClass a, Eq a, XLike m) =>
(a -> a) -> m Bool
XS.modified ((a -> a) -> X Bool) -> (a -> a -> a) -> a -> X Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> a -> a
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 (String -> WindowSpace -> String)
workspaceRename :: X (String -> WindowSpace -> String)
workspaceRename :: EwmhDesktopsConfig -> X (String -> WindowSpace -> String)
workspaceRename} = (WindowSet -> X ()) -> X ()
forall a. (WindowSet -> X a) -> X a
withWindowSet ((WindowSet -> X ()) -> X ()) -> (WindowSet -> X ()) -> X ()
forall a b. (a -> b) -> a -> b
$ \WindowSet
s -> do
WorkspaceSort
sort' <- X WorkspaceSort
workspaceSort
let ws :: [WindowSpace]
ws = WorkspaceSort
sort' WorkspaceSort -> WorkspaceSort
forall a b. (a -> b) -> a -> b
$ WindowSet -> [WindowSpace]
forall i l a s sd. StackSet i l a s sd -> [Workspace i l a]
W.workspaces WindowSet
s
String -> WindowSpace -> String
rename <- X (String -> WindowSpace -> String)
workspaceRename
let desktopNames :: [String]
desktopNames = [ String -> WindowSpace -> String
rename (WindowSpace -> String
forall i l a. Workspace i l a -> i
W.tag WindowSpace
w) WindowSpace
w | WindowSpace
w <- [WindowSpace]
ws ]
DesktopNames -> X () -> X ()
forall a. (Eq a, ExtensionClass a) => a -> X () -> X ()
whenChanged ([String] -> DesktopNames
DesktopNames [String]
desktopNames) (X () -> X ()) -> X () -> X ()
forall a b. (a -> b) -> a -> b
$ do
Int -> X ()
forall a. Integral a => a -> X ()
setNumberOfDesktops ([String] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [String]
desktopNames)
[String] -> X ()
setDesktopNames [String]
desktopNames
let clientList :: [Window]
clientList = [Window] -> [Window]
forall a. Eq a => [a] -> [a]
nub ([Window] -> [Window])
-> ([WindowSpace] -> [Window]) -> [WindowSpace] -> [Window]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (WindowSpace -> [Window]) -> [WindowSpace] -> [Window]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (Maybe (Stack Window) -> [Window]
forall a. Maybe (Stack a) -> [a]
W.integrate' (Maybe (Stack Window) -> [Window])
-> (WindowSpace -> Maybe (Stack Window)) -> WindowSpace -> [Window]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WindowSpace -> Maybe (Stack Window)
forall i l a. Workspace i l a -> Maybe (Stack a)
W.stack) ([WindowSpace] -> [Window]) -> [WindowSpace] -> [Window]
forall a b. (a -> b) -> a -> b
$ [WindowSpace]
ws
ClientList -> X () -> X ()
forall a. (Eq a, ExtensionClass a) => a -> X () -> X ()
whenChanged ([Window] -> ClientList
ClientList [Window]
clientList) (X () -> X ()) -> X () -> X ()
forall a b. (a -> b) -> a -> b
$ [Window] -> X ()
setClientList [Window]
clientList
let clientListStacking :: [Window]
clientListStacking = [Window] -> [Window]
forall a. Eq a => [a] -> [a]
nub ([Window] -> [Window])
-> ([WindowSpace] -> [Window]) -> [WindowSpace] -> [Window]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (WindowSpace -> [Window]) -> [WindowSpace] -> [Window]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap ([Window]
-> (Stack Window -> [Window]) -> Maybe (Stack Window) -> [Window]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\(W.Stack Window
x [Window]
l [Window]
r) -> [Window] -> [Window]
forall a. [a] -> [a]
reverse [Window]
l [Window] -> [Window] -> [Window]
forall a. [a] -> [a] -> [a]
++ [Window]
r [Window] -> [Window] -> [Window]
forall a. [a] -> [a] -> [a]
++ [Window
x]) (Maybe (Stack Window) -> [Window])
-> (WindowSpace -> Maybe (Stack Window)) -> WindowSpace -> [Window]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WindowSpace -> Maybe (Stack Window)
forall i l a. Workspace i l a -> Maybe (Stack a)
W.stack) ([WindowSpace] -> [Window]) -> [WindowSpace] -> [Window]
forall a b. (a -> b) -> a -> b
$ [WindowSpace]
ws
ClientListStacking -> X () -> X ()
forall a. (Eq a, ExtensionClass a) => a -> X () -> X ()
whenChanged ([Window] -> ClientListStacking
ClientListStacking [Window]
clientListStacking) (X () -> X ()) -> X () -> X ()
forall a b. (a -> b) -> a -> b
$ [Window] -> X ()
setClientListStacking [Window]
clientListStacking
let current :: Maybe Int
current = WindowSet -> String
forall i l a s sd. StackSet i l a s sd -> i
W.currentTag WindowSet
s String -> [String] -> Maybe Int
forall a. Eq a => a -> [a] -> Maybe Int
`elemIndex` (WindowSpace -> String) -> [WindowSpace] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map WindowSpace -> String
forall i l a. Workspace i l a -> i
W.tag [WindowSpace]
ws
CurrentDesktop -> X () -> X ()
forall a. (Eq a, ExtensionClass a) => a -> X () -> X ()
whenChanged (Int -> CurrentDesktop
CurrentDesktop (Int -> CurrentDesktop) -> Int -> CurrentDesktop
forall a b. (a -> b) -> a -> b
$ Int -> Maybe Int -> Int
forall a. a -> Maybe a -> a
fromMaybe Int
0 Maybe Int
current) (X () -> X ()) -> X () -> X ()
forall a b. (a -> b) -> a -> b
$
(Int -> X ()) -> Maybe Int -> X ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Int -> X ()
forall a. Integral a => a -> X ()
setCurrentDesktop Maybe Int
current
let windowDesktops :: Map Window Int
windowDesktops =
let f :: a -> Workspace i l k -> Map k a
f a
wsId Workspace i l k
workspace = [(k, a)] -> Map k a
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList [ (k
winId, a
wsId) | k
winId <- Maybe (Stack k) -> [k]
forall a. Maybe (Stack a) -> [a]
W.integrate' (Maybe (Stack k) -> [k]) -> Maybe (Stack k) -> [k]
forall a b. (a -> b) -> a -> b
$ Workspace i l k -> Maybe (Stack k)
forall i l a. Workspace i l a -> Maybe (Stack a)
W.stack Workspace i l k
workspace ]
in [Map Window Int] -> Map Window Int
forall (f :: * -> *) k a.
(Foldable f, Ord k) =>
f (Map k a) -> Map k a
M.unions ([Map Window Int] -> Map Window Int)
-> [Map Window Int] -> Map Window Int
forall a b. (a -> b) -> a -> b
$ (Int -> WindowSpace -> Map Window Int)
-> [Int] -> [WindowSpace] -> [Map Window Int]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith Int -> WindowSpace -> Map Window Int
forall k a i l. Ord k => a -> Workspace i l k -> Map k a
f [Int
0..] [WindowSpace]
ws
WindowDesktops -> X () -> X ()
forall a. (Eq a, ExtensionClass a) => a -> X () -> X ()
whenChanged (Map Window Int -> WindowDesktops
WindowDesktops Map Window Int
windowDesktops) (X () -> X ()) -> X () -> X ()
forall a b. (a -> b) -> a -> b
$
((Window, Int) -> X ()) -> [(Window, Int)] -> X ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ((Window -> Int -> X ()) -> (Window, Int) -> X ()
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Window -> Int -> X ()
forall a. Integral a => Window -> a -> X ()
setWindowDesktop) (Map Window Int -> [(Window, Int)]
forall k a. Map k a -> [(k, a)]
M.toList Map Window Int
windowDesktops)
let activeWindow' :: Window
activeWindow' = Window -> Maybe Window -> Window
forall a. a -> Maybe a -> a
fromMaybe Window
none (WindowSet -> Maybe Window
forall i l a s sd. StackSet i l a s sd -> Maybe a
W.peek WindowSet
s)
ActiveWindow -> X () -> X ()
forall a. (Eq a, ExtensionClass a) => a -> X () -> X ()
whenChanged (Window -> ActiveWindow
ActiveWindow Window
activeWindow') (X () -> X ()) -> X () -> X ()
forall a b. (a -> b) -> a -> b
$ Window -> X ()
setActiveWindow Window
activeWindow'
ewmhDesktopsEventHook' :: Event -> EwmhDesktopsConfig -> X All
ewmhDesktopsEventHook' :: Event -> EwmhDesktopsConfig -> X All
ewmhDesktopsEventHook'
ClientMessageEvent{ev_window :: Event -> Window
ev_window = Window
w, ev_message_type :: Event -> Window
ev_message_type = Window
mt, ev_data :: Event -> [CInt]
ev_data = [CInt]
d}
EwmhDesktopsConfig{X WorkspaceSort
workspaceSort :: X WorkspaceSort
workspaceSort :: EwmhDesktopsConfig -> X WorkspaceSort
workspaceSort, ManageHook
activateHook :: ManageHook
activateHook :: EwmhDesktopsConfig -> ManageHook
activateHook} =
(WindowSet -> X All) -> X All
forall a. (WindowSet -> X a) -> X a
withWindowSet ((WindowSet -> X All) -> X All) -> (WindowSet -> X All) -> X All
forall a b. (a -> b) -> a -> b
$ \WindowSet
s -> do
WorkspaceSort
sort' <- X WorkspaceSort
workspaceSort
let ws :: [WindowSpace]
ws = WorkspaceSort
sort' WorkspaceSort -> WorkspaceSort
forall a b. (a -> b) -> a -> b
$ WindowSet -> [WindowSpace]
forall i l a s sd. StackSet i l a s sd -> [Workspace i l a]
W.workspaces WindowSet
s
Window
a_cd <- String -> X Window
getAtom String
"_NET_CURRENT_DESKTOP"
Window
a_d <- String -> X Window
getAtom String
"_NET_WM_DESKTOP"
Window
a_aw <- String -> X Window
getAtom String
"_NET_ACTIVE_WINDOW"
Window
a_cw <- String -> X Window
getAtom String
"_NET_CLOSE_WINDOW"
if | Window
mt Window -> Window -> Bool
forall a. Eq a => a -> a -> Bool
== Window
a_cd, CInt
n : [CInt]
_ <- [CInt]
d, Just WindowSpace
ww <- [WindowSpace]
ws [WindowSpace] -> Int -> Maybe WindowSpace
forall a. [a] -> Int -> Maybe a
!? CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fi CInt
n ->
if WindowSet -> String
forall i l a s sd. StackSet i l a s sd -> i
W.currentTag WindowSet
s String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== WindowSpace -> String
forall i l a. Workspace i l a -> i
W.tag WindowSpace
ww then X ()
forall a. Monoid a => a
mempty else (WindowSet -> WindowSet) -> X ()
windows ((WindowSet -> WindowSet) -> X ())
-> (WindowSet -> WindowSet) -> X ()
forall a b. (a -> b) -> a -> b
$ String -> WindowSet -> WindowSet
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 (WindowSpace -> String
forall i l a. Workspace i l a -> i
W.tag WindowSpace
ww)
| Window
mt Window -> Window -> Bool
forall a. Eq a => a -> a -> Bool
== Window
a_cd ->
String -> X ()
forall (m :: * -> *). MonadIO m => String -> m ()
trace (String -> X ()) -> String -> X ()
forall a b. (a -> b) -> a -> b
$ String
"Bad _NET_CURRENT_DESKTOP with data=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ [CInt] -> String
forall a. Show a => a -> String
show [CInt]
d
| Window
mt Window -> Window -> Bool
forall a. Eq a => a -> a -> Bool
== Window
a_d, CInt
n : [CInt]
_ <- [CInt]
d, Just WindowSpace
ww <- [WindowSpace]
ws [WindowSpace] -> Int -> Maybe WindowSpace
forall a. [a] -> Int -> Maybe a
!? CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fi CInt
n ->
if Window -> WindowSet -> Maybe String
forall a i l s sd. Eq a => a -> StackSet i l a s sd -> Maybe i
W.findTag Window
w WindowSet
s Maybe String -> Maybe String -> Bool
forall a. Eq a => a -> a -> Bool
== String -> Maybe String
forall a. a -> Maybe a
Just (WindowSpace -> String
forall i l a. Workspace i l a -> i
W.tag WindowSpace
ww) then X ()
forall a. Monoid a => a
mempty else (WindowSet -> WindowSet) -> X ()
windows ((WindowSet -> WindowSet) -> X ())
-> (WindowSet -> WindowSet) -> X ()
forall a b. (a -> b) -> a -> b
$ String -> Window -> WindowSet -> WindowSet
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 (WindowSpace -> String
forall i l a. Workspace i l a -> i
W.tag WindowSpace
ww) Window
w
| Window
mt Window -> Window -> Bool
forall a. Eq a => a -> a -> Bool
== Window
a_d ->
String -> X ()
forall (m :: * -> *). MonadIO m => String -> m ()
trace (String -> X ()) -> String -> X ()
forall a b. (a -> b) -> a -> b
$ String
"Bad _NET_WM_DESKTOP with data=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ [CInt] -> String
forall a. Show a => a -> String
show [CInt]
d
| Window
mt Window -> Window -> Bool
forall a. Eq a => a -> a -> Bool
== Window
a_aw, CInt
2 : [CInt]
_ <- [CInt]
d ->
if WindowSet -> Maybe Window
forall i l a s sd. StackSet i l a s sd -> Maybe a
W.peek WindowSet
s Maybe Window -> Maybe Window -> Bool
forall a. Eq a => a -> a -> Bool
== Window -> Maybe Window
forall a. a -> Maybe a
Just Window
w then X ()
forall a. Monoid a => a
mempty else (WindowSet -> WindowSet) -> X ()
windows ((WindowSet -> WindowSet) -> X ())
-> (WindowSet -> WindowSet) -> X ()
forall a b. (a -> b) -> a -> b
$ Window -> WindowSet -> WindowSet
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 Window
w
| Window
mt Window -> Window -> Bool
forall a. Eq a => a -> a -> Bool
== Window
a_aw -> do
if WindowSet -> Maybe Window
forall i l a s sd. StackSet i l a s sd -> Maybe a
W.peek WindowSet
s Maybe Window -> Maybe Window -> Bool
forall a. Eq a => a -> a -> Bool
== Window -> Maybe Window
forall a. a -> Maybe a
Just Window
w then X ()
forall a. Monoid a => a
mempty else (WindowSet -> WindowSet) -> X ()
windows ((WindowSet -> WindowSet) -> X ())
-> (Endo WindowSet -> WindowSet -> WindowSet)
-> Endo WindowSet
-> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Endo WindowSet -> WindowSet -> WindowSet
forall a. Endo a -> a -> a
appEndo (Endo WindowSet -> X ()) -> X (Endo WindowSet) -> X ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< ManageHook -> Window -> X (Endo WindowSet)
forall a. Query a -> Window -> X a
runQuery ManageHook
activateHook Window
w
| Window
mt Window -> Window -> Bool
forall a. Eq a => a -> a -> Bool
== Window
a_cw ->
Window -> X ()
killWindow Window
w
| Bool
otherwise ->
X ()
forall a. Monoid a => a
mempty
X All
forall a. Monoid a => a
mempty
ewmhDesktopsEventHook' Event
_ EwmhDesktopsConfig
_ = X All
forall a. Monoid a => a
mempty
ewmhFullscreen :: XConfig a -> XConfig a
ewmhFullscreen :: XConfig a -> XConfig a
ewmhFullscreen XConfig a
c = XConfig a
c { startupHook :: X ()
startupHook = XConfig a -> X ()
forall (l :: * -> *). XConfig l -> X ()
startupHook XConfig a
c X () -> X () -> X ()
forall m. Monoid m => m -> m -> m
<+> X ()
fullscreenStartup
, handleEventHook :: Event -> X All
handleEventHook = XConfig a -> Event -> X All
forall (l :: * -> *). XConfig l -> Event -> X All
handleEventHook XConfig a
c (Event -> X All) -> (Event -> X All) -> Event -> X All
forall m. Monoid m => m -> m -> m
<+> 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 (ClientMessageEvent EventType
_ CULong
_ Bool
_ Display
dpy Window
win Window
typ (CInt
action:[CInt]
dats)) = do
Bool
managed <- Window -> X Bool
isClient Window
win
Window
wmstate <- String -> X Window
getAtom String
"_NET_WM_STATE"
Window
fullsc <- String -> X Window
getAtom String
"_NET_WM_STATE_FULLSCREEN"
[CLong]
wstate <- [CLong] -> Maybe [CLong] -> [CLong]
forall a. a -> Maybe a -> a
fromMaybe [] (Maybe [CLong] -> [CLong]) -> X (Maybe [CLong]) -> X [CLong]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Window -> Window -> X (Maybe [CLong])
getProp32 Window
wmstate Window
win
let isFull :: Bool
isFull = Window -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Window
fullsc CLong -> [CLong] -> Bool
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 = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Display -> Window -> Window -> Window -> CInt -> [CLong] -> IO ()
changeProperty32 Display
dpy Window
win Window
wmstate Window
aTOM CInt
propModeReplace ([CLong] -> [CLong]
f [CLong]
wstate)
Bool -> X () -> X ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Bool
managed Bool -> Bool -> Bool
&& Window
typ Window -> Window -> Bool
forall a. Eq a => a -> a -> Bool
== Window
wmstate Bool -> Bool -> Bool
&& Window -> CInt
forall a b. (Integral a, Num b) => a -> b
fi Window
fullsc CInt -> [CInt] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [CInt]
dats) (X () -> X ()) -> X () -> X ()
forall a b. (a -> b) -> a -> b
$ do
Bool -> X () -> X ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (CInt
action CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
== CInt
add Bool -> Bool -> Bool
|| (CInt
action CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
== CInt
toggle Bool -> Bool -> Bool
&& Bool -> Bool
not Bool
isFull)) (X () -> X ()) -> X () -> X ()
forall a b. (a -> b) -> a -> b
$ do
([CLong] -> [CLong]) -> X ()
forall (m :: * -> *). MonadIO m => ([CLong] -> [CLong]) -> m ()
chWstate (Window -> CLong
forall a b. (Integral a, Num b) => a -> b
fi Window
fullscCLong -> [CLong] -> [CLong]
forall a. a -> [a] -> [a]
:)
(WindowSet -> WindowSet) -> X ()
windows ((WindowSet -> WindowSet) -> X ())
-> (WindowSet -> WindowSet) -> X ()
forall a b. (a -> b) -> a -> b
$ Window -> RationalRect -> WindowSet -> WindowSet
forall a i l s sd.
Ord a =>
a -> RationalRect -> StackSet i l a s sd -> StackSet i l a s sd
W.float Window
win (RationalRect -> WindowSet -> WindowSet)
-> RationalRect -> WindowSet -> WindowSet
forall a b. (a -> b) -> a -> b
$ Rational -> Rational -> Rational -> Rational -> RationalRect
W.RationalRect Rational
0 Rational
0 Rational
1 Rational
1
Bool -> X () -> X ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (CInt
action CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
== CInt
remove Bool -> Bool -> Bool
|| (CInt
action CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
== CInt
toggle Bool -> Bool -> Bool
&& Bool
isFull)) (X () -> X ()) -> X () -> X ()
forall a b. (a -> b) -> a -> b
$ do
([CLong] -> [CLong]) -> X ()
forall (m :: * -> *). MonadIO m => ([CLong] -> [CLong]) -> m ()
chWstate (([CLong] -> [CLong]) -> X ()) -> ([CLong] -> [CLong]) -> X ()
forall a b. (a -> b) -> a -> b
$ CLong -> [CLong] -> [CLong]
forall a. Eq a => a -> [a] -> [a]
delete (Window -> CLong
forall a b. (Integral a, Num b) => a -> b
fi Window
fullsc)
(WindowSet -> WindowSet) -> X ()
windows ((WindowSet -> WindowSet) -> X ())
-> (WindowSet -> WindowSet) -> X ()
forall a b. (a -> b) -> a -> b
$ Window -> WindowSet -> WindowSet
forall a i l s sd.
Ord a =>
a -> StackSet i l a s sd -> StackSet i l a s sd
W.sink Window
win
All -> X All
forall (m :: * -> *) a. Monad m => a -> m a
return (All -> X All) -> All -> X All
forall a b. (a -> b) -> a -> b
$ Bool -> All
All Bool
True
fullscreenEventHook Event
_ = All -> X All
forall (m :: * -> *) a. Monad m => a -> m a
return (All -> X All) -> All -> X All
forall a b. (a -> b) -> a -> b
$ Bool -> All
All Bool
True
setNumberOfDesktops :: (Integral a) => a -> X ()
setNumberOfDesktops :: a -> X ()
setNumberOfDesktops a
n = (Display -> X ()) -> X ()
forall a. (Display -> X a) -> X a
withDisplay ((Display -> X ()) -> X ()) -> (Display -> X ()) -> X ()
forall a b. (a -> b) -> a -> b
$ \Display
dpy -> do
Window
a <- String -> X Window
getAtom String
"_NET_NUMBER_OF_DESKTOPS"
Window
r <- (XConf -> Window) -> X Window
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks XConf -> Window
theRoot
IO () -> X ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO () -> X ()) -> IO () -> X ()
forall a b. (a -> b) -> a -> b
$ Display -> Window -> Window -> Window -> CInt -> [CLong] -> IO ()
changeProperty32 Display
dpy Window
r Window
a Window
cARDINAL CInt
propModeReplace [a -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
n]
setCurrentDesktop :: (Integral a) => a -> X ()
setCurrentDesktop :: a -> X ()
setCurrentDesktop a
i = (Display -> X ()) -> X ()
forall a. (Display -> X a) -> X a
withDisplay ((Display -> X ()) -> X ()) -> (Display -> X ()) -> X ()
forall a b. (a -> b) -> a -> b
$ \Display
dpy -> do
Window
a <- String -> X Window
getAtom String
"_NET_CURRENT_DESKTOP"
Window
r <- (XConf -> Window) -> X Window
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks XConf -> Window
theRoot
IO () -> X ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO () -> X ()) -> IO () -> X ()
forall a b. (a -> b) -> a -> b
$ Display -> Window -> Window -> Window -> CInt -> [CLong] -> IO ()
changeProperty32 Display
dpy Window
r Window
a Window
cARDINAL CInt
propModeReplace [a -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i]
setDesktopNames :: [String] -> X ()
setDesktopNames :: [String] -> X ()
setDesktopNames [String]
names = (Display -> X ()) -> X ()
forall a. (Display -> X a) -> X a
withDisplay ((Display -> X ()) -> X ()) -> (Display -> X ()) -> X ()
forall a b. (a -> b) -> a -> b
$ \Display
dpy -> do
Window
r <- (XConf -> Window) -> X Window
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks XConf -> Window
theRoot
Window
a <- String -> X Window
getAtom String
"_NET_DESKTOP_NAMES"
Window
c <- String -> X Window
getAtom String
"UTF8_STRING"
let names' :: [CChar]
names' = (Word8 -> CChar) -> [Word8] -> [CChar]
forall a b. (a -> b) -> [a] -> [b]
map Word8 -> CChar
forall a b. (Integral a, Num b) => a -> b
fromIntegral ([Word8] -> [CChar]) -> [Word8] -> [CChar]
forall a b. (a -> b) -> a -> b
$ (String -> [Word8]) -> [String] -> [Word8]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (([Word8] -> [Word8] -> [Word8]
forall a. [a] -> [a] -> [a]
++[Word8
0]) ([Word8] -> [Word8]) -> (String -> [Word8]) -> String -> [Word8]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> [Word8]
encode) [String]
names
IO () -> X ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO () -> X ()) -> IO () -> X ()
forall a b. (a -> b) -> a -> b
$ Display -> Window -> Window -> Window -> CInt -> [CChar] -> IO ()
changeProperty8 Display
dpy Window
r Window
a Window
c CInt
propModeReplace [CChar]
names'
setClientList :: [Window] -> X ()
setClientList :: [Window] -> X ()
setClientList [Window]
wins = (Display -> X ()) -> X ()
forall a. (Display -> X a) -> X a
withDisplay ((Display -> X ()) -> X ()) -> (Display -> X ()) -> X ()
forall a b. (a -> b) -> a -> b
$ \Display
dpy -> do
Window
r <- (XConf -> Window) -> X Window
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks XConf -> Window
theRoot
Window
a <- String -> X Window
getAtom String
"_NET_CLIENT_LIST"
IO () -> X ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO () -> X ()) -> IO () -> X ()
forall a b. (a -> b) -> a -> b
$ Display -> Window -> Window -> Window -> CInt -> [CLong] -> IO ()
changeProperty32 Display
dpy Window
r Window
a Window
wINDOW CInt
propModeReplace ((Window -> CLong) -> [Window] -> [CLong]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Window -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral [Window]
wins)
setClientListStacking :: [Window] -> X ()
setClientListStacking :: [Window] -> X ()
setClientListStacking [Window]
wins = (Display -> X ()) -> X ()
forall a. (Display -> X a) -> X a
withDisplay ((Display -> X ()) -> X ()) -> (Display -> X ()) -> X ()
forall a b. (a -> b) -> a -> b
$ \Display
dpy -> do
Window
r <- (XConf -> Window) -> X Window
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks XConf -> Window
theRoot
Window
a <- String -> X Window
getAtom String
"_NET_CLIENT_LIST_STACKING"
IO () -> X ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO () -> X ()) -> IO () -> X ()
forall a b. (a -> b) -> a -> b
$ Display -> Window -> Window -> Window -> CInt -> [CLong] -> IO ()
changeProperty32 Display
dpy Window
r Window
a Window
wINDOW CInt
propModeReplace ((Window -> CLong) -> [Window] -> [CLong]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Window -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral [Window]
wins)
setWindowDesktop :: (Integral a) => Window -> a -> X ()
setWindowDesktop :: Window -> a -> X ()
setWindowDesktop Window
win a
i = (Display -> X ()) -> X ()
forall a. (Display -> X a) -> X a
withDisplay ((Display -> X ()) -> X ()) -> (Display -> X ()) -> X ()
forall a b. (a -> b) -> a -> b
$ \Display
dpy -> do
Window
a <- String -> X Window
getAtom String
"_NET_WM_DESKTOP"
IO () -> X ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO () -> X ()) -> IO () -> X ()
forall a b. (a -> b) -> a -> b
$ Display -> Window -> Window -> Window -> CInt -> [CLong] -> IO ()
changeProperty32 Display
dpy Window
win Window
a Window
cARDINAL CInt
propModeReplace [a -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i]
setActiveWindow :: Window -> X ()
setActiveWindow :: Window -> X ()
setActiveWindow Window
w = (Display -> X ()) -> X ()
forall a. (Display -> X a) -> X a
withDisplay ((Display -> X ()) -> X ()) -> (Display -> X ()) -> X ()
forall a b. (a -> b) -> a -> b
$ \Display
dpy -> do
Window
r <- (XConf -> Window) -> X Window
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks XConf -> Window
theRoot
Window
a <- String -> X Window
getAtom String
"_NET_ACTIVE_WINDOW"
IO () -> X ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO () -> X ()) -> IO () -> X ()
forall a b. (a -> b) -> a -> b
$ Display -> Window -> Window -> Window -> CInt -> [CLong] -> IO ()
changeProperty32 Display
dpy Window
r Window
a Window
wINDOW CInt
propModeReplace [Window -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Window
w]
setSupported :: X ()
setSupported :: X ()
setSupported = (Display -> X ()) -> X ()
forall a. (Display -> X a) -> X a
withDisplay ((Display -> X ()) -> X ()) -> (Display -> X ()) -> X ()
forall a b. (a -> b) -> a -> b
$ \Display
dpy -> do
Window
r <- (XConf -> Window) -> X Window
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks XConf -> Window
theRoot
Window
a <- String -> X Window
getAtom String
"_NET_SUPPORTED"
[Window]
supp <- (String -> X Window) -> [String] -> X [Window]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM String -> X Window
getAtom [String
"_NET_WM_STATE_HIDDEN"
,String
"_NET_WM_STATE_DEMANDS_ATTENTION"
,String
"_NET_NUMBER_OF_DESKTOPS"
,String
"_NET_CLIENT_LIST"
,String
"_NET_CLIENT_LIST_STACKING"
,String
"_NET_CURRENT_DESKTOP"
,String
"_NET_DESKTOP_NAMES"
,String
"_NET_ACTIVE_WINDOW"
,String
"_NET_WM_DESKTOP"
,String
"_NET_WM_STRUT"
]
IO () -> X ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO () -> X ()) -> IO () -> X ()
forall a b. (a -> b) -> a -> b
$ Display -> Window -> Window -> Window -> CInt -> [CLong] -> IO ()
changeProperty32 Display
dpy Window
r Window
a Window
aTOM CInt
propModeReplace ((Window -> CLong) -> [Window] -> [CLong]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Window -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral [Window]
supp)
String -> X ()
setWMName String
"xmonad"
addSupported :: [String] -> X ()
addSupported :: [String] -> X ()
addSupported [String]
props = (Display -> X ()) -> X ()
forall a. (Display -> X a) -> X a
withDisplay ((Display -> X ()) -> X ()) -> (Display -> X ()) -> X ()
forall a b. (a -> b) -> a -> b
$ \Display
dpy -> do
Window
r <- (XConf -> Window) -> X Window
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks XConf -> Window
theRoot
Window
a <- String -> X Window
getAtom String
"_NET_SUPPORTED"
[CLong]
newSupportedList <- (String -> X CLong) -> [String] -> X [CLong]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((Window -> CLong) -> X Window -> X CLong
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Window -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral (X Window -> X CLong) -> (String -> X Window) -> String -> X CLong
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> X Window
getAtom) [String]
props
IO () -> X ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO () -> X ()) -> IO () -> X ()
forall a b. (a -> b) -> a -> b
$ do
[CLong]
supportedList <- [[CLong]] -> [CLong]
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join ([[CLong]] -> [CLong])
-> (Maybe [CLong] -> [[CLong]]) -> Maybe [CLong] -> [CLong]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe [CLong] -> [[CLong]]
forall a. Maybe a -> [a]
maybeToList (Maybe [CLong] -> [CLong]) -> IO (Maybe [CLong]) -> IO [CLong]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Display -> Window -> Window -> IO (Maybe [CLong])
getWindowProperty32 Display
dpy Window
a Window
r
Display -> Window -> Window -> Window -> CInt -> [CLong] -> IO ()
changeProperty32 Display
dpy Window
r Window
a Window
aTOM CInt
propModeReplace ([CLong] -> [CLong]
forall a. Eq a => [a] -> [a]
nub ([CLong] -> [CLong]) -> [CLong] -> [CLong]
forall a b. (a -> b) -> a -> b
$ [CLong]
newSupportedList [CLong] -> [CLong] -> [CLong]
forall a. [a] -> [a] -> [a]
++ [CLong]
supportedList)
setFullscreenSupported :: X ()
setFullscreenSupported :: X ()
setFullscreenSupported = [String] -> X ()
addSupported [String
"_NET_WM_STATE", String
"_NET_WM_STATE_FULLSCREEN"]