[MINOR] made xmonad focus monitor on hover, even if empty
This commit is contained in:
parent
5fc4290ed2
commit
aa3d8cde7d
1 changed files with 37 additions and 1 deletions
|
@ -26,6 +26,14 @@ import XMonad.Actions.UpdateFocus (focusUnderPointer)
|
||||||
import XMonad.Layout.NoBorders
|
import XMonad.Layout.NoBorders
|
||||||
import XMonad.Layout.Spacing
|
import XMonad.Layout.Spacing
|
||||||
|
|
||||||
|
|
||||||
|
-- MultiMonitorFocusHook
|
||||||
|
import Control.Monad (when)
|
||||||
|
import Data.Foldable (find)
|
||||||
|
import Foreign.C (CInt)
|
||||||
|
import Data.Maybe (fromMaybe)
|
||||||
|
import Data.Monoid (All (All))
|
||||||
|
|
||||||
--Miscellaneous
|
--Miscellaneous
|
||||||
import qualified XMonad.StackSet as W
|
import qualified XMonad.StackSet as W
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
@ -140,6 +148,33 @@ myManageHook = composeAll
|
||||||
, isFullscreen --> doFullFloat]
|
, isFullscreen --> doFullFloat]
|
||||||
|
|
||||||
myEventHook = ewmhDesktopsEventHook
|
myEventHook = ewmhDesktopsEventHook
|
||||||
|
|
||||||
|
|
||||||
|
multiScreenFocusHook :: Event -> X All
|
||||||
|
multiScreenFocusHook MotionEvent { ev_x = x, ev_y = y } = do
|
||||||
|
ms <- getScreenForPos x y
|
||||||
|
let cursorScreenID = W.screen <$> ms
|
||||||
|
focussedScreenID <- W.screen . W.current . windowset <$> get
|
||||||
|
when (cursorScreenID /= Just focussedScreenID) $
|
||||||
|
maybe (return ()) (windows . W.view . W.tag . W.workspace) ms
|
||||||
|
return (All True)
|
||||||
|
where
|
||||||
|
getScreenForPos :: CInt -> CInt
|
||||||
|
-> X (Maybe (W.Screen WorkspaceId (Layout Window) Window ScreenId ScreenDetail))
|
||||||
|
getScreenForPos x y = do
|
||||||
|
ws <- windowset <$> get
|
||||||
|
let screens = W.current ws : W.visible ws
|
||||||
|
inRects = map (inRect x y . screenRect . W.screenDetail) screens
|
||||||
|
return $ fst <$> find snd (zip screens inRects)
|
||||||
|
|
||||||
|
inRect :: CInt -> CInt -> Rectangle -> Bool
|
||||||
|
inRect x y rect =
|
||||||
|
let l = fromIntegral (rect_x rect)
|
||||||
|
r = l + fromIntegral (rect_width rect)
|
||||||
|
t = fromIntegral (rect_y rect)
|
||||||
|
b = t + fromIntegral (rect_height rect)
|
||||||
|
in x >= l && x < r && y >= t && y < b
|
||||||
|
|
||||||
myStartupHook = do
|
myStartupHook = do
|
||||||
spawnOnce "pasystray"
|
spawnOnce "pasystray"
|
||||||
spawnOnce "nitrogen --restore &"
|
spawnOnce "nitrogen --restore &"
|
||||||
|
@ -190,6 +225,7 @@ myXmobarPP s = def
|
||||||
|
|
||||||
myConfig = def
|
myConfig = def
|
||||||
{
|
{
|
||||||
|
rootMask = rootMask def .|. pointerMotionMask,
|
||||||
terminal = myTerminal,
|
terminal = myTerminal,
|
||||||
focusFollowsMouse = myFocusFollowsMouse,
|
focusFollowsMouse = myFocusFollowsMouse,
|
||||||
clickJustFocuses = myClickJustFocuses,
|
clickJustFocuses = myClickJustFocuses,
|
||||||
|
@ -201,7 +237,7 @@ myConfig = def
|
||||||
-- keys = myKeys,
|
-- keys = myKeys,
|
||||||
layoutHook = smartBorders . spacingWithEdge 10 $ myLayout,
|
layoutHook = smartBorders . spacingWithEdge 10 $ myLayout,
|
||||||
manageHook = manageSpawn <+> myManageHook <+> manageHook def,
|
manageHook = manageSpawn <+> myManageHook <+> manageHook def,
|
||||||
handleEventHook = myEventHook <+> fullscreenEventHook <+> swallowEventHook (className=?"Alacritty") (return True) ,
|
handleEventHook = myEventHook <+> multiScreenFocusHook <+> fullscreenEventHook <+> swallowEventHook (className=?"Alacritty") (return True),
|
||||||
startupHook = myStartupHook
|
startupHook = myStartupHook
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue