mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-01 04:31:52 -07:00
Close the display correctly after counting the number of screens
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.
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user