summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Main.hs4
-rw-r--r--Operations.hs3
-rw-r--r--XMonad.hs14
3 files changed, 13 insertions, 8 deletions
diff --git a/Main.hs b/Main.hs
index faaf059..04591ae 100644
--- a/Main.hs
+++ b/Main.hs
@@ -39,8 +39,6 @@ main = do
initcolor c = fst `liftM` allocNamedColor dpy (defaultColormap dpy dflt) c
rootw <- rootWindow dpy dflt
- wmdelt <- internAtom dpy "WM_DELETE_WINDOW" False
- wmprot <- internAtom dpy "WM_PROTOCOLS" False
xinesc <- getScreenInfo dpy
nbc <- initcolor normalBorderColor
fbc <- initcolor focusedBorderColor
@@ -53,8 +51,6 @@ main = do
cf = XConf
{ display = dpy
, theRoot = rootw
- , wmdelete = wmdelt
- , wmprotocols = wmprot
-- fromIntegral needed for X11 versions that use Int instead of CInt.
, normalBorder = nbc
, focusedBorder = fbc
diff --git a/Operations.hs b/Operations.hs
index 81df02a..ab99946 100644
--- a/Operations.hs
+++ b/Operations.hs
@@ -98,7 +98,8 @@ modifyGap f = do
--
kill :: X ()
kill = withDisplay $ \d -> withFocused $ \w -> do
- XConf {wmdelete = wmdelt, wmprotocols = wmprot} <- ask
+ wmdelt <- atom_WM_DELETE_WINDOW ; wmprot <- atom_WM_PROTOCOLS
+
protocols <- io $ getWMProtocols d w
io $ if wmdelt `elem` protocols
then allocaXEvent $ \ev -> do
diff --git a/XMonad.hs b/XMonad.hs
index 9f89f19..df60e23 100644
--- a/XMonad.hs
+++ b/XMonad.hs
@@ -17,7 +17,7 @@
module XMonad (
X, WindowSet, WorkspaceId(..), ScreenId(..), XState(..), XConf(..), Layout(..),
- Typeable, Message, SomeMessage(..), fromMessage,
+ Typeable, Message, SomeMessage(..), fromMessage, atom_WM_PROTOCOLS, atom_WM_DELETE_WINDOW,
runX, io, withDisplay, withWindowSet, isRoot, spawn, restart, trace, whenJust, whenX
) where
@@ -26,6 +26,7 @@ import StackSet (StackSet)
import Control.Monad.State
import Control.Monad.Reader
import System.IO
+import System.IO.Unsafe (unsafePerformIO)
import System.Posix.Process (executeFile, forkProcess, getProcessStatus, createSession)
import System.Exit
import System.Environment
@@ -47,8 +48,6 @@ data XState = XState
data XConf = XConf
{ display :: Display -- ^ the X11 display
, theRoot :: !Window -- ^ the root window
- , wmdelete :: !Atom -- ^ window deletion atom
- , wmprotocols :: !Atom -- ^ wm protocols atom
, normalBorder :: !Color -- ^ border color of unfocused windows
, focusedBorder :: !Color } -- ^ border color of the focused window
@@ -92,6 +91,15 @@ withWindowSet f = gets windowset >>= f
isRoot :: Window -> X Bool
isRoot w = liftM (w==) (asks theRoot)
+-- | Wrapper for the common case of atom internment
+getAtom :: String -> X Atom
+getAtom str = withDisplay $ \dpy -> io $ internAtom dpy str False
+
+-- | Common non-predefined atoms
+atom_WM_PROTOCOLS, atom_WM_DELETE_WINDOW :: X Atom
+atom_WM_PROTOCOLS = getAtom "WM_PROTOCOLS"
+atom_WM_DELETE_WINDOW = getAtom "WM_DELETE_WINDOW"
+
------------------------------------------------------------------------
-- Layout handling