aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Hooks
diff options
context:
space:
mode:
authorhaskell <haskell@tmorris.net>2011-01-05 04:25:35 +0100
committerhaskell <haskell@tmorris.net>2011-01-05 04:25:35 +0100
commit76dfd6304910abf174f9a17fdfee29c5ccfd630f (patch)
treecf190a8c4233ea65d806d6c0f83243d961049899 /XMonad/Hooks
parent2dd4f917627dc5b33fca41f8da5299bf52acbb63 (diff)
downloadXMonadContrib-76dfd6304910abf174f9a17fdfee29c5ccfd630f.tar.gz
XMonadContrib-76dfd6304910abf174f9a17fdfee29c5ccfd630f.tar.xz
XMonadContrib-76dfd6304910abf174f9a17fdfee29c5ccfd630f.zip
Java swing application focus patch
Ignore-this: 301805eb559489d34d984dc13c0fa5d0 darcs-hash:20110105032535-bbeb2-893cd5340a5c6a8f6d459a4e0a35d5e16233711d.gz
Diffstat (limited to 'XMonad/Hooks')
-rw-r--r--XMonad/Hooks/ICCCMFocus.hs57
1 files changed, 57 insertions, 0 deletions
diff --git a/XMonad/Hooks/ICCCMFocus.hs b/XMonad/Hooks/ICCCMFocus.hs
new file mode 100644
index 0000000..c059ad2
--- /dev/null
+++ b/XMonad/Hooks/ICCCMFocus.hs
@@ -0,0 +1,57 @@
+-----------------------------------------------------------------------------
+-- |
+-- Module : XMonad.Hooks.ICCCMFocus
+-- License : BSD
+--
+-- Maintainer : Tony Morris <haskell@tmorris.net>
+--
+-- Implemented in your @logHook@, Java swing applications will not misbehave
+-- when it comes to taking and losing focus.
+--
+-- This has been done by taking the patch in <http://code.google.com/p/xmonad/issues/detail?id=177> and refactoring it so that it can be included in @~\/.xmonad\/xmonad.hs@.
+--
+-- @
+-- conf' =
+-- conf {
+-- logHook = takeTopFocus
+-- }
+-- @
+-----------------------------------------------------------------------------
+module XMonad.Hooks.ICCCMFocus
+(
+ atom_WM_TAKE_FOCUS
+, takeFocusX
+, takeTopFocus
+) where
+
+import XMonad
+import XMonad.Hooks.SetWMName
+import qualified XMonad.StackSet as W
+import Control.Monad
+
+atom_WM_TAKE_FOCUS ::
+ X Atom
+atom_WM_TAKE_FOCUS =
+ getAtom "WM_TAKE_FOCUS"
+
+takeFocusX ::
+ Window
+ -> X ()
+takeFocusX w =
+ withWindowSet . const $ do
+ dpy <- asks display
+ wmtakef <- atom_WM_TAKE_FOCUS
+ wmprot <- atom_WM_PROTOCOLS
+ protocols <- io $ getWMProtocols dpy w
+ when (wmtakef `elem` protocols) $
+ io . allocaXEvent $ \ev -> do
+ setEventType ev clientMessage
+ setClientMessageEvent ev w wmprot 32 wmtakef currentTime
+ sendEvent dpy w False noEventMask ev
+
+-- | The value to add to your log hook configuration.
+takeTopFocus ::
+ X ()
+takeTopFocus =
+ (withWindowSet $ maybe (setFocusX =<< asks theRoot) takeFocusX . W.peek) >> setWMName "LG3D"
+