Adjusted EwmhDesktops module

This commit is contained in:
Matthias Schiffer 2011-09-03 13:43:11 +02:00
parent 6ce8a6515e
commit 01a381911a
3 changed files with 27 additions and 12 deletions

View file

@ -6,6 +6,7 @@ module DynamicPerScreenWorkspaces ( screenWorkspaceStorage
, dynamicRescreenHook
, create
, cleanup
, focusWindow
, view
, viewOn
, viewOnCurrent
@ -128,6 +129,15 @@ create conf i = do
cleanup :: X ()
cleanup = windows cleanup'
focusWindow :: DynamicWorkspaceConfig -> Window -> X ()
focusWindow conf w = do
wset <- gets windowset
let mws = W.findTag w wset
whenJust mws $ \ws -> do
let i = head $ filter ((== ws) . workspaceTag conf) [0..]
sid <- workspaceScreen conf i
windows' $ liftM (cleanup' . W.focusWindow w) . viewOn' conf sid i
view :: DynamicWorkspaceConfig -> Int -> X ()
view conf i = do
sid <- workspaceScreen conf i

View file

@ -36,6 +36,8 @@ import XMonad.Util.XUtils (fi)
import XMonad.Util.WorkspaceCompare
import XMonad.Util.WindowProperties (getProp32)
import DynamicPerScreenWorkspaces
-- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
--
@ -48,9 +50,9 @@ import XMonad.Util.WindowProperties (getProp32)
-- | Add EWMH functionality to the given config. See above for an example.
ewmh :: XConfig a -> XConfig a
ewmh c = c { startupHook = startupHook c +++ ewmhDesktopsStartup
, handleEventHook = handleEventHook c +++ ewmhDesktopsEventHook
ewmh :: DynamicWorkspaceConfig -> XConfig a -> XConfig a
ewmh dwc c = c { startupHook = startupHook c +++ ewmhDesktopsStartup
, handleEventHook = handleEventHook c +++ ewmhDesktopsEventHook dwc
, logHook = logHook c +++ ewmhDesktopsLogHook }
where x +++ y = mappend x y
@ -105,11 +107,11 @@ ewmhDesktopsLogHook = withWindowSet $ \s -> do
--
-- * _NET_ACTIVE_WINDOW (activate another window, changing workspace if needed)
--
ewmhDesktopsEventHook :: Event -> X All
ewmhDesktopsEventHook e = handle e >> return (All True)
ewmhDesktopsEventHook :: DynamicWorkspaceConfig -> Event -> X All
ewmhDesktopsEventHook dwc e = handle dwc e >> return (All True)
handle :: Event -> X ()
handle ClientMessageEvent {
handle :: DynamicWorkspaceConfig -> Event -> X ()
handle dwc ClientMessageEvent {
ev_window = w,
ev_message_type = mt,
ev_data = d
@ -125,7 +127,9 @@ handle ClientMessageEvent {
if mt == a_cd then do
let n = head d
if 0 <= n && fi n < length ws then
windows $ W.view (W.tag (ws !! fi n))
--windows $ W.view (W.tag (ws !! fi n))
--view dwc $ fi n
return ()
else trace $ "Bad _NET_CURRENT_DESKTOP with data[0]="++show n
else if mt == a_d then do
let n = head d
@ -133,7 +137,8 @@ handle ClientMessageEvent {
windows $ W.shiftWin (W.tag (ws !! fi n)) w
else trace $ "Bad _NET_DESKTOP with data[0]="++show n
else if mt == a_aw then do
windows $ W.focusWindow w
--windows $ W.focusWindow w
focusWindow dwc w
else if mt == a_cw then do
killWindow w
else if mt `elem` a_ignore then do
@ -142,7 +147,7 @@ handle ClientMessageEvent {
-- The Message is unknown to us, but that is ok, not all are meant
-- to be handled by the window manager
return ()
handle _ = return ()
handle _ _ = return ()
-- |
-- An event hook to handle applications that wish to fullscreen using the

View file

@ -28,7 +28,7 @@ import ProcessWorkspaces
modm = mod4Mask
main = xmonad $ ewmh $ defaultConfig
main = xmonad $ ewmh dwConfig $ defaultConfig
{ modMask = modm
, manageHook = myManageHook
, layoutHook = desktopLayoutModifiers myLayoutHook