mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
New module: XMonad.Hooks.BorderPerWindow
This commit is contained in:
parent
a981832aaf
commit
95b37a9ab2
@ -16,6 +16,11 @@
|
|||||||
Put XMonad actions in the queue to be executed every time the
|
Put XMonad actions in the queue to be executed every time the
|
||||||
`logHook` (or, alternatively, a hook of your choice) runs.
|
`logHook` (or, alternatively, a hook of your choice) runs.
|
||||||
|
|
||||||
|
* `XMonad.Hooks.BorderPerWindow`
|
||||||
|
|
||||||
|
While XMonad provides config to set all window borders at the same
|
||||||
|
width, this extension defines and sets border width for each window.
|
||||||
|
|
||||||
### Bug Fixes and Minor Changes
|
### Bug Fixes and Minor Changes
|
||||||
|
|
||||||
* `XMonad.Prompt`
|
* `XMonad.Prompt`
|
||||||
|
78
XMonad/Hooks/BorderPerWindow.hs
Normal file
78
XMonad/Hooks/BorderPerWindow.hs
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
-----------------------------------------------------------------------------
|
||||||
|
-- |
|
||||||
|
-- Module : XMonad.Hooks.BorderPerWindow
|
||||||
|
-- Description : Set border width for each window in all layouts.
|
||||||
|
-- Copyright : (c) 2021 Xiaokui Shu
|
||||||
|
-- License : BSD-style (see LICENSE)
|
||||||
|
--
|
||||||
|
-- Maintainer : subbyte@gmail.com
|
||||||
|
-- Stability : unstable
|
||||||
|
-- Portability : unportable
|
||||||
|
--
|
||||||
|
-- Want to customize border width, for each window on all layouts? Want
|
||||||
|
-- specific window have no border on all layouts? Try this.
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
module XMonad.Hooks.BorderPerWindow ( -- * Usage
|
||||||
|
-- $usage
|
||||||
|
defineBorderWidth
|
||||||
|
, actionQueue
|
||||||
|
|
||||||
|
-- * Design Considerations
|
||||||
|
-- $design
|
||||||
|
) where
|
||||||
|
|
||||||
|
|
||||||
|
import Graphics.X11.Xlib (Dimension)
|
||||||
|
import XMonad
|
||||||
|
import XMonad.Util.ActionQueue (enqueue, actionQueue)
|
||||||
|
|
||||||
|
-- $usage
|
||||||
|
--
|
||||||
|
-- To use this module, first import it
|
||||||
|
--
|
||||||
|
-- > import XMonad.Hooks.BorderPerWindow (defineBorderWidth, actionQueue)
|
||||||
|
--
|
||||||
|
-- Then specify which window to customize the border of in your
|
||||||
|
-- @manageHook@:
|
||||||
|
--
|
||||||
|
-- > myManageHook :: ManageHook
|
||||||
|
-- > myManageHook = composeAll
|
||||||
|
-- > [ className =? "firefox" --> defineWindowWidth 0
|
||||||
|
-- > , className =? "Chromium" --> defineWindowWidth 0
|
||||||
|
-- > , isDialog --> defineWindowWidth 8
|
||||||
|
-- > ]
|
||||||
|
--
|
||||||
|
-- Finally, add the 'actionQueue' combinator and @myManageHook@ to your
|
||||||
|
-- config:
|
||||||
|
--
|
||||||
|
-- > main = xmonad $ actionQueue $ def
|
||||||
|
-- > { ...
|
||||||
|
-- > , manageHook = myManageHook
|
||||||
|
-- > , ...
|
||||||
|
-- > }
|
||||||
|
--
|
||||||
|
-- Note that this module is incompatible with other ways of changing
|
||||||
|
-- borders, like "XMonad.Layout.NoBorders". This is because we are
|
||||||
|
-- changing the border exactly /once/ (when the window first appears)
|
||||||
|
-- and not every time some condition is satisfied.
|
||||||
|
|
||||||
|
-- $design
|
||||||
|
--
|
||||||
|
-- 1. Keep it simple. Since the extension does not aim to change border setting
|
||||||
|
-- when layout changes, only execute the border setting function once to
|
||||||
|
-- avoid potential window flashing/jumping/scaling.
|
||||||
|
--
|
||||||
|
-- 2. The 'ManageHook' eDSL is a nice language for specifying windows. Let's
|
||||||
|
-- build on top of it and use it to specify window to define border.
|
||||||
|
|
||||||
|
defineBorderWidth :: Dimension -> ManageHook
|
||||||
|
defineBorderWidth bw = do
|
||||||
|
w <- ask
|
||||||
|
liftX . enqueue $ updateBorderWidth w bw
|
||||||
|
idHook
|
||||||
|
|
||||||
|
updateBorderWidth :: Window -> Dimension -> X ()
|
||||||
|
updateBorderWidth w bw = do
|
||||||
|
withDisplay $ \d -> io $ setWindowBorderWidth d w bw
|
||||||
|
refresh
|
@ -168,6 +168,7 @@ library
|
|||||||
XMonad.Doc.Configuring
|
XMonad.Doc.Configuring
|
||||||
XMonad.Doc.Developing
|
XMonad.Doc.Developing
|
||||||
XMonad.Doc.Extending
|
XMonad.Doc.Extending
|
||||||
|
XMonad.Hooks.BorderPerWindow
|
||||||
XMonad.Hooks.CurrentWorkspaceOnTop
|
XMonad.Hooks.CurrentWorkspaceOnTop
|
||||||
XMonad.Hooks.DebugEvents
|
XMonad.Hooks.DebugEvents
|
||||||
XMonad.Hooks.DebugKeyEvents
|
XMonad.Hooks.DebugKeyEvents
|
||||||
|
Loading…
x
Reference in New Issue
Block a user