From 1ec6561af48ced6631c73ee4e94014afe68d5570 Mon Sep 17 00:00:00 2001 From: quesel Date: Tue, 16 Nov 2010 09:14:49 +0100 Subject: 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 --- XMonad/Layout/IndependentScreens.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3