Issue 177 - XMonad.Operations patched setFocusX

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
-- track-currently-processing-event.dpatch change to X.Operations.setFocusX
-- (adds Data.Bits.testBit import)

-- It also depends on adding a currentEvent XConf field in Core and handling it in Main

-- | Call X to set the keyboard focus details.
setFocusX :: Window -> X ()
setFocusX w = withWindowSet $ \ws -> do
    dpy <- asks display

    -- clear mouse button grab and border on other windows
    forM_ (W.current ws : W.visible ws) $ \wk ->
        forM_ (W.index (W.view (W.tag (W.workspace wk)) ws)) $ \otherw ->
            setButtonGrab True otherw

    -- If we ungrab buttons on the root window, we lose our mouse bindings.
    whenX (not <$> isRoot w) $ setButtonGrab False w

    hints <- io $ getWMHints dpy w
    protocols <- io $ getWMProtocols dpy w
    wmprot <- atom_WM_PROTOCOLS
    wmtf <- atom_WM_TAKE_FOCUS
    currevt <- asks currentEvent
    let inputHintSet = wmh_flags hints `testBit` inputHintBit

    when ((inputHintSet && wmh_input hints) || (not inputHintSet)) $
      io $ do setInputFocus dpy w revertToPointerRoot 0
    when (wmtf `elem` protocols) $
      io $ allocaXEvent $ \ev -> do
        setEventType ev clientMessage
        setClientMessageEvent ev w wmprot 32 wmtf $ maybe currentTime event_time currevt
        sendEvent dpy w False noEventMask ev
        where event_time ev =
                if (ev_event_type ev) `elem` timedEvents then
                  ev_time ev
                else
                  currentTime
              timedEvents = [ keyPress, keyRelease, buttonPress, buttonRelease, enterNotify
							, leaveNotify, selectionRequest ]
26:11: Warning: Redundant bracket
Found:
(inputHintSet && wmh_input hints) || (not inputHintSet)
Why not:
(inputHintSet && wmh_input hints) || not inputHintSet
27:12: Error: Redundant do
Found:
do setInputFocus dpy w revertToPointerRoot 0
Why not:
setInputFocus dpy w revertToPointerRoot 0
34:20: Warning: Redundant bracket
Found:
(ev_event_type ev) `elem` timedEvents
Why not:
ev_event_type ev `elem` timedEvents