From 9a59e55b1b527cdc0b4154a2a7ea022764de421e Mon Sep 17 00:00:00 2001 From: Michal Minar Date: Sun, 2 Aug 2015 10:00:21 +0200 Subject: Moved eventHook to local library Signed-off-by: Michal Minar --- Makefile | 1 + src/XMonad/Local/EventHook.hs | 32 ++++++++++++++++++++++++++++++++ xminad.cabal | 6 +++++- xminad.hs | 31 +++---------------------------- 4 files changed, 41 insertions(+), 29 deletions(-) create mode 100644 src/XMonad/Local/EventHook.hs diff --git a/Makefile b/Makefile index 88969fd..5e667a6 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,7 @@ realclean: ################################################################################ check: build $(CHECK) + cabal check ################################################################################ ifeq ($(DO_CHECK),YES) diff --git a/src/XMonad/Local/EventHook.hs b/src/XMonad/Local/EventHook.hs new file mode 100644 index 0000000..aa26b7e --- /dev/null +++ b/src/XMonad/Local/EventHook.hs @@ -0,0 +1,32 @@ +module XMonad.Local.EventHook (eventHook) where + +import qualified Data.Map as M +import Data.Monoid + +import XMonad +import XMonad.Hooks.EwmhDesktops +import XMonad.Hooks.FadeWindows +import XMonad.Hooks.ManageDocks +import qualified XMonad.StackSet as W + +eventHook :: Event -> X All +eventHook = mconcat + [ ewmhDesktopsEventHook + , docksEventHook + , fadeWindowsEventHook + , focusFollowsTiledOnly + , fullscreenEventHook + ] + +-- | Enables 'focusFollowsMouse' for tiled windows only. For this to +-- work you need to turn off 'focusFollowsMouse' in your configuration +-- and then add this function to your 'handleEventHook'. +focusFollowsTiledOnly :: Event -> X All +focusFollowsTiledOnly e@(CrossingEvent {ev_window = w, ev_event_type = t}) + | isNormalEnter = whenX bothTiled (focus w) >> mempty + where isNormalEnter = t == enterNotify && ev_mode e == notifyNormal + bothTiled = notFloating w <&&> currentIsTiled + currentIsTiled = currentWindow >>= maybe (return True) notFloating + currentWindow = gets $ W.peek . windowset + notFloating w' = gets $ not . M.member w' . W.floating . windowset +focusFollowsTiledOnly _ = mempty diff --git a/xminad.cabal b/xminad.cabal index 9c8e238..c21403b 100644 --- a/xminad.cabal +++ b/xminad.cabal @@ -51,8 +51,8 @@ Library XMonad.Layout.TopicDir XMonad.Local.Actions XMonad.Local.Config - XMonad.Local.XConfig XMonad.Local.GridSelect + XMonad.Local.EventHook XMonad.Local.LogHook XMonad.Local.Keys XMonad.Local.Layout @@ -60,6 +60,7 @@ Library XMonad.Local.NamedScratchpad XMonad.Local.TopicSpace XMonad.Local.Workspaces + XMonad.Local.XConfig -- Directories containing source files. hs-source-dirs: src @@ -133,3 +134,6 @@ executable checkrc , xminad , xmonad , xmonad-contrib + + -- Base language which the package is written in. + default-language: Haskell2010 diff --git a/xminad.hs b/xminad.hs index ea63f8f..6fccb8f 100644 --- a/xminad.hs +++ b/xminad.hs @@ -2,29 +2,26 @@ {-# OPTIONS -fno-warn-missing-signatures #-} import qualified Data.Map as M -import Data.Monoid import qualified DBus as D import qualified DBus.Client as D import XMonad import qualified XMonad.Actions.FlexibleResize as FlexR import XMonad.Config.Desktop -import XMonad.Hooks.EwmhDesktops -import XMonad.Hooks.FadeWindows import XMonad.Hooks.SetWMName import XMonad.Hooks.UrgencyHook -import XMonad.Hooks.ManageDocks import qualified XMonad.StackSet as W import qualified XMonad.Util.EZConfig as EZ -- local modules ************************************************************** import qualified XMonad.Local.Config as Local -import qualified XMonad.Local.XConfig as Local +import qualified XMonad.Local.EventHook as Local import qualified XMonad.Local.LogHook as Local import qualified XMonad.Local.Keys as Local import qualified XMonad.Local.Layout as Local import qualified XMonad.Local.ManageHook as Local import qualified XMonad.Local.TopicSpace as Local +import qualified XMonad.Local.XConfig as Local -- Mouse bindings: default actions bound to mouse events @@ -43,28 +40,6 @@ myMouseBindings (XConfig {XMonad.modMask = mm}) = M.fromList , ((mm, button5), const $ windows W.swapUp) ] --- | Enables 'focusFollowsMouse' for tiled windows only. For this to --- work you need to turn off 'focusFollowsMouse' in your configuration --- and then add this function to your 'handleEventHook'. -focusFollowsTiledOnly :: Event -> X All -focusFollowsTiledOnly e@(CrossingEvent {ev_window = w, ev_event_type = t}) - | isNormalEnter = whenX bothTiled (focus w) >> mempty - where isNormalEnter = t == enterNotify && ev_mode e == notifyNormal - bothTiled = notFloating w <&&> currentIsTiled - currentIsTiled = currentWindow >>= maybe (return True) notFloating - currentWindow = gets $ W.peek . windowset - notFloating w' = gets $ not . M.member w' . W.floating . windowset -focusFollowsTiledOnly _ = mempty - -myEventHook :: Event -> X All -myEventHook = mconcat - [ ewmhDesktopsEventHook - , docksEventHook - , fadeWindowsEventHook - , focusFollowsTiledOnly - , fullscreenEventHook - ] - myConfig dbus = Local.xConfig { modMask = Local.modMask , borderWidth = 1 @@ -75,7 +50,7 @@ myConfig dbus = Local.xConfig , layoutHook = desktopLayoutModifiers Local.layoutHook , keys = Local.keyBindings , logHook = Local.logHook dbus - , handleEventHook = myEventHook + , handleEventHook = Local.eventHook , manageHook = Local.manageHook , startupHook = myStartupHook , mouseBindings = myMouseBindings -- cgit