From 905ee90bad8922aaac5c1408fcdc5370ac388a78 Mon Sep 17 00:00:00 2001 From: mwlochbaum Date: Tue, 5 Feb 2013 19:28:58 +0100 Subject: configurableEventMasks Ignore-this: 3848de0f8f5ad5995e87a2a01e7752f darcs-hash:20130205182858-2314b-e8e2c7286946762cadb2e58ae043b194d681df9e --- XMonad/Config.hs | 19 +++++++++++++++++-- XMonad/Core.hs | 2 ++ XMonad/Main.hsc | 5 ++--- XMonad/Operations.hs | 11 ++++------- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/XMonad/Config.hs b/XMonad/Config.hs index 1fdef5b..cbfb06e 100644 --- a/XMonad/Config.hs +++ b/XMonad/Config.hs @@ -27,11 +27,11 @@ module XMonad.Config (defaultConfig) where import XMonad.Core as XMonad hiding (workspaces,manageHook,keys,logHook,startupHook,borderWidth,mouseBindings ,layoutHook,modMask,terminal,normalBorderColor,focusedBorderColor,focusFollowsMouse - ,handleEventHook,clickJustFocuses) + ,handleEventHook,clickJustFocuses,rootMask,clientMask) import qualified XMonad.Core as XMonad (workspaces,manageHook,keys,logHook,startupHook,borderWidth,mouseBindings ,layoutHook,modMask,terminal,normalBorderColor,focusedBorderColor,focusFollowsMouse - ,handleEventHook,clickJustFocuses) + ,handleEventHook,clickJustFocuses,rootMask,clientMask) import XMonad.Layout import XMonad.Operations @@ -145,6 +145,19 @@ layout = tiled ||| Mirror tiled ||| Full -- Percent of screen to increment by when resizing panes delta = 3/100 +------------------------------------------------------------------------ +-- Event Masks: + +-- | The client events that xmonad is interested in +clientMask :: EventMask +clientMask = structureNotifyMask .|. enterWindowMask .|. propertyChangeMask + +-- | The root events that xmonad is interested in +rootMask :: EventMask +rootMask = substructureRedirectMask .|. substructureNotifyMask + .|. enterWindowMask .|. leaveWindowMask .|. structureNotifyMask + .|. buttonPressMask + ------------------------------------------------------------------------ -- Key bindings: @@ -254,6 +267,8 @@ defaultConfig = XConfig , XMonad.handleEventHook = handleEventHook , XMonad.focusFollowsMouse = focusFollowsMouse , XMonad.clickJustFocuses = clickJustFocuses + , XMonad.clientMask = clientMask + , XMonad.rootMask = rootMask } -- | Finally, a copy of the default bindings in simple textual tabular format. diff --git a/XMonad/Core.hs b/XMonad/Core.hs index e3d1b27..569f9f9 100644 --- a/XMonad/Core.hs +++ b/XMonad/Core.hs @@ -111,6 +111,8 @@ data XConfig l = XConfig , startupHook :: !(X ()) -- ^ The action to perform on startup , focusFollowsMouse :: !Bool -- ^ Whether window entry events can change focus , clickJustFocuses :: !Bool -- ^ False to make a click which changes focus to be additionally passed to the window + , clientMask :: !EventMask -- ^ The client events that xmonad is interested in + , rootMask :: !EventMask -- ^ The root events that xmonad is interested in } diff --git a/XMonad/Main.hsc b/XMonad/Main.hsc index 0176187..8410a0c 100644 --- a/XMonad/Main.hsc +++ b/XMonad/Main.hsc @@ -75,9 +75,8 @@ xmonad initxmc = do -- If another WM is running, a BadAccess error will be returned. The -- default error handler will write the exception to stderr and exit with -- an error. - selectInput dpy rootw $ substructureRedirectMask .|. substructureNotifyMask - .|. enterWindowMask .|. leaveWindowMask .|. structureNotifyMask - .|. buttonPressMask + selectInput dpy rootw $ rootMask initxmc + sync dpy False -- sync to ensure all outstanding errors are delivered -- turn off the default handler in favor of one that ignores all errors diff --git a/XMonad/Operations.hs b/XMonad/Operations.hs index bc69962..41fbed0 100644 --- a/XMonad/Operations.hs +++ b/XMonad/Operations.hs @@ -184,9 +184,10 @@ setWMState w v = withDisplay $ \dpy -> do -- | hide. Hide a window by unmapping it, and setting Iconified. hide :: Window -> X () hide w = whenX (gets (S.member w . mapped)) $ withDisplay $ \d -> do - io $ do selectInput d w (clientMask .&. complement structureNotifyMask) + cMask <- asks $ clientMask . config + io $ do selectInput d w (cMask .&. complement structureNotifyMask) unmapWindow d w - selectInput d w clientMask + selectInput d w cMask setWMState w iconicState -- this part is key: we increment the waitingUnmap counter to distinguish -- between client and xmonad initiated unmaps. @@ -201,15 +202,11 @@ reveal w = withDisplay $ \d -> do io $ mapWindow d w whenX (isClient w) $ modify (\s -> s { mapped = S.insert w (mapped s) }) --- | The client events that xmonad is interested in -clientMask :: EventMask -clientMask = structureNotifyMask .|. enterWindowMask .|. propertyChangeMask - -- | Set some properties when we initially gain control of a window setInitialProperties :: Window -> X () setInitialProperties w = asks normalBorder >>= \nb -> withDisplay $ \d -> do setWMState w iconicState - io $ selectInput d w clientMask + asks (clientMask . config) >>= io . selectInput d w bw <- asks (borderWidth . config) io $ setWindowBorderWidth d w bw -- we must initially set the color of new windows, to maintain invariants -- cgit v1.2.3