diff options
author | gopsychonauts <gopsychonauts@gmail.com> | 2013-05-01 17:14:25 +0200 |
---|---|---|
committer | gopsychonauts <gopsychonauts@gmail.com> | 2013-05-01 17:14:25 +0200 |
commit | 6e183515ab56b0a767c50dfd94840453187d69ca (patch) | |
tree | 460b059310b55e452c7b67c712d3c190ff5348b5 /XMonad | |
parent | efecf917cb429577e566fdebff9431e8b4a52e4d (diff) | |
download | XMonadContrib-6e183515ab56b0a767c50dfd94840453187d69ca.tar.gz XMonadContrib-6e183515ab56b0a767c50dfd94840453187d69ca.tar.xz XMonadContrib-6e183515ab56b0a767c50dfd94840453187d69ca.zip |
Generalises modWorkspace to take any layout-transforming function
Ignore-this: 28c7dc1f6216bb1ebdffef5434ccbcbd
modWorkspace already was capable of modifying the layout with an arbitrary
layout -> layout function, but its original type restricted it such that it
could only apply a single LayoutModifier; this was often inconvenient, as for
example it was not possible simply to compose LayoutModifiers for use with
modWorkspace.
This patch also reimplements onWorkspaces in terms of modWorkspaces, since with
the latter's less restrictive type this is now possible.
darcs-hash:20130501151425-1e6bb-1fc7e26a39fab65bb2bf387db0052f19e7c619fc.gz
Diffstat (limited to 'XMonad')
-rw-r--r-- | XMonad/Layout/PerWorkspace.hs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/XMonad/Layout/PerWorkspace.hs b/XMonad/Layout/PerWorkspace.hs index ff8ae3d..4108138 100644 --- a/XMonad/Layout/PerWorkspace.hs +++ b/XMonad/Layout/PerWorkspace.hs @@ -44,7 +44,8 @@ import Data.Maybe (fromMaybe) -- Note that @l1@, @l2@, and @l3@ can be arbitrarily complicated -- layouts, e.g. @(Full ||| smartBorders $ tabbed shrinkText -- defaultTConf ||| ...)@, and @m1@ can be any layout modifier, i.e. a --- function of type @(l a -> ModifiedLayout lm l a)@. +-- function of type @(l a -> ModifiedLayout lm l a)@. (In fact, @m1@ can be any +-- function @(LayoutClass l a, LayoutClass l' a) => l a -> l' a@.) -- -- In another scenario, suppose you wanted to have layouts A, B, and C -- available on all workspaces, except that on workspace foo you want @@ -69,25 +70,25 @@ onWorkspaces :: (LayoutClass l1 a, LayoutClass l2 a) -> (l1 a) -- ^ layout to use on matched workspaces -> (l2 a) -- ^ layout to use everywhere else -> PerWorkspace l1 l2 a -onWorkspaces wsIds l1 l2 = PerWorkspace wsIds False l1 l2 +onWorkspaces wsIds = modWorkspaces wsIds . const -- | Specify a layout modifier to apply to a particular workspace; layouts -- on all other workspaces will remain unmodified. -modWorkspace :: (LayoutClass l a) - => WorkspaceId -- ^ tag of the workspace to match - -> (l a -> ModifiedLayout lm l a) -- ^ the modifier to apply on the matching workspace - -> l a -- ^ the base layout - -> PerWorkspace (ModifiedLayout lm l) l a +modWorkspace :: (LayoutClass l1 a, LayoutClass l2 a) + => WorkspaceId -- ^ tag of the workspace to match + -> (l2 a -> l1 a) -- ^ the modifier to apply on the matching workspace + -> l2 a -- ^ the base layout + -> PerWorkspace l1 l2 a modWorkspace wsId = modWorkspaces [wsId] -- | Specify a layout modifier to apply to a particular set of -- workspaces; layouts on all other workspaces will remain -- unmodified. -modWorkspaces :: (LayoutClass l a) - => [WorkspaceId] -- ^ tags of the workspaces to match - -> (l a -> ModifiedLayout lm l a) -- ^ the modifier to apply on the matching workspaces - -> l a -- ^ the base layout - -> PerWorkspace (ModifiedLayout lm l) l a +modWorkspaces :: (LayoutClass l1 a, LayoutClass l2 a) + => [WorkspaceId] -- ^ tags of the workspaces to match + -> (l2 a -> l1 a) -- ^ the modifier to apply on the matching workspaces + -> l2 a -- ^ the base layout + -> PerWorkspace l1 l2 a modWorkspaces wsIds f l = PerWorkspace wsIds False (f l) l -- | Structure for representing a workspace-specific layout along with |