aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorquesel <quesel@informatik.uni-oldenburg.de>2010-11-16 09:14:49 +0100
committerquesel <quesel@informatik.uni-oldenburg.de>2010-11-16 09:14:49 +0100
commit1ec6561af48ced6631c73ee4e94014afe68d5570 (patch)
tree34148e84cf3c7b85523be2ad6b5e1824f17dc70b
parent790fd3ad02aa70296ee458a02193154c899f6886 (diff)
downloadXMonadContrib-1ec6561af48ced6631c73ee4e94014afe68d5570.tar.gz
XMonadContrib-1ec6561af48ced6631c73ee4e94014afe68d5570.tar.xz
XMonadContrib-1ec6561af48ced6631c73ee4e94014afe68d5570.zip
Close the display correctly after counting the number of screens
Ignore-this: 6fbc269e34770935fed7d4fd9494154b This patch adds support for calling countScreens in arbitrary places. Prior to this patch one would end up with an open display for each call of the countScreens function with would eventually mess up X. This patch ensures that the display that is no longer needed is closed after the operation and thus using the function without side effects. darcs-hash:20101116081449-2216c-b6d4aee766682de3bec2aa9dd733adcccb5cdf7b.gz
-rw-r--r--XMonad/Layout/IndependentScreens.hs3
1 files changed, 2 insertions, 1 deletions
diff --git a/XMonad/Layout/IndependentScreens.hs b/XMonad/Layout/IndependentScreens.hs
index 0b5b996..17e782e 100644
--- a/XMonad/Layout/IndependentScreens.hs
+++ b/XMonad/Layout/IndependentScreens.hs
@@ -28,6 +28,7 @@ module XMonad.Layout.IndependentScreens (
) where
-- for the screen stuff
+import Control.Applicative((<*), liftA2)
import Control.Arrow hiding ((|||))
import Control.Monad
import Data.List
@@ -112,7 +113,7 @@ onCurrentScreen f vws = screen . current >>= f . flip marshall vws
-- > }
--
countScreens :: (MonadIO m, Integral i) => m i
-countScreens = liftM genericLength . liftIO $ openDisplay "" >>= getScreenInfo
+countScreens = liftM genericLength . liftIO $ openDisplay "" >>= liftA2 (<*) getScreenInfo closeDisplay
-- | This turns a naive pretty-printer into one that is aware of the
-- independent screens. That is, you can write your pretty printer to behave