diff options
author | Jason Creighton <jcreigh@gmail.com> | 2007-06-28 04:50:23 +0200 |
---|---|---|
committer | Jason Creighton <jcreigh@gmail.com> | 2007-06-28 04:50:23 +0200 |
commit | 2ea97e792f3584981ea565ec960d75a0568665f5 (patch) | |
tree | f321308c94fc3bc509fa4468aa39161dabd0360b | |
parent | ab16766e1da5b7ef2325b6b7f851e570c29cc682 (diff) | |
download | metatile-2ea97e792f3584981ea565ec960d75a0568665f5.tar metatile-2ea97e792f3584981ea565ec960d75a0568665f5.zip |
Change a window's workspace when dragging across screens (closes #30)
darcs-hash:20070628025023-b9aa7-54e0930487ac4a8f085b6d78ad783ed9b40bc65f
-rw-r--r-- | Operations.hs | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/Operations.hs b/Operations.hs index c747467..2bb348a 100644 --- a/Operations.hs +++ b/Operations.hs @@ -21,7 +21,7 @@ import qualified StackSet as W import {-# SOURCE #-} Config (borderWidth,logHook,numlockMask) import Data.Maybe -import Data.List (genericIndex, nub, (\\)) +import Data.List (genericIndex, nub, (\\), findIndex) import Data.Bits ((.|.), (.&.), complement) import Data.Ratio import qualified Data.Map as M @@ -476,16 +476,26 @@ sink = windows . W.sink -- | Make a tiled window floating, using its suggested rectangle float :: Window -> X () float w = withDisplay $ \d -> do - xinesc <- gets xineScreens - sc <- (genericIndex xinesc . W.screen . W.current) `liftM` gets windowset - wa <- io $ getWindowAttributes d w - let bw = fi . wa_border_width $ wa - windows $ W.float w + XState { xineScreens = xinesc, windowset = ws } <- get + wa <- io $ getWindowAttributes d w + + let sid = fromMaybe (W.screen . W.current $ ws) (fmap fi $ findIndex (pointWithin (fi (wa_x wa)) (fi (wa_y wa))) xinesc) + sc = genericIndex xinesc sid + bw = fi . wa_border_width $ wa + + wid <- screenWorkspace sid + + windows $ W.shift wid . W.focusWindow w . W.float w (W.RationalRect ((fi (wa_x wa) - fi (rect_x sc)) % fi (rect_width sc)) ((fi (wa_y wa) - fi (rect_y sc)) % fi (rect_height sc)) (fi (wa_width wa + bw*2) % fi (rect_width sc)) (fi (wa_height wa + bw*2) % fi (rect_height sc))) where fi x = fromIntegral x + pointWithin :: Integer -> Integer -> Rectangle -> Bool + pointWithin x y r = x >= fi (rect_x r) && + x < fi (rect_x r) + fi (rect_width r) && + y >= fi (rect_y r) && + y < fi (rect_y r) + fi (rect_height r) -- --------------------------------------------------------------------- -- Mouse handling |