mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-10 17:52:09 -07:00
Prefer safe alternatives to getWindowAttributes
Whenever possible, prefer the safe wrappers withWindowAttributes or safeGetWindowAttributes to getWindowAttributes. Places where these are not applicable are limited to layouts, where there is not good "default value" to give back in case these calls fail. In these cases, we let the exception handling of the layout mechanism handle it and fall back to the Full layout. Fixes: https://github.com/xmonad/xmonad-contrib/issues/146
This commit is contained in:
@@ -28,7 +28,6 @@ import XMonad
|
||||
import XMonad.Prelude
|
||||
import XMonad.StackSet (member, peek, screenDetail, current)
|
||||
|
||||
import Control.Exception (SomeException, try)
|
||||
import Control.Arrow ((&&&), (***))
|
||||
|
||||
-- $usage
|
||||
@@ -73,10 +72,9 @@ updatePointer refPos ratio = do
|
||||
let defaultRect = screenRect $ screenDetail $ current ws
|
||||
rect <- case peek ws of
|
||||
Nothing -> return defaultRect
|
||||
Just w -> do tryAttributes <- io $ try $ getWindowAttributes dpy w
|
||||
return $ case tryAttributes of
|
||||
Left (_ :: SomeException) -> defaultRect
|
||||
Right attributes -> windowAttributesToRectangle attributes
|
||||
Just w -> maybe defaultRect windowAttributesToRectangle
|
||||
<$> safeGetWindowAttributes w
|
||||
|
||||
root <- asks theRoot
|
||||
mouseIsMoving <- asks mouseFocused
|
||||
(_sameRoot,_,currentWindow,rootX,rootY,_,_,_) <- io $ queryPointer dpy root
|
||||
|
Reference in New Issue
Block a user