diff options
author | Dmitri Iouchtchenko <johnnyspoon@gmail.com> | 2013-01-23 05:38:50 +0100 |
---|---|---|
committer | Dmitri Iouchtchenko <johnnyspoon@gmail.com> | 2013-01-23 05:38:50 +0100 |
commit | 1c21d0580c70b1351ee8c58ba853ddb032635f34 (patch) | |
tree | fbe9946a53efa9ed3b4989109acdba74d71b1fcd /XMonad | |
parent | ccec28ce8b5c44fcc39bd647acc7d506ac7e22d2 (diff) | |
download | XMonadContrib-1c21d0580c70b1351ee8c58ba853ddb032635f34.tar.gz XMonadContrib-1c21d0580c70b1351ee8c58ba853ddb032635f34.tar.xz XMonadContrib-1c21d0580c70b1351ee8c58ba853ddb032635f34.zip |
Avoid repainting elements in X.A.GridSelect
Ignore-this: 8e926cebc8d458a06a05f7457ae40b68
darcs-hash:20130123043850-7d114-908a346dd3d8a84cd896fcde1505d41284f01795.gz
Diffstat (limited to 'XMonad')
-rw-r--r-- | XMonad/Actions/GridSelect.hs | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/XMonad/Actions/GridSelect.hs b/XMonad/Actions/GridSelect.hs index bb392d9..513d4ac 100644 --- a/XMonad/Actions/GridSelect.hs +++ b/XMonad/Actions/GridSelect.hs @@ -238,10 +238,11 @@ data TwoDState a = TwoDState { td_curpos :: TwoDPosition , td_paneY :: Integer , td_drawingWin :: Window , td_searchString :: String + , td_elementmap :: TwoDElementMap a } -td_elementmap :: TwoDState a -> [(TwoDPosition,(String,a))] -td_elementmap s = zipWith (,) positions sortedElements +generateElementmap :: TwoDState a -> TwoDElementMap a +generateElementmap s = zip positions sortedElements where TwoDState {td_availSlots = positions, td_searchString = searchString} = s @@ -337,11 +338,11 @@ updateAllElements = s <- get updateElements (td_elementmap s) -grayoutAllElements :: TwoD a () -grayoutAllElements = +grayoutElements :: Int -> TwoD a () +grayoutElements skip = do s <- get - updateElementsWithColorizer grayOnly (td_elementmap s) + updateElementsWithColorizer grayOnly $ drop skip (td_elementmap s) where grayOnly _ _ = return ("#808080", "#808080") updateElements :: TwoDElementMap a -> TwoD a () @@ -473,11 +474,17 @@ transformSearchString f = do let oldSearchString = td_searchString s newSearchString = f oldSearchString when (newSearchString /= oldSearchString) $ do - -- FIXME: grayoutAllElements + updateAllElements paint some fields twice causing flickering - -- we would need a much smarter update strategy to fix that - when (length newSearchString > length oldSearchString) grayoutAllElements -- FIXME curpos might end up outside new bounds - put s { td_searchString = newSearchString } + let s' = s { td_searchString = newSearchString } + m = generateElementmap s' + s'' = s' { td_elementmap = m } + oldLen = length $ td_elementmap s + newLen = length $ td_elementmap s'' + -- All the elements in the previous element map should be + -- grayed out, except for those which will be covered by + -- elements in the new element map. + when (newLen < oldLen) $ grayoutElements newLen + put s'' updateAllElements -- | By default gridselect used the defaultNavigation action, which @@ -653,8 +660,11 @@ gridselect gsconfig elements = td_paneX = screenWidth, td_paneY = screenHeight, td_drawingWin = win, - td_searchString = "" } - evalTwoD (updateAllElements >> (gs_navigate gsconfig)) s + td_searchString = "", + td_elementmap = [] } + m = generateElementmap s + evalTwoD (updateAllElements >> (gs_navigate gsconfig)) + (s { td_elementmap = m }) else return Nothing liftIO $ do |