module XMonad.Util.DebugWindow (debugWindow) where
import Prelude
import XMonad
import XMonad.Prelude
import Codec.Binary.UTF8.String (decodeString)
import Control.Exception as E
import Foreign
import Foreign.C.String
import Numeric (showHex)
import System.Exit
debugWindow :: Window -> X String
debugWindow :: Window -> X String
debugWindow Window
0 = String -> X String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"-no window-"
debugWindow Window
w = do
let wx :: String
wx = Int -> Char -> String -> String
pad Int
8 Char
'0' (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ Window -> String -> String
forall a. (Integral a, Show a) => a -> String -> String
showHex Window
w String
""
Maybe WindowAttributes
w' <- (Display -> X (Maybe WindowAttributes))
-> X (Maybe WindowAttributes)
forall a. (Display -> X a) -> X a
withDisplay ((Display -> X (Maybe WindowAttributes))
-> X (Maybe WindowAttributes))
-> (Display -> X (Maybe WindowAttributes))
-> X (Maybe WindowAttributes)
forall a b. (a -> b) -> a -> b
$ \Display
d -> IO (Maybe WindowAttributes) -> X (Maybe WindowAttributes)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (Display -> Window -> IO (Maybe WindowAttributes)
safeGetWindowAttributes Display
d Window
w)
case Maybe WindowAttributes
w' of
Maybe WindowAttributes
Nothing ->
String -> X String
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> X String) -> String -> X String
forall a b. (a -> b) -> a -> b
$ String
"(deleted window " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
wx String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
Just WindowAttributes
{ wa_x :: WindowAttributes -> CInt
wa_x = CInt
x
, wa_y :: WindowAttributes -> CInt
wa_y = CInt
y
, wa_width :: WindowAttributes -> CInt
wa_width = CInt
wid
, wa_height :: WindowAttributes -> CInt
wa_height = CInt
ht
, wa_border_width :: WindowAttributes -> CInt
wa_border_width = CInt
bw
, wa_map_state :: WindowAttributes -> CInt
wa_map_state = CInt
m
, wa_override_redirect :: WindowAttributes -> Bool
wa_override_redirect = Bool
o
} -> do
Maybe [CChar]
c' <- (Display -> X (Maybe [CChar])) -> X (Maybe [CChar])
forall a. (Display -> X a) -> X a
withDisplay ((Display -> X (Maybe [CChar])) -> X (Maybe [CChar]))
-> (Display -> X (Maybe [CChar])) -> X (Maybe [CChar])
forall a b. (a -> b) -> a -> b
$ \Display
d ->
IO (Maybe [CChar]) -> X (Maybe [CChar])
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (Display -> Window -> Window -> IO (Maybe [CChar])
getWindowProperty8 Display
d Window
wM_CLASS Window
w)
let c :: String
c = case Maybe [CChar]
c' of
Maybe [CChar]
Nothing -> String
""
Just [CChar]
c'' -> String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
"/" ([String] -> String) -> [String] -> String
forall a b. (a -> b) -> a -> b
$
((String -> Maybe (String, String)) -> String -> [String])
-> String -> (String -> Maybe (String, String)) -> [String]
forall a b c. (a -> b -> c) -> b -> a -> c
flip (String -> Maybe (String, String)) -> String -> [String]
forall b a. (b -> Maybe (a, b)) -> b -> [a]
unfoldr ((CChar -> Char) -> [CChar] -> String
forall a b. (a -> b) -> [a] -> [b]
map (Int -> Char
forall a. Enum a => Int -> a
toEnum (Int -> Char) -> (CChar -> Int) -> CChar -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CChar -> Int
forall a. Enum a => a -> Int
fromEnum) [CChar]
c'') ((String -> Maybe (String, String)) -> [String])
-> (String -> Maybe (String, String)) -> [String]
forall a b. (a -> b) -> a -> b
$
\String
s -> if String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
s
then Maybe (String, String)
forall a. Maybe a
Nothing
else let (String
w'',String
s'') = (Char -> Bool) -> String -> (String, String)
forall a. (a -> Bool) -> [a] -> ([a], [a])
break (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'\NUL') String
s
s' :: String
s' = if String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
s''
then String
s''
else String -> String
forall a. [a] -> [a]
tail String
s''
in (String, String) -> Maybe (String, String)
forall a. a -> Maybe a
Just (String
w'',String
s')
String
t <- X String -> X String -> X String
forall a. X a -> X a -> X a
catchX' (String -> String
wrap (String -> String) -> X String -> X String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> Window -> X String
getEWMHTitle String
"VISIBLE" Window
w) (X String -> X String) -> X String -> X String
forall a b. (a -> b) -> a -> b
$
X String -> X String -> X String
forall a. X a -> X a -> X a
catchX' (String -> String
wrap (String -> String) -> X String -> X String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> Window -> X String
getEWMHTitle String
"" Window
w) (X String -> X String) -> X String -> X String
forall a b. (a -> b) -> a -> b
$
X String -> X String -> X String
forall a. X a -> X a -> X a
catchX' (String -> String
wrap (String -> String) -> X String -> X String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Window -> X String
getICCCMTitle Window
w) (X String -> X String) -> X String -> X String
forall a b. (a -> b) -> a -> b
$
String -> X String
forall (m :: * -> *) a. Monad m => a -> m a
return String
""
String
h' <- Window -> X String
getMachine Window
w
let h :: String
h = if String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
h' then String
"" else Char
'@'Char -> String -> String
forall a. a -> [a] -> [a]
:String
h'
[String]
p' <- (Display -> X [String]) -> X [String]
forall a. (Display -> X a) -> X a
withDisplay ((Display -> X [String]) -> X [String])
-> (Display -> X [String]) -> X [String]
forall a b. (a -> b) -> a -> b
$ \Display
d -> Display -> Window -> X [String]
safeGetCommand Display
d Window
w
let p :: String
p = if [String] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [String]
p' then String
"" else String -> String
wrap (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ [String] -> String
unwords [String]
p'
Window
nWP <- String -> X Window
getAtom String
"_NET_WM_PID"
Maybe [CLong]
pid' <- (Display -> X (Maybe [CLong])) -> X (Maybe [CLong])
forall a. (Display -> X a) -> X a
withDisplay ((Display -> X (Maybe [CLong])) -> X (Maybe [CLong]))
-> (Display -> X (Maybe [CLong])) -> X (Maybe [CLong])
forall a b. (a -> b) -> a -> b
$ \Display
d -> IO (Maybe [CLong]) -> X (Maybe [CLong])
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO (Maybe [CLong]) -> X (Maybe [CLong]))
-> IO (Maybe [CLong]) -> X (Maybe [CLong])
forall a b. (a -> b) -> a -> b
$ Display -> Window -> Window -> IO (Maybe [CLong])
getWindowProperty32 Display
d Window
nWP Window
w
let pid :: String
pid = case Maybe [CLong]
pid' of
Just [CLong
pid''] -> Char
'('Char -> String -> String
forall a. a -> [a] -> [a]
:CLong -> String
forall a. Show a => a -> String
show CLong
pid'' String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"
Maybe [CLong]
_ -> String
""
let cmd :: String
cmd = String
p String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
pid String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
h
let (String
lb,String
rb) = case () of
() | CInt
m CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
== CInt
waIsViewable -> (String
"",String
"")
| Bool
otherwise -> (String
"[",String
"]")
o' :: String
o' = if Bool
o then String
"!" else String
""
String -> X String
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> X String) -> String -> X String
forall a b. (a -> b) -> a -> b
$ [String] -> String
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String
lb
,String
o'
,String
wx
,String
t
,String
" "
,CInt -> String
forall a. Show a => a -> String
show CInt
wid
,Char
'x'Char -> String -> String
forall a. a -> [a] -> [a]
:CInt -> String
forall a. Show a => a -> String
show CInt
ht
,if CInt
bw CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
== CInt
0 then String
"" else Char
'+'Char -> String -> String
forall a. a -> [a] -> [a]
:CInt -> String
forall a. Show a => a -> String
show CInt
bw
,String
"@"
,CInt -> String
forall a. Show a => a -> String
show CInt
x
,Char
','Char -> String -> String
forall a. a -> [a] -> [a]
:CInt -> String
forall a. Show a => a -> String
show CInt
y
,if String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
c then String
"" else Char
' 'Char -> String -> String
forall a. a -> [a] -> [a]
:String
c
,if String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
cmd then String
"" else Char
' 'Char -> String -> String
forall a. a -> [a] -> [a]
:String
cmd
,String
rb
]
getEWMHTitle :: String -> Window -> X String
getEWMHTitle :: String -> Window -> X String
getEWMHTitle String
sub Window
w = do
Window
a <- String -> X Window
getAtom (String -> X Window) -> String -> X Window
forall a b. (a -> b) -> a -> b
$ String
"_NET_WM_" String -> String -> String
forall a. [a] -> [a] -> [a]
++ (if String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
sub then String
"" else Char
'_'Char -> String -> String
forall a. a -> [a] -> [a]
:String
sub) String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"_NAME"
(Just [CLong]
t) <- (Display -> X (Maybe [CLong])) -> X (Maybe [CLong])
forall a. (Display -> X a) -> X a
withDisplay ((Display -> X (Maybe [CLong])) -> X (Maybe [CLong]))
-> (Display -> X (Maybe [CLong])) -> X (Maybe [CLong])
forall a b. (a -> b) -> a -> b
$ \Display
d -> IO (Maybe [CLong]) -> X (Maybe [CLong])
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO (Maybe [CLong]) -> X (Maybe [CLong]))
-> IO (Maybe [CLong]) -> X (Maybe [CLong])
forall a b. (a -> b) -> a -> b
$ Display -> Window -> Window -> IO (Maybe [CLong])
getWindowProperty32 Display
d Window
a Window
w
String -> X String
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> X String) -> String -> X String
forall a b. (a -> b) -> a -> b
$ (CLong -> Char) -> [CLong] -> String
forall a b. (a -> b) -> [a] -> [b]
map (Int -> Char
forall a. Enum a => Int -> a
toEnum (Int -> Char) -> (CLong -> Int) -> CLong -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CLong -> Int
forall a. Enum a => a -> Int
fromEnum) [CLong]
t
getICCCMTitle :: Window -> X String
getICCCMTitle :: Window -> X String
getICCCMTitle Window
w = Window -> Window -> X String
getDecodedStringProp Window
w Window
wM_NAME
getDecodedStringProp :: Window -> Atom -> X String
getDecodedStringProp :: Window -> Window -> X String
getDecodedStringProp Window
w Window
a = do
t :: TextProperty
t@(TextProperty CString
t' Window
_ CInt
8 Window
_) <- (Display -> X TextProperty) -> X TextProperty
forall a. (Display -> X a) -> X a
withDisplay ((Display -> X TextProperty) -> X TextProperty)
-> (Display -> X TextProperty) -> X TextProperty
forall a b. (a -> b) -> a -> b
$ \Display
d -> IO TextProperty -> X TextProperty
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO TextProperty -> X TextProperty)
-> IO TextProperty -> X TextProperty
forall a b. (a -> b) -> a -> b
$ Display -> Window -> Window -> IO TextProperty
getTextProperty Display
d Window
w Window
a
[String
s] <- X [String] -> X [String] -> X [String]
forall a. X a -> X a -> X a
catchX' (TextProperty -> X [String]
tryUTF8 TextProperty
t) (X [String] -> X [String]) -> X [String] -> X [String]
forall a b. (a -> b) -> a -> b
$
X [String] -> X [String] -> X [String]
forall a. X a -> X a -> X a
catchX' (TextProperty -> X [String]
tryCompound TextProperty
t) (X [String] -> X [String]) -> X [String] -> X [String]
forall a b. (a -> b) -> a -> b
$
IO [String] -> X [String]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io ((String -> [String] -> [String]
forall a. a -> [a] -> [a]
:[]) (String -> [String]) -> IO String -> IO [String]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CString -> IO String
peekCString CString
t')
String -> X String
forall (m :: * -> *) a. Monad m => a -> m a
return String
s
tryUTF8 :: TextProperty -> X [String]
tryUTF8 :: TextProperty -> X [String]
tryUTF8 (TextProperty CString
s Window
enc CInt
_ Window
_) = do
Window
uTF8_STRING <- String -> X Window
getAtom String
"UTF8_STRING"
Bool -> X () -> X ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Window
enc Window -> Window -> Bool
forall a. Eq a => a -> a -> Bool
/= Window
uTF8_STRING) (X () -> X ()) -> X () -> X ()
forall a b. (a -> b) -> a -> b
$ String -> X ()
forall a. HasCallStack => String -> a
error String
"String is not UTF8_STRING"
(String -> String) -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map String -> String
decodeString ([String] -> [String])
-> (String -> [String]) -> String -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> [String]
splitNul (String -> [String]) -> X String -> X [String]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IO String -> X String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (CString -> IO String
peekCString CString
s)
tryCompound :: TextProperty -> X [String]
tryCompound :: TextProperty -> X [String]
tryCompound t :: TextProperty
t@(TextProperty CString
_ Window
enc CInt
_ Window
_) = do
Window
cOMPOUND_TEXT <- String -> X Window
getAtom String
"COMPOUND_TEXT"
Bool -> X () -> X ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Window
enc Window -> Window -> Bool
forall a. Eq a => a -> a -> Bool
/= Window
cOMPOUND_TEXT) (X () -> X ()) -> X () -> X ()
forall a b. (a -> b) -> a -> b
$ String -> X ()
forall a. HasCallStack => String -> a
error String
"String is not COMPOUND_TEXT"
(Display -> X [String]) -> X [String]
forall a. (Display -> X a) -> X a
withDisplay ((Display -> X [String]) -> X [String])
-> (Display -> X [String]) -> X [String]
forall a b. (a -> b) -> a -> b
$ \Display
d -> IO [String] -> X [String]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO [String] -> X [String]) -> IO [String] -> X [String]
forall a b. (a -> b) -> a -> b
$ Display -> TextProperty -> IO [String]
wcTextPropertyToTextList Display
d TextProperty
t
splitNul :: String -> [String]
splitNul :: String -> [String]
splitNul String
"" = []
splitNul String
s = let (String
s',String
ss') = (Char -> Bool) -> String -> (String, String)
forall a. (a -> Bool) -> [a] -> ([a], [a])
break (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'\NUL') String
s in String
s' String -> [String] -> [String]
forall a. a -> [a] -> [a]
: String -> [String]
splitNul String
ss'
pad :: Int -> Char -> String -> String
pad :: Int -> Char -> String -> String
pad Int
w Char
c String
s = Int -> Char -> String
forall a. Int -> a -> [a]
replicate (Int
w Int -> Int -> Int
forall a. Num a => a -> a -> a
- String -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length String
s) Char
c String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
s
catchX' :: X a -> X a -> X a
catchX' :: X a -> X a -> X a
catchX' X a
job X a
errcase = do
XState
st <- X XState
forall s (m :: * -> *). MonadState s m => m s
get
XConf
c <- X XConf
forall r (m :: * -> *). MonadReader r m => m r
ask
(a
a, XState
s') <- IO (a, XState) -> X (a, XState)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO (a, XState) -> X (a, XState))
-> IO (a, XState) -> X (a, XState)
forall a b. (a -> b) -> a -> b
$ XConf -> XState -> X a -> IO (a, XState)
forall a. XConf -> XState -> X a -> IO (a, XState)
runX XConf
c XState
st X a
job IO (a, XState)
-> (SomeException -> IO (a, XState)) -> IO (a, XState)
forall e a. Exception e => IO a -> (e -> IO a) -> IO a
`E.catch` \SomeException
e -> case SomeException -> Maybe ExitCode
forall e. Exception e => SomeException -> Maybe e
fromException SomeException
e of
Just ExitCode
x -> SomeException -> IO (a, XState)
forall a e. Exception e => e -> a
throw SomeException
e IO (a, XState) -> ExitCode -> IO (a, XState)
forall a b. a -> b -> a
`const` (ExitCode
x ExitCode -> ExitCode -> ExitCode
forall a. a -> a -> a
`asTypeOf` ExitCode
ExitSuccess)
Maybe ExitCode
_ -> XConf -> XState -> X a -> IO (a, XState)
forall a. XConf -> XState -> X a -> IO (a, XState)
runX XConf
c XState
st X a
errcase
XState -> X ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put XState
s'
a -> X a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a
wrap :: String -> String
wrap :: String -> String
wrap String
s = Char
' ' Char -> String -> String
forall a. a -> [a] -> [a]
: Char
'"' Char -> String -> String
forall a. a -> [a] -> [a]
: String -> String
wrap' String
s String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\""
where
wrap' :: String -> String
wrap' (Char
s':String
ss) | Char
s' Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'"' = Char
'\\' Char -> String -> String
forall a. a -> [a] -> [a]
: Char
s' Char -> String -> String
forall a. a -> [a] -> [a]
: String -> String
wrap' String
ss
| Char
s' Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'\\' = Char
'\\' Char -> String -> String
forall a. a -> [a] -> [a]
: Char
s' Char -> String -> String
forall a. a -> [a] -> [a]
: String -> String
wrap' String
ss
| Bool
otherwise = Char
s' Char -> String -> String
forall a. a -> [a] -> [a]
: String -> String
wrap' String
ss
wrap' String
"" = String
""
safeGetWindowAttributes :: Display -> Window -> IO (Maybe WindowAttributes)
safeGetWindowAttributes :: Display -> Window -> IO (Maybe WindowAttributes)
safeGetWindowAttributes Display
d Window
w = (Ptr WindowAttributes -> IO (Maybe WindowAttributes))
-> IO (Maybe WindowAttributes)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr WindowAttributes -> IO (Maybe WindowAttributes))
-> IO (Maybe WindowAttributes))
-> (Ptr WindowAttributes -> IO (Maybe WindowAttributes))
-> IO (Maybe WindowAttributes)
forall a b. (a -> b) -> a -> b
$ \Ptr WindowAttributes
p -> do
CInt
s <- Display -> Window -> Ptr WindowAttributes -> IO CInt
xGetWindowAttributes Display
d Window
w Ptr WindowAttributes
p
case CInt
s of
CInt
0 -> Maybe WindowAttributes -> IO (Maybe WindowAttributes)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe WindowAttributes
forall a. Maybe a
Nothing
CInt
_ -> WindowAttributes -> Maybe WindowAttributes
forall a. a -> Maybe a
Just (WindowAttributes -> Maybe WindowAttributes)
-> IO WindowAttributes -> IO (Maybe WindowAttributes)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr WindowAttributes -> IO WindowAttributes
forall a. Storable a => Ptr a -> IO a
peek Ptr WindowAttributes
p
safeGetCommand :: Display -> Window -> X [String]
safeGetCommand :: Display -> Window -> X [String]
safeGetCommand Display
d Window
w = do
Window
wC <- String -> X Window
getAtom String
"WM_COMMAND"
Maybe [CChar]
p <- IO (Maybe [CChar]) -> X (Maybe [CChar])
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO (Maybe [CChar]) -> X (Maybe [CChar]))
-> IO (Maybe [CChar]) -> X (Maybe [CChar])
forall a b. (a -> b) -> a -> b
$ Display -> Window -> Window -> IO (Maybe [CChar])
getWindowProperty8 Display
d Window
wC Window
w
case Maybe [CChar]
p of
Maybe [CChar]
Nothing -> [String] -> X [String]
forall (m :: * -> *) a. Monad m => a -> m a
return []
Just [CChar]
cs' -> do
let cs :: String
cs = (CChar -> Char) -> [CChar] -> String
forall a b. (a -> b) -> [a] -> [b]
map (Int -> Char
forall a. Enum a => Int -> a
toEnum (Int -> Char) -> (CChar -> Int) -> CChar -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CChar -> Int
forall a. Enum a => a -> Int
fromEnum) [CChar]
cs'
go :: ([String], (String, String)) -> ([String], (String, String))
go ([String]
a,(String
s,String
"\NUL")) = (String
sString -> [String] -> [String]
forall a. a -> [a] -> [a]
:[String]
a,(String
"",String
""))
go ([String]
a,(String
s,Char
'\NUL':String
ss)) = ([String], (String, String)) -> ([String], (String, String))
go (String
sString -> [String] -> [String]
forall a. a -> [a] -> [a]
:[String]
a,String -> (String, String)
go' String
ss)
go ([String], (String, String))
r = ([String], (String, String))
r
go' :: String -> (String, String)
go' = (Char -> Bool) -> String -> (String, String)
forall a. (a -> Bool) -> [a] -> ([a], [a])
break (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'\NUL')
in [String] -> X [String]
forall (m :: * -> *) a. Monad m => a -> m a
return ([String] -> X [String]) -> [String] -> X [String]
forall a b. (a -> b) -> a -> b
$ [String] -> [String]
forall a. [a] -> [a]
reverse ([String] -> [String]) -> [String] -> [String]
forall a b. (a -> b) -> a -> b
$ ([String], (String, String)) -> [String]
forall a b. (a, b) -> a
fst (([String], (String, String)) -> [String])
-> ([String], (String, String)) -> [String]
forall a b. (a -> b) -> a -> b
$ ([String], (String, String)) -> ([String], (String, String))
go ([],String -> (String, String)
go' String
cs)
getMachine :: Window -> X String
getMachine :: Window -> X String
getMachine Window
w = X String -> X String -> X String
forall a. X a -> X a -> X a
catchX' (String -> X Window
getAtom String
"WM_CLIENT_MACHINE" X Window -> (Window -> X String) -> X String
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Window -> Window -> X String
getDecodedStringProp Window
w) (String -> X String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"")