@@ -203,10 +203,13 @@ data GSConfig a = GSConfig {
203
203
gs_colorizer :: a -> Bool -> X (String , String ),
204
204
gs_font :: String ,
205
205
gs_navigate :: TwoD a (Maybe a ),
206
+ -- ^ Customize key bindings for a GridSelect
206
207
gs_rearranger :: Rearranger a ,
207
208
gs_originFractX :: Double ,
208
209
gs_originFractY :: Double ,
209
- gs_bordercolor :: String
210
+ gs_bordercolor :: String ,
211
+ gs_cancelOnEmptyClick :: Bool
212
+ -- ^ When True, click on empty space will cancel GridSelect
210
213
}
211
214
212
215
-- | That is 'fromClassName' if you are selecting a 'Window', or
@@ -386,13 +389,20 @@ updateElementsWithColorizer colorizer elementmap = do
386
389
stdHandle :: Event -> TwoD a (Maybe a ) -> TwoD a (Maybe a )
387
390
stdHandle ButtonEvent { ev_event_type = t, ev_x = x, ev_y = y } contEventloop
388
391
| t == buttonRelease = do
389
- s@ TwoDState { td_paneX = px, td_paneY = py,
390
- td_gsconfig = (GSConfig ch cw _ _ _ _ _ _ _ _) } <- get
392
+ s@ TwoDState { td_paneX = px
393
+ , td_paneY = py
394
+ , td_gsconfig = GSConfig { gs_cellheight = ch
395
+ , gs_cellwidth = cw
396
+ , gs_cancelOnEmptyClick = cancelOnEmptyClick
397
+ }
398
+ } <- get
391
399
let gridX = (fi x - (px - cw) `div` 2 ) `div` cw
392
400
gridY = (fi y - (py - ch) `div` 2 ) `div` ch
393
401
case lookup (gridX,gridY) (td_elementmap s) of
394
402
Just (_,el) -> return (Just el)
395
- Nothing -> contEventloop
403
+ Nothing -> if cancelOnEmptyClick
404
+ then return Nothing
405
+ else contEventloop
396
406
| otherwise = contEventloop
397
407
398
408
stdHandle ExposeEvent {} contEventloop = updateAllElements >> contEventloop
@@ -648,7 +658,7 @@ gridselect gsconfig elements =
648
658
liftIO $ mapWindow dpy win
649
659
liftIO $ selectInput dpy win (exposureMask .|. keyPressMask .|. buttonReleaseMask)
650
660
status <- io $ grabKeyboard dpy win True grabModeAsync grabModeAsync currentTime
651
- io $ grabPointer dpy win True buttonReleaseMask grabModeAsync grabModeAsync none none currentTime
661
+ void $ io $ grabPointer dpy win True buttonReleaseMask grabModeAsync grabModeAsync none none currentTime
652
662
font <- initXMF (gs_font gsconfig)
653
663
let screenWidth = toInteger $ rect_width scr
654
664
screenHeight = toInteger $ rect_height scr
@@ -706,7 +716,7 @@ decorateName' w = do
706
716
707
717
-- | Builds a default gs config from a colorizer function.
708
718
buildDefaultGSConfig :: (a -> Bool -> X (String ,String )) -> GSConfig a
709
- buildDefaultGSConfig col = GSConfig 50 130 10 col " xft:Sans-8" defaultNavigation noRearranger (1 / 2 ) (1 / 2 ) " white"
719
+ buildDefaultGSConfig col = GSConfig 50 130 10 col " xft:Sans-8" defaultNavigation noRearranger (1 / 2 ) (1 / 2 ) " white" True
710
720
711
721
-- | Brings selected window to the current workspace.
712
722
bringSelected :: GSConfig Window -> X ()
0 commit comments