Center floating window

This commit is contained in:
Martin Potier 2021-01-20 12:16:59 +02:00
parent 6f4d2c30c5
commit d51ced34d5
No known key found for this signature in database
GPG key ID: D4DD957DBA4AD89E

View file

@ -57,6 +57,7 @@ modify conf = conf
, ("M-s t", spawn "/run/current-system/sw/bin/scrot /tmp/screen.png")
-- Workspace and tasks
, ("M-b", switchProjectPrompt promptConfig)
, ("M-p c", withFocused centerWindow)
, ("M-p m", shiftToProjectPrompt promptConfig)
, ("M-p n", switchProjectPrompt promptConfig)
, ("M-p r", renameProjectPrompt promptConfig)
@ -69,6 +70,14 @@ modify conf = conf
, ("M-c", workspacePrompt promptConfig (\name -> windows $ copy name))
]
-- Borrowed from https://www.reddit.com/r/xmonad/comments/gzq316/how_can_i_centre_a_floating_window_without/fthtx29/
centerWindow :: Window -> X ()
centerWindow win = do
(_, W.RationalRect x y w h) <- floatLocation win
windows $ W.float win (W.RationalRect ((1 - w) / 2) ((1 - h) / 2) w h)
return ()
viewProject :: WorkspaceId -> X ()
viewProject id = do
project <- lookupProject id