aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Util/NamedWindows.hs
diff options
context:
space:
mode:
authorSpencer Janssen <sjanssen@cse.unl.edu>2008-05-02 12:42:49 +0200
committerSpencer Janssen <sjanssen@cse.unl.edu>2008-05-02 12:42:49 +0200
commit52dbdd8c41886b8e65ad0249b3069914efcb95dd (patch)
treea14ae5fb47a355723bb8f9d92670c5e5a0d63809 /XMonad/Util/NamedWindows.hs
parent3b06802b38a232d990d3bf5ff6d31e902e7c3b51 (diff)
downloadXMonadContrib-52dbdd8c41886b8e65ad0249b3069914efcb95dd.tar.gz
XMonadContrib-52dbdd8c41886b8e65ad0249b3069914efcb95dd.tar.xz
XMonadContrib-52dbdd8c41886b8e65ad0249b3069914efcb95dd.zip
NamedWindows: when converting the text property, handle the empty list.
This fixes a "Prelude.head" exception observed with windows that have no title. Reproduce by placing several windows in the tabbed layout, then starting 'xterm -name ""'. Thanks to Andrea for pointing out the issue. darcs-hash:20080502104249-a5988-c460b42456d65ad71016a7423e713b8250f1aa5c.gz
Diffstat (limited to 'XMonad/Util/NamedWindows.hs')
-rw-r--r--XMonad/Util/NamedWindows.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/XMonad/Util/NamedWindows.hs b/XMonad/Util/NamedWindows.hs
index c29519e..4ab7078 100644
--- a/XMonad/Util/NamedWindows.hs
+++ b/XMonad/Util/NamedWindows.hs
@@ -44,12 +44,17 @@ instance Show NamedWindow where
getName :: Window -> X NamedWindow
getName w = withDisplay $ \d -> do
+ -- TODO, this code is ugly and convoluted -- clean it up
let getIt = bracket getProp (xFree . tp_value) (fmap (`NW` w) . copy)
getProp = (internAtom d "_NET_WM_NAME" False >>= getTextProperty d w)
`catch` \_ -> getTextProperty d w wM_NAME
- copy prop = head `fmap` wcTextPropertyToTextList d prop
+ copy prop = do
+ xs <- wcTextPropertyToTextList d prop
+ return $ case xs of
+ [] -> ""
+ (x:_) -> x
io $ getIt `catch` \_ -> ((`NW` w) . resName) `fmap` getClassHint d w