mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
XMonad.Hooks.ScreenCorners: Add support for edges
Previously only corners are supported, now support for edges are added. This is similar to Hot Edge shell extension in GNOME.
This commit is contained in:
parent
7109b0ce8f
commit
077b4ff34b
@ -75,6 +75,11 @@
|
|||||||
- Added `visualSubmapSorted` to enable sorting of the keymap
|
- Added `visualSubmapSorted` to enable sorting of the keymap
|
||||||
descriptions.
|
descriptions.
|
||||||
|
|
||||||
|
* `XMonad.Hooks.ScreenCorners`
|
||||||
|
|
||||||
|
- Added screen edge support with `SCTop`, `SCBottom`, `SCLeft` and
|
||||||
|
`SCRight`. Now both corners and edges are supported.
|
||||||
|
|
||||||
### Other changes
|
### Other changes
|
||||||
|
|
||||||
## 0.18.0 (February 3, 2024)
|
## 0.18.0 (February 3, 2024)
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
-- |
|
-- |
|
||||||
-- Module : XMonad.Hooks.ScreenCorners
|
-- Module : XMonad.Hooks.ScreenCorners
|
||||||
-- Description : Run X () actions by touching the edge of your screen with your mouse.
|
-- Description : Run X () actions by touching the edge of your screen with your mouse.
|
||||||
-- Copyright : (c) 2009 Nils Schweinsberg, 2015 Evgeny Kurnevsky
|
-- Copyright : (c) 2009 Nils Schweinsberg, 2015 Evgeny Kurnevsky, 2024 Yuanle Song
|
||||||
-- License : BSD3-style (see LICENSE)
|
-- License : BSD3-style (see LICENSE)
|
||||||
--
|
--
|
||||||
-- Maintainer : Nils Schweinsberg <mail@n-sch.de>
|
-- Maintainer : Nils Schweinsberg <mail@n-sch.de>
|
||||||
@ -42,6 +42,10 @@ data ScreenCorner = SCUpperLeft
|
|||||||
| SCUpperRight
|
| SCUpperRight
|
||||||
| SCLowerLeft
|
| SCLowerLeft
|
||||||
| SCLowerRight
|
| SCLowerRight
|
||||||
|
| SCTop
|
||||||
|
| SCBottom
|
||||||
|
| SCLeft
|
||||||
|
| SCRight
|
||||||
deriving (Eq, Ord, Show)
|
deriving (Eq, Ord, Show)
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
@ -74,25 +78,49 @@ addScreenCorners = mapM_ (uncurry addScreenCorner)
|
|||||||
-- Xlib functions
|
-- Xlib functions
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- "Translate" a ScreenCorner to real (x,y) Positions
|
-- "Translate" a ScreenCorner to real (x,y) Positions with proper width and
|
||||||
|
-- height.
|
||||||
createWindowAt :: ScreenCorner -> X Window
|
createWindowAt :: ScreenCorner -> X Window
|
||||||
createWindowAt SCUpperLeft = createWindowAt' 0 0
|
createWindowAt SCUpperLeft = createWindowAt' 0 0 1 1
|
||||||
createWindowAt SCUpperRight = withDisplay $ \dpy ->
|
createWindowAt SCUpperRight = withDisplay $ \dpy ->
|
||||||
let w = displayWidth dpy (defaultScreen dpy) - 1
|
let w = displayWidth dpy (defaultScreen dpy) - 1
|
||||||
in createWindowAt' (fi w) 0
|
in createWindowAt' (fi w) 0 1 1
|
||||||
|
|
||||||
createWindowAt SCLowerLeft = withDisplay $ \dpy ->
|
createWindowAt SCLowerLeft = withDisplay $ \dpy ->
|
||||||
let h = displayHeight dpy (defaultScreen dpy) - 1
|
let h = displayHeight dpy (defaultScreen dpy) - 1
|
||||||
in createWindowAt' 0 (fi h)
|
in createWindowAt' 0 (fi h) 1 1
|
||||||
|
|
||||||
createWindowAt SCLowerRight = withDisplay $ \dpy ->
|
createWindowAt SCLowerRight = withDisplay $ \dpy ->
|
||||||
let w = displayWidth dpy (defaultScreen dpy) - 1
|
let w = displayWidth dpy (defaultScreen dpy) - 1
|
||||||
h = displayHeight dpy (defaultScreen dpy) - 1
|
h = displayHeight dpy (defaultScreen dpy) - 1
|
||||||
in createWindowAt' (fi w) (fi h)
|
in createWindowAt' (fi w) (fi h) 1 1
|
||||||
|
|
||||||
-- Create a new X window at a (x,y) Position
|
createWindowAt SCTop = withDisplay $ \dpy ->
|
||||||
createWindowAt' :: Position -> Position -> X Window
|
let w = displayWidth dpy (defaultScreen dpy) - 1
|
||||||
createWindowAt' x y = withDisplay $ \dpy -> io $ do
|
-- leave some gap so corner and edge can work nicely when they overlap
|
||||||
|
threshold = 150
|
||||||
|
in createWindowAt' threshold 0 (fi $ fi w - threshold * 2) 1
|
||||||
|
|
||||||
|
createWindowAt SCBottom = withDisplay $ \dpy ->
|
||||||
|
let w = displayWidth dpy (defaultScreen dpy) - 1
|
||||||
|
h = displayHeight dpy (defaultScreen dpy) - 1
|
||||||
|
threshold = 150
|
||||||
|
in createWindowAt' threshold (fi h) (fi $ fi w - threshold * 2) 1
|
||||||
|
|
||||||
|
createWindowAt SCLeft = withDisplay $ \dpy ->
|
||||||
|
let h = displayHeight dpy (defaultScreen dpy) - 1
|
||||||
|
threshold = 150
|
||||||
|
in createWindowAt' 0 threshold 1 (fi $ fi h - threshold * 2)
|
||||||
|
|
||||||
|
createWindowAt SCRight = withDisplay $ \dpy ->
|
||||||
|
let w = displayWidth dpy (defaultScreen dpy) - 1
|
||||||
|
h = displayHeight dpy (defaultScreen dpy) - 1
|
||||||
|
threshold = 150
|
||||||
|
in createWindowAt' (fi w) threshold 1 (fi $ fi h - threshold * 2)
|
||||||
|
|
||||||
|
-- Create a new X window at a (x,y) Position, with given width and height.
|
||||||
|
createWindowAt' :: Position -> Position -> Dimension -> Dimension -> X Window
|
||||||
|
createWindowAt' x y width height = withDisplay $ \dpy -> io $ do
|
||||||
|
|
||||||
rootw <- rootWindow dpy (defaultScreen dpy)
|
rootw <- rootWindow dpy (defaultScreen dpy)
|
||||||
|
|
||||||
@ -107,8 +135,8 @@ createWindowAt' x y = withDisplay $ \dpy -> io $ do
|
|||||||
rootw -- parent window
|
rootw -- parent window
|
||||||
x -- x
|
x -- x
|
||||||
y -- y
|
y -- y
|
||||||
1 -- width
|
width -- width
|
||||||
1 -- height
|
height -- height
|
||||||
0 -- border width
|
0 -- border width
|
||||||
0 -- depth
|
0 -- depth
|
||||||
inputOnly -- class
|
inputOnly -- class
|
||||||
@ -122,7 +150,6 @@ createWindowAt' x y = withDisplay $ \dpy -> io $ do
|
|||||||
sync dpy False
|
sync dpy False
|
||||||
return w
|
return w
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Event hook
|
-- Event hook
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
@ -162,9 +189,10 @@ screenCornerLayoutHook = ModifiedLayout ScreenCornerLayout
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- $usage
|
-- $usage
|
||||||
--
|
--
|
||||||
-- This extension adds KDE-like screen corners to XMonad. By moving your cursor
|
-- This extension adds KDE-like screen corners and GNOME Hot Edge like
|
||||||
-- into one of your screen corners you can trigger an @X ()@ action, for
|
-- features to XMonad. By moving your cursor into one of your screen corners
|
||||||
-- example @"XMonad.Actions.GridSelect".goToSelected@ or
|
-- or edges, you can trigger an @X ()@ action, for example
|
||||||
|
-- @"XMonad.Actions.GridSelect".goToSelected@ or
|
||||||
-- @"XMonad.Actions.CycleWS".nextWS@ etc.
|
-- @"XMonad.Actions.CycleWS".nextWS@ etc.
|
||||||
--
|
--
|
||||||
-- To use it, import it on top of your @xmonad.hs@:
|
-- To use it, import it on top of your @xmonad.hs@:
|
||||||
@ -176,6 +204,7 @@ screenCornerLayoutHook = ModifiedLayout ScreenCornerLayout
|
|||||||
-- > myStartupHook = do
|
-- > myStartupHook = do
|
||||||
-- > ...
|
-- > ...
|
||||||
-- > addScreenCorner SCUpperRight (goToSelected def { gs_cellwidth = 200})
|
-- > addScreenCorner SCUpperRight (goToSelected def { gs_cellwidth = 200})
|
||||||
|
-- > addScreenCorner SCBottom (goToSelected def)
|
||||||
-- > addScreenCorners [ (SCLowerRight, nextWS)
|
-- > addScreenCorners [ (SCLowerRight, nextWS)
|
||||||
-- > , (SCLowerLeft, prevWS)
|
-- > , (SCLowerLeft, prevWS)
|
||||||
-- > ]
|
-- > ]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user