mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
Java swing application focus patch
This commit is contained in:
parent
bbd9761130
commit
37fc674790
57
XMonad/Hooks/ICCCMFocus.hs
Normal file
57
XMonad/Hooks/ICCCMFocus.hs
Normal file
@ -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"
|
||||
|
@ -142,6 +142,7 @@ library
|
||||
XMonad.Hooks.EwmhDesktops
|
||||
XMonad.Hooks.FadeInactive
|
||||
XMonad.Hooks.FloatNext
|
||||
XMonad.Hooks.ICCCMFocus
|
||||
XMonad.Hooks.InsertPosition
|
||||
XMonad.Hooks.ManageDocks
|
||||
XMonad.Hooks.ManageHelpers
|
||||
|
Loading…
x
Reference in New Issue
Block a user