aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Util
diff options
context:
space:
mode:
authorRoman Cheplyaka <roma@ro-che.info>2008-12-25 09:07:02 +0100
committerRoman Cheplyaka <roma@ro-che.info>2008-12-25 09:07:02 +0100
commitf0dcbcf3f0593ba7176b2a900060b7e933c1f7a1 (patch)
treeeb8f015ad57865ec67841df8c8118c4da90d7abe /XMonad/Util
parentb0eaccbe91f272ec5114101a038ef7d1499268e6 (diff)
downloadXMonadContrib-f0dcbcf3f0593ba7176b2a900060b7e933c1f7a1.tar.gz
XMonadContrib-f0dcbcf3f0593ba7176b2a900060b7e933c1f7a1.tar.xz
XMonadContrib-f0dcbcf3f0593ba7176b2a900060b7e933c1f7a1.zip
X.U.WindowProperties: propertyToQuery+docs
darcs-hash:20081225080702-3ebed-12de5f40c2a50480118e521fb233bfd4feb3d841.gz
Diffstat (limited to 'XMonad/Util')
-rw-r--r--XMonad/Util/WindowProperties.hs15
1 files changed, 14 insertions, 1 deletions
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