make tabbed work nicely with LayoutCombinators and WindowNavigation.

The problem is that WindowNavigation assumes all windows are navigable, and
it was getting confused by decorations.  With a bit of work, we can
decorate windows *after* combining layouts just fine.
This commit is contained in:
David Roundy
2008-02-05 20:23:43 +00:00
parent f804991d22
commit 5df47fcfc5
2 changed files with 23 additions and 14 deletions

View File

@@ -6,7 +6,7 @@
-- --
------------------------------------------------------------------------ ------------------------------------------------------------------------
module XMonad.Config.Droundy ( config, mytab ) where module XMonad.Config.Droundy ( config ) where
--import Control.Monad.State ( modify ) --import Control.Monad.State ( modify )
@@ -21,6 +21,7 @@ import System.Exit
-- % Extension-provided imports -- % Extension-provided imports
import XMonad.Layout.Simplest
import XMonad.Layout.Tabbed import XMonad.Layout.Tabbed
import XMonad.Layout.Combo import XMonad.Layout.Combo
import XMonad.Layout.Mosaic import XMonad.Layout.Mosaic
@@ -32,6 +33,7 @@ import XMonad.Layout.WindowNavigation
import XMonad.Layout.NoBorders import XMonad.Layout.NoBorders
import XMonad.Layout.WorkspaceDir import XMonad.Layout.WorkspaceDir
import XMonad.Layout.ToggleLayouts import XMonad.Layout.ToggleLayouts
import XMonad.Layout.ShowWName ( showWName )
import XMonad.Prompt import XMonad.Prompt
import XMonad.Prompt.Layout import XMonad.Prompt.Layout
@@ -132,13 +134,14 @@ config = -- withUrgencyHook FocusUrgencyHook $
defaultConfig defaultConfig
{ borderWidth = 1 -- Width of the window border in pixels. { borderWidth = 1 -- Width of the window border in pixels.
, XMonad.workspaces = ["1:mutt","2:iceweasel"] , XMonad.workspaces = ["1:mutt","2:iceweasel"]
, layoutHook = workspaceDir "~" $ windowNavigation $ , layoutHook = addTabs CustomShrink defaultTheme $ showWName $ workspaceDir "~" $
windowNavigation $
toggleLayouts (noBorders Full) $ avoidStruts $ toggleLayouts (noBorders Full) $ avoidStruts $
named "tabbed" (noBorders mytab) ||| named "tabbed" (noBorders Simplest) |||
named "xclock" (mytab ****//* combineTwo Square mytab mytab) ||| named "xclock" (Simplest ****//* combineTwo Square Simplest Simplest) |||
named "three" (mytab **//* mytab *//* combineTwo Square mytab mytab) ||| named "three" (Simplest **//* Simplest *//* combineTwo Square Simplest Simplest) |||
named "widescreen" ((mytab *||* mytab) named "widescreen" ((Simplest *||* Simplest)
****//* combineTwo Square mytab mytab) -- ||| ****//* combineTwo Square Simplest Simplest) -- |||
--mosaic 0.25 0.5 --mosaic 0.25 0.5
, manageHook = manageHook defaultConfig <+> manageDocks -- add panel-handling , manageHook = manageHook defaultConfig <+> manageDocks -- add panel-handling
, logHook = ewmhDesktopsLogHook -- actually, no logging here, just other stuff , logHook = ewmhDesktopsLogHook -- actually, no logging here, just other stuff
@@ -149,8 +152,6 @@ config = -- withUrgencyHook FocusUrgencyHook $
, XMonad.keys = keys , XMonad.keys = keys
} }
mytab = tabbed CustomShrink defaultTheme
instance Shrinker CustomShrink where instance Shrinker CustomShrink where
shrinkIt shr s | Just s' <- dropFromHead " " s = shrinkIt shr s' shrinkIt shr s | Just s' <- dropFromHead " " s = shrinkIt shr s'
shrinkIt shr s | Just s' <- dropFromTail " " s = shrinkIt shr s' shrinkIt shr s | Just s' <- dropFromTail " " s = shrinkIt shr s'

View File

@@ -17,7 +17,7 @@
module XMonad.Layout.Tabbed module XMonad.Layout.Tabbed
( -- * Usage: ( -- * Usage:
-- $usage -- $usage
tabbed tabbed, addTabs
, Theme (..) , Theme (..)
, defaultTheme , defaultTheme
, TabbedDecoration (..) , TabbedDecoration (..)
@@ -61,13 +61,21 @@ tabbed :: (Eq a, Shrinker s) => s -> Theme
-> ModifiedLayout (Decoration TabbedDecoration s) Simplest a -> ModifiedLayout (Decoration TabbedDecoration s) Simplest a
tabbed s c = decoration s c Tabbed Simplest tabbed s c = decoration s c Tabbed Simplest
addTabs :: (Eq a, LayoutClass l a, Shrinker s) => s -> Theme -> l a
-> ModifiedLayout (Decoration TabbedDecoration s) l a
addTabs s c l = decoration s c Tabbed l
data TabbedDecoration a = Tabbed deriving (Read, Show) data TabbedDecoration a = Tabbed deriving (Read, Show)
instance Eq a => DecorationStyle TabbedDecoration a where instance Eq a => DecorationStyle TabbedDecoration a where
describeDeco _ = "Tabbed" describeDeco _ = "Tabbed"
decorateFirst _ = False decorateFirst _ = True
pureDecoration _ _ ht (Rectangle x y wh _) s wrs (w,_) = Just $ Rectangle nx y nwh (fi ht) pureDecoration _ _ ht _ s wrs (w,r@(Rectangle x y wh _)) =
where nwh = wh `div` max 1 (fi $ length wrs) if length wrs' <= 1 then Nothing
nx = case w `elemIndex` (S.integrate s) of else Just $ Rectangle nx y nwh (fi ht)
where wrs' = filter ((==r) . snd) wrs
ws = map fst wrs'
nwh = wh `div` max 1 (fi $ length wrs')
nx = case elemIndex w $ filter (`elem` ws) (S.integrate s) of
Just i -> x + (fi nwh * fi i) Just i -> x + (fi nwh * fi i)
Nothing -> x Nothing -> x