From f0dcbcf3f0593ba7176b2a900060b7e933c1f7a1 Mon Sep 17 00:00:00 2001
From: Roman Cheplyaka <roma@ro-che.info>
Date: Thu, 25 Dec 2008 09:07:02 +0100
Subject: X.U.WindowProperties: propertyToQuery+docs

darcs-hash:20081225080702-3ebed-12de5f40c2a50480118e521fb233bfd4feb3d841.gz
---
 XMonad/Util/WindowProperties.hs | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/XMonad/Util/WindowProperties.hs b/XMonad/Util/WindowProperties.hs
index 226908d..d6282b1 100644
--- a/XMonad/Util/WindowProperties.hs
+++ b/XMonad/Util/WindowProperties.hs
@@ -14,7 +14,8 @@
 module XMonad.Util.WindowProperties (
     -- * Usage
     -- $usage
-    Property(..), hasProperty, focusedHasProperty, allWithProperty)
+    Property(..), hasProperty, focusedHasProperty, allWithProperty,
+    propertyToQuery)
 where
 import XMonad
 import qualified XMonad.StackSet as W
@@ -60,8 +61,20 @@ focusedHasProperty p = do
         Just s  -> hasProperty p $ W.focus s
         Nothing -> return False
 
+-- | Find all existing windows with specified property
 allWithProperty :: Property -> X [Window]
 allWithProperty prop = withDisplay $ \dpy -> do
     rootw <- asks theRoot
     (_,_,wins) <- io $ queryTree dpy rootw
     hasProperty prop `filterM` wins
+
+-- | Convert property to 'Query' 'Bool' (see "XMonad.ManageHook")
+propertyToQuery :: Property -> Query Bool
+propertyToQuery (Title s) = title =? s
+propertyToQuery (Resource s) = resource =? s
+propertyToQuery (ClassName s) = className =? s
+propertyToQuery (Role s) = stringProperty "WM_WINDOW_ROLE" =? s
+propertyToQuery (And p1 p2) = propertyToQuery p1 <&&> propertyToQuery p2
+propertyToQuery (Or p1 p2) = propertyToQuery p1 <||> propertyToQuery p2
+propertyToQuery (Not p) = not `fmap` propertyToQuery p
+propertyToQuery (Const b) = return b
-- 
cgit v1.2.3