diff --git a/XMonad/Hooks/EwmhDesktops.hs b/XMonad/Hooks/EwmhDesktops.hs index 2ca8c3aaca..9d067785bc 100644 --- a/XMonad/Hooks/EwmhDesktops.hs +++ b/XMonad/Hooks/EwmhDesktops.hs @@ -1,6 +1,5 @@ -{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE MultiWayIf #-} -{-# LANGUAGE PatternGuards #-} ----------------------------------------------------------------------------- -- | @@ -248,7 +247,7 @@ activateLogHook mh = XS.get >>= maybe (return ()) go . netActivated windows (appEndo f) handle :: ([WindowSpace] -> [WindowSpace]) -> Event -> X () -handle f ClientMessageEvent{ev_window = w, ev_message_type = mt, ev_data = d} = +handle f (ClientMessageEvent {ev_window = w, ev_message_type = mt, ev_data = d}) = withWindowSet $ \s -> do sort' <- getSortByIndex let ws = f $ sort' $ W.workspaces s @@ -258,18 +257,16 @@ handle f ClientMessageEvent{ev_window = w, ev_message_type = mt, ev_data = d} = a_aw <- getAtom "_NET_ACTIVE_WINDOW" a_cw <- getAtom "_NET_CLOSE_WINDOW" - if | mt == a_cd, n : _ <- d, Just ww <- ws !? fi n -> - windows $ W.view (W.tag ww) - | mt == a_cd -> - trace $ "Bad _NET_CURRENT_DESKTOP with data=" ++ show d - | mt == a_d, n : _ <- d, Just ww <- ws !? fi n -> - windows $ W.shiftWin (W.tag ww) w + if | mt == a_cd -> + case d of + (n:_) | 0 <= n && fi n < length ws -> windows $ W.view (W.tag (ws !! fi n)) + | otherwise -> trace $ "Bad _NET_CURRENT_DESKTOP with data[0]="++show n + _ -> trace $ "Bad _NET_CURRENT_DESKTOP with data="++show d | mt == a_d -> - trace $ "Bad _NET_WM_DESKTOP with data=" ++ show d - | mt == a_aw, 2 : _ <- d -> - -- when the request comes from a pager, honor it unconditionally - -- https://specifications.freedesktop.org/wm-spec/wm-spec-1.3.html#sourceindication - windows $ W.focusWindow w + case d of + (n:_) | 0 <= n && fi n < length ws -> windows $ W.shiftWin (W.tag (ws !! fi n)) w + | otherwise -> trace $ "Bad _NET_DESKTOP with data[0]="++show n + _ -> trace $ "Bad _NET_DESKTOP with data="++show d | mt == a_aw -> do lh <- asks (logHook . config) XS.put (NetActivated (Just w))