From 5fbfcaada0fd827e157bad7d49a6992039127df8 Mon Sep 17 00:00:00 2001 From: slotThe Date: Wed, 24 Mar 2021 09:52:41 +0100 Subject: [PATCH 1/4] X.L.Magnifier: Implement magnifier['] in term of magnifiercz['] --- XMonad/Layout/Magnifier.hs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/XMonad/Layout/Magnifier.hs b/XMonad/Layout/Magnifier.hs index 0059dbca..5d2590d8 100644 --- a/XMonad/Layout/Magnifier.hs +++ b/XMonad/Layout/Magnifier.hs @@ -84,7 +84,7 @@ import XMonad.Util.XUtils -- | Increase the size of the window that has focus magnifier :: l a -> ModifiedLayout Magnifier l a -magnifier = ModifiedLayout (Mag 1 (1.5,1.5) On All) +magnifier = magnifiercz 1.5 -- | Change the size of the window that has focus by a custom zoom magnifiercz :: Rational -> l a -> ModifiedLayout Magnifier l a @@ -93,7 +93,12 @@ magnifiercz cz = ModifiedLayout (Mag 1 (fromRational cz, fromRational cz) On All -- | Increase the size of the window that has focus, unless if it is one of the -- master windows. magnifier' :: l a -> ModifiedLayout Magnifier l a -magnifier' = ModifiedLayout (Mag 1 (1.5,1.5) On NoMaster) +magnifier' = magnifiercz' 1.5 + +-- | Increase the size of the window that has focus by a custom zoom, +-- unless if it is one of the the master windows. +magnifiercz' :: Rational -> l a -> ModifiedLayout Magnifier l a +magnifiercz' cz = ModifiedLayout (Mag 1 (fromRational cz, fromRational cz) On NoMaster) -- | Magnifier that defaults to Off magnifierOff :: l a -> ModifiedLayout Magnifier l a @@ -103,11 +108,6 @@ magnifierOff = ModifiedLayout (Mag 1 (1.5,1.5) Off All) maxMagnifierOff :: l a -> ModifiedLayout Magnifier l a maxMagnifierOff = ModifiedLayout (Mag 1 (1000,1000) Off All) --- | Increase the size of the window that has focus by a custom zoom, --- unless if it is one of the the master windows. -magnifiercz' :: Rational -> l a -> ModifiedLayout Magnifier l a -magnifiercz' cz = ModifiedLayout (Mag 1 (fromRational cz, fromRational cz) On NoMaster) - -- | A magnifier that greatly magnifies just the vertical direction maximizeVertical :: l a -> ModifiedLayout Magnifier l a maximizeVertical = ModifiedLayout (Mag 1 (1,1000) Off All) @@ -123,7 +123,7 @@ data MagnifyMaster = All | NoMaster deriving (Read, Show) instance LayoutModifier Magnifier Window where redoLayout (Mag _ z On All ) r (Just s) wrs = applyMagnifier z r s wrs redoLayout (Mag n z On NoMaster) r (Just s) wrs = unlessMaster n (applyMagnifier z) r s wrs - redoLayout _ _ _ wrs = return (wrs, Nothing) + redoLayout _ _ _ wrs = return (wrs, Nothing) handleMess (Mag n z On t) m | Just MagnifyMore <- fromMessage m = return . Just $ Mag n (z `addto` 0.1 ) On t @@ -164,7 +164,7 @@ magnify (zoomx,zoomy) (Rectangle x y w h) = Rectangle x' y' w' h' fit :: Rectangle -> Rectangle -> Rectangle fit (Rectangle sx sy sw sh) (Rectangle x y w h) = Rectangle x' y' w' h' - where x' = max sx (x - (max 0 (x + fi w - sx - fi sw))) - y' = max sy (y - (max 0 (y + fi h - sy - fi sh))) + where x' = max sx (x - max 0 (x + fi w - sx - fi sw)) + y' = max sy (y - max 0 (y + fi h - sy - fi sh)) w' = min sw w h' = min sh h From b49ebdf2e0981d3e645034b47fbbacba56823b9d Mon Sep 17 00:00:00 2001 From: slotThe Date: Wed, 24 Mar 2021 09:59:29 +0100 Subject: [PATCH 2/4] X.L.Magnifier: Add magnifierczOff and magnifierczOff' Instead of exporting the internal constructor, define a few more functions for people who like their magnifier to start of in the Off position. Closes: https://github.com/xmonad/xmonad-contrib/issues/168 --- XMonad/Layout/Magnifier.hs | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/XMonad/Layout/Magnifier.hs b/XMonad/Layout/Magnifier.hs index 5d2590d8..c779725c 100644 --- a/XMonad/Layout/Magnifier.hs +++ b/XMonad/Layout/Magnifier.hs @@ -20,13 +20,21 @@ module XMonad.Layout.Magnifier ( -- * Usage -- $usage + + -- * Magnify Everything magnifier, - magnifier', magnifierOff, - maxMagnifierOff, magnifiercz, - magnifiercz', + magnifierczOff, + maxMagnifierOff, maximizeVertical, + + -- * Don't Magnify the Master Window + magnifier', + magnifiercz', + magnifierczOff', + + -- * Messages and Types MagnifyMsg (..), Magnifier, ) where @@ -102,11 +110,20 @@ magnifiercz' cz = ModifiedLayout (Mag 1 (fromRational cz, fromRational cz) On No -- | Magnifier that defaults to Off magnifierOff :: l a -> ModifiedLayout Magnifier l a -magnifierOff = ModifiedLayout (Mag 1 (1.5,1.5) Off All) +magnifierOff = magnifierczOff 1.5 --- | A magnifier that greatly magnifies with defaults to Off +-- | A magnifier that greatly magnifies the focused window; defaults to +-- @Off@. maxMagnifierOff :: l a -> ModifiedLayout Magnifier l a -maxMagnifierOff = ModifiedLayout (Mag 1 (1000,1000) Off All) +maxMagnifierOff = magnifierczOff 1000 + +-- | Like 'magnifiercz', but default to @Off@. +magnifierczOff :: Rational -> l a -> ModifiedLayout Magnifier l a +magnifierczOff cz = ModifiedLayout (Mag 1 (fromRational cz, fromRational cz) Off All) + +-- | Like 'magnifiercz'', but default to @Off@. +magnifierczOff' :: Rational -> l a -> ModifiedLayout Magnifier l a +magnifierczOff' cz = ModifiedLayout (Mag 1 (fromRational cz, fromRational cz) Off NoMaster) -- | A magnifier that greatly magnifies just the vertical direction maximizeVertical :: l a -> ModifiedLayout Magnifier l a From bb205e92051de531c6c8b7eb1d692779969b6710 Mon Sep 17 00:00:00 2001 From: slotThe Date: Wed, 24 Mar 2021 10:04:26 +0100 Subject: [PATCH 3/4] X.L.Magnifier: Strictify and document `Magnifier` type --- XMonad/Layout/Magnifier.hs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/XMonad/Layout/Magnifier.hs b/XMonad/Layout/Magnifier.hs index c779725c..695beb7a 100644 --- a/XMonad/Layout/Magnifier.hs +++ b/XMonad/Layout/Magnifier.hs @@ -132,7 +132,21 @@ maximizeVertical = ModifiedLayout (Mag 1 (1,1000) Off All) data MagnifyMsg = MagnifyMore | MagnifyLess | ToggleOn | ToggleOff | Toggle deriving ( Typeable ) instance Message MagnifyMsg -data Magnifier a = Mag !Int (Double,Double) Toggle MagnifyMaster deriving (Read, Show) +-- | The type for magnifying a given type; do note that the given type +-- @a@ is a phantom type. +data Magnifier a = Mag !Int !(Double, Double) !Toggle !MagnifyMaster + deriving (Read, Show) +-- The constructors are documented here due to a bug in haddock with GHC +-- 8.4.x (TODO: Change this when we bump the GHC version lower bound). +-- Since they are an implementation detail and are thus subject to +-- change, this is not top-level documentation. +-- +-- - Int: How many windows there are in the master pane. +-- - (Double, Double): Zoom-factor in the @x@ and @y@ direction; the +-- window's width and height will be multiplied by these amounts when +-- magnifying. +-- - Toggle: Whether to magnify windows at all. +-- - MagnifyMaster: Magnify only the master, or all windows. data Toggle = On | Off deriving (Read, Show) data MagnifyMaster = All | NoMaster deriving (Read, Show) From 3aadb487ed7e93bd49d61c300c7ee3dfae18570e Mon Sep 17 00:00:00 2001 From: slotThe Date: Wed, 24 Mar 2021 10:10:11 +0100 Subject: [PATCH 4/4] Update CHANGES.md --- CHANGES.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index dcaa76e5..febb5ee2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -487,6 +487,11 @@ - Fixed a bug that prevented changing focus on inactive workspaces. + * `XMonad.Layout.Magnifier` + + - Added `magnifierczOff` and `magnifierczOff'` for custom-size + magnifiers that start out with magnifying disabled. + ## 0.16 ### Breaking Changes