-----------------------------------------------------------------------------
-- |
-- Module       : XMonad.Hooks.ICCCMFocus
-- Description  : Deprecated.
-- 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
{-# DEPRECATED "XMonad.Hooks.ICCCMFocus: xmonad>0.10 core merged issue 177" #-}
(
  atom_WM_TAKE_FOCUS
, takeFocusX
, takeTopFocus
) where

import XMonad
import XMonad.Hooks.SetWMName
import qualified XMonad.StackSet as W

takeFocusX ::
  Window
  -> X ()
takeFocusX :: Window -> X ()
takeFocusX Window
_w = () -> X ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

-- | The value to add to your log hook configuration.
takeTopFocus ::
  X ()
takeTopFocus :: X ()
takeTopFocus =
  (WindowSet -> X ()) -> X ()
forall a. (WindowSet -> X a) -> X a
withWindowSet (X () -> (Window -> X ()) -> Maybe Window -> X ()
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Window -> X ()
setFocusX (Window -> X ()) -> X Window -> X ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (XConf -> Window) -> X Window
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks XConf -> Window
theRoot) Window -> X ()
takeFocusX (Maybe Window -> X ())
-> (WindowSet -> Maybe Window) -> WindowSet -> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WindowSet -> Maybe Window
forall i l a s sd. StackSet i l a s sd -> Maybe a
W.peek) X () -> X () -> X ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> String -> X ()
setWMName String
"LG3D"