mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-11 18:22:16 -07:00
Generalises modWorkspace to take any layout-transforming function
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.
This commit is contained in:
@@ -44,7 +44,8 @@ import Data.Maybe (fromMaybe)
|
|||||||
-- Note that @l1@, @l2@, and @l3@ can be arbitrarily complicated
|
-- Note that @l1@, @l2@, and @l3@ can be arbitrarily complicated
|
||||||
-- layouts, e.g. @(Full ||| smartBorders $ tabbed shrinkText
|
-- layouts, e.g. @(Full ||| smartBorders $ tabbed shrinkText
|
||||||
-- defaultTConf ||| ...)@, and @m1@ can be any layout modifier, i.e. a
|
-- 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
|
-- In another scenario, suppose you wanted to have layouts A, B, and C
|
||||||
-- available on all workspaces, except that on workspace foo you want
|
-- 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
|
-> (l1 a) -- ^ layout to use on matched workspaces
|
||||||
-> (l2 a) -- ^ layout to use everywhere else
|
-> (l2 a) -- ^ layout to use everywhere else
|
||||||
-> PerWorkspace l1 l2 a
|
-> 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
|
-- | Specify a layout modifier to apply to a particular workspace; layouts
|
||||||
-- on all other workspaces will remain unmodified.
|
-- on all other workspaces will remain unmodified.
|
||||||
modWorkspace :: (LayoutClass l a)
|
modWorkspace :: (LayoutClass l1 a, LayoutClass l2 a)
|
||||||
=> WorkspaceId -- ^ tag of the workspace to match
|
=> WorkspaceId -- ^ tag of the workspace to match
|
||||||
-> (l a -> ModifiedLayout lm l a) -- ^ the modifier to apply on the matching workspace
|
-> (l2 a -> l1 a) -- ^ the modifier to apply on the matching workspace
|
||||||
-> l a -- ^ the base layout
|
-> l2 a -- ^ the base layout
|
||||||
-> PerWorkspace (ModifiedLayout lm l) l a
|
-> PerWorkspace l1 l2 a
|
||||||
modWorkspace wsId = modWorkspaces [wsId]
|
modWorkspace wsId = modWorkspaces [wsId]
|
||||||
|
|
||||||
-- | Specify a layout modifier to apply to a particular set of
|
-- | Specify a layout modifier to apply to a particular set of
|
||||||
-- workspaces; layouts on all other workspaces will remain
|
-- workspaces; layouts on all other workspaces will remain
|
||||||
-- unmodified.
|
-- unmodified.
|
||||||
modWorkspaces :: (LayoutClass l a)
|
modWorkspaces :: (LayoutClass l1 a, LayoutClass l2 a)
|
||||||
=> [WorkspaceId] -- ^ tags of the workspaces to match
|
=> [WorkspaceId] -- ^ tags of the workspaces to match
|
||||||
-> (l a -> ModifiedLayout lm l a) -- ^ the modifier to apply on the matching workspaces
|
-> (l2 a -> l1 a) -- ^ the modifier to apply on the matching workspaces
|
||||||
-> l a -- ^ the base layout
|
-> l2 a -- ^ the base layout
|
||||||
-> PerWorkspace (ModifiedLayout lm l) l a
|
-> PerWorkspace l1 l2 a
|
||||||
modWorkspaces wsIds f l = PerWorkspace wsIds False (f l) l
|
modWorkspaces wsIds f l = PerWorkspace wsIds False (f l) l
|
||||||
|
|
||||||
-- | Structure for representing a workspace-specific layout along with
|
-- | Structure for representing a workspace-specific layout along with
|
||||||
|
Reference in New Issue
Block a user