mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-07-26 17:51:51 -07:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user