More ScreenDetails fixes

This commit is contained in:
Spencer Janssen 2007-06-30 06:59:16 +00:00
parent 3b9723b5ae
commit 52e6f1c210
4 changed files with 14 additions and 11 deletions

View File

@ -47,7 +47,7 @@ import StackSet
copy :: WorkspaceId -> X () copy :: WorkspaceId -> X ()
copy n = windows (copy' n) copy n = windows (copy' n)
copy' :: (Ord a, Eq s, Integral i) => i -> StackSet i a s -> StackSet i a s copy' :: (Ord a, Eq s, Integral i) => i -> StackSet i a s sd -> StackSet i a s sd
copy' n s = if n `tagMember` s && n /= tag (workspace (current s)) copy' n s = if n `tagMember` s && n /= tag (workspace (current s))
then maybe s go (peek s) then maybe s go (peek s)
else s else s
@ -68,11 +68,11 @@ copy' n s = if n `tagMember` s && n /= tag (workspace (current s))
-- Semantics in Huet's paper is that insert doesn't move the cursor. -- Semantics in Huet's paper is that insert doesn't move the cursor.
-- However, we choose to insert above, and move the focus. -- However, we choose to insert above, and move the focus.
insertUp' :: Eq a => a -> StackSet i a s -> StackSet i a s insertUp' :: Eq a => a -> StackSet i a s sd -> StackSet i a s sd
insertUp' a s = modify (Just $ Stack a [] []) insertUp' a s = modify (Just $ Stack a [] [])
(\(Stack t l r) -> Just $ Stack a (L.delete a l) (L.delete a (t:r))) s (\(Stack t l r) -> Just $ Stack a (L.delete a l) (L.delete a (t:r))) s
delete' :: Ord a => a -> StackSet i a s -> StackSet i a s delete' :: Ord a => a -> StackSet i a s sd -> StackSet i a s sd
delete' w = sink w . modify Nothing (filter (/= w)) delete' w = sink w . modify Nothing (filter (/= w))
-- | Remove the focussed window from this workspace. If it's present in no -- | Remove the focussed window from this workspace. If it's present in no

View File

@ -39,7 +39,7 @@ import StackSet
dwmpromote :: X () dwmpromote :: X ()
dwmpromote = windows swap dwmpromote = windows swap
swap :: StackSet i a s -> StackSet i a s swap :: StackSet i a s sd -> StackSet i a s sd
swap = modify' $ \c -> case c of swap = modify' $ \c -> case c of
Stack _ [] [] -> c Stack _ [] [] -> c
Stack t [] (x:rs) -> Stack x [] (t:rs) Stack t [] (x:rs) -> Stack x [] (t:rs)

View File

@ -46,7 +46,7 @@ import qualified Operations as O
-- Nothing if all workspaces are in use. Function searches currently -- Nothing if all workspaces are in use. Function searches currently
-- focused workspace, other visible workspaces (when in Xinerama) and -- focused workspace, other visible workspaces (when in Xinerama) and
-- hidden workspaces in this order. -- hidden workspaces in this order.
findEmptyWorkspace :: StackSet i a s -> Maybe (Workspace i a) findEmptyWorkspace :: StackSet i a s sd -> Maybe (Workspace i a)
findEmptyWorkspace = find (isNothing . stack) . allWorkspaces findEmptyWorkspace = find (isNothing . stack) . allWorkspaces
where where
allWorkspaces ss = (workspace . current) ss : allWorkspaces ss = (workspace . current) ss :

15
Warp.hs
View File

@ -22,11 +22,13 @@ module XMonadContrib.Warp (
import Data.Ratio import Data.Ratio
import Data.Maybe import Data.Maybe
import Data.List
import Control.Monad.RWS import Control.Monad.RWS
import Graphics.X11.Xlib import Graphics.X11.Xlib
import Graphics.X11.Xlib.Extras import Graphics.X11.Xlib.Extras
import Operations import Operations
import XMonad import XMonad
import StackSet as W
{- $usage {- $usage
This can be used to make a keybinding that warps the pointer to a given This can be used to make a keybinding that warps the pointer to a given
@ -59,10 +61,11 @@ warpToWindow h v =
wa <- io $ getWindowAttributes d w wa <- io $ getWindowAttributes d w
warp w (fraction h (wa_width wa)) (fraction v (wa_height wa)) warp w (fraction h (wa_width wa)) (fraction v (wa_height wa))
warpToScreen :: Int -> Rational -> Rational -> X () warpToScreen :: ScreenId -> Rational -> Rational -> X ()
warpToScreen n h v = do warpToScreen n h v = do
xScreens <- gets xineScreens root <- asks theRoot
root <- asks theRoot (StackSet {current = x, visible = xs}) <- gets windowset
whenJust (ix n xScreens) $ \r -> whenJust (fmap (screenRect . W.screenDetail) . find ((n==) . W.screen) $ x : xs)
warp root (rect_x r + fraction h (rect_width r)) $ \r ->
(rect_y r + fraction v (rect_height r)) warp root (rect_x r + fraction h (rect_width r))
(rect_y r + fraction v (rect_height r))