mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
In a multi-head setup, move windows with a non-zero position upon creation to the right workspace.
Useful in a dual-head setup: Looks at the requested geometry of new windows and moves them to the workspace of the non-focused screen if necessary.
This commit is contained in:
parent
3bc9c11d97
commit
41b58ed499
65
XMonad/Hooks/WorkspaceByPos.hs
Normal file
65
XMonad/Hooks/WorkspaceByPos.hs
Normal file
@ -0,0 +1,65 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- |
|
||||
-- Module : XMonad.Hooks.WorkspaceByPos
|
||||
-- Copyright : (c) Jan Vornberger 2009
|
||||
-- License : BSD3-style (see LICENSE)
|
||||
--
|
||||
-- Maintainer : jan.vornberger@informatik.uni-oldenburg.de
|
||||
-- Stability : unstable
|
||||
-- Portability : not portable
|
||||
--
|
||||
-- Useful in a dual-head setup: Looks at the requested geometry of
|
||||
-- new windows and moves them to the workspace of the non-focused
|
||||
-- screen if necessary.
|
||||
--
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
module XMonad.Hooks.WorkspaceByPos (
|
||||
-- * Usage
|
||||
-- $usage
|
||||
workspaceByPos
|
||||
) where
|
||||
|
||||
import XMonad
|
||||
import qualified XMonad.StackSet as W
|
||||
|
||||
import Data.Maybe
|
||||
import Control.Applicative((<$>))
|
||||
|
||||
-- $usage
|
||||
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
|
||||
--
|
||||
-- > import XMonad.Hooks.WorkspaceByPos
|
||||
-- >
|
||||
-- > myManageHook = workspaceByPos <+> manageHook defaultConfig
|
||||
-- >
|
||||
-- > main = xmonad defaultConfig { manageHook = myManageHook }
|
||||
|
||||
workspaceByPos :: ManageHook
|
||||
workspaceByPos = ask >>= \w -> do
|
||||
b <- liftX $ needsMoving w
|
||||
case b of
|
||||
Nothing -> idHook
|
||||
Just wkspc -> doShift wkspc
|
||||
|
||||
needsMoving :: Window -> X (Maybe WorkspaceId)
|
||||
needsMoving w = withDisplay $ \d -> do
|
||||
-- only relocate windows with non-zero position
|
||||
wa <- io $ getWindowAttributes d w
|
||||
if ((wa_x wa) == 0) && ((wa_y wa) == 0)
|
||||
then return Nothing
|
||||
else do
|
||||
ws <- gets windowset
|
||||
sc <- fromMaybe (W.current ws)
|
||||
<$> pointScreen (fi $ wa_x wa) (fi $ wa_y wa)
|
||||
maybeWkspc <- screenWorkspace (W.screen sc)
|
||||
case maybeWkspc of
|
||||
Nothing -> return Nothing
|
||||
Just wkspc -> do
|
||||
let currentWksp = W.currentTag ws
|
||||
if currentWksp == wkspc
|
||||
then return Nothing
|
||||
else return (Just wkspc)
|
||||
|
||||
fi :: (Integral a, Num b) => a -> b
|
||||
fi = fromIntegral
|
@ -129,6 +129,7 @@ library
|
||||
XMonad.Hooks.SetWMName
|
||||
XMonad.Hooks.ServerMode
|
||||
XMonad.Hooks.UrgencyHook
|
||||
XMonad.Hooks.WorkspaceByPos
|
||||
XMonad.Hooks.XPropManage
|
||||
XMonad.Layout.Accordion
|
||||
XMonad.Layout.AutoMaster
|
||||
|
Loading…
x
Reference in New Issue
Block a user