aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad
diff options
context:
space:
mode:
Diffstat (limited to 'XMonad')
-rw-r--r--XMonad/Util/NamedWindows.hs15
1 files changed, 12 insertions, 3 deletions
diff --git a/XMonad/Util/NamedWindows.hs b/XMonad/Util/NamedWindows.hs
index c38e25b..719d599 100644
--- a/XMonad/Util/NamedWindows.hs
+++ b/XMonad/Util/NamedWindows.hs
@@ -22,6 +22,9 @@ module XMonad.Util.NamedWindows (
unName
) where
+import Control.Monad.Reader ( asks )
+import Control.Monad.State ( gets )
+
import qualified XMonad.StackSet as W ( peek )
@@ -40,9 +43,15 @@ instance Show NamedWindow where
show (NW n _) = n
getName :: Window -> X NamedWindow
-getName w = asks display >>= \d -> do s <- io $ getClassHint d w
- n <- maybe (resName s) id `fmap` io (fetchName d w)
- return $ NW n w
+getName w = withDisplay $ \d -> do
+ 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
+
+ io $ getIt `catch` \_ -> ((`NW` w) . resName) `fmap` getClassHint d w
unName :: NamedWindow -> Window
unName (NW _ w) = w