1
0
mirror of https://github.com/xmonad/xmonad-contrib.git synced 2025-08-13 19:25:52 -07:00
Files
.github
XMonad
Actions
Config
Doc
Hooks
Layout
Prompt
Util
Loggers
ActionCycle.hs
ClickableWorkspaces.hs
Cursor.hs
CustomKeys.hs
DebugWindow.hs
Dmenu.hs
DynamicScratchpads.hs
Dzen.hs
EZConfig.hs
ExclusiveScratchpads.hs
ExtensibleConf.hs
ExtensibleState.hs
Font.hs
Hacks.hs
Image.hs
Invisible.hs
Loggers.hs
Minimize.hs
NamedActions.hs
NamedScratchpad.hs
NamedWindows.hs
NoTaskbar.hs
Paste.hs
PositionStore.hs
PureX.hs
Rectangle.hs
RemoteWindows.hs
Replace.hs
Run.hs
Scratchpad.hs
SessionStart.hs
SpawnNamedPipe.hs
SpawnOnce.hs
Stack.hs
StringProp.hs
Themes.hs
Timer.hs
TreeZipper.hs
Types.hs
Ungrab.hs
WindowProperties.hs
WindowState.hs
WorkspaceCompare.hs
XSelection.hs
XUtils.hs
Doc.hs
Prelude.hs
Prompt.hs
scripts
tests
.gitignore
.hlint.yaml
.mailmap
CHANGES.md
LICENSE
README.md
Setup.lhs
cabal.haskell-ci
cabal.project
flake.nix
stack-master.yaml
xmonad-contrib.cabal
xmonad-contrib/XMonad/Util/Ungrab.hs

46 lines
1.6 KiB
Haskell

-----------------------------------------------------------------------------
-- |
-- Module : XMonad.Util.Ungrab
-- Description : Release xmonad's keyboard and pointer grabs immediately.
-- Copyright : (c) 2016 Brandon S Allbery
-- License : BSD-style (see xmonad/LICENSE)
--
-- Maintainer : allbery.b@gmail.com
-- Stability : unstable
-- Portability : unportable
--
-- Allow releasing xmonad's keyboard grab
--
-----------------------------------------------------------------------------
module XMonad.Util.Ungrab
( -- * Usage:
-- $usage
unGrab
) where
import Graphics.X11.Xlib (sync)
import Graphics.X11.Xlib.Extras (currentTime)
import Graphics.X11.Xlib.Misc (ungrabKeyboard, ungrabPointer)
import XMonad.Core
-- $usage
-- Start a keyboard action with this if it is going to run something
-- that needs to do a keyboard, pointer, or server grab. For example,
--
-- > , ((modm .|. controlMask, xK_p), unGrab >> spawn "scrot")
--
-- (Other examples are screen lockers and "gksu".)
-- This avoids needing to insert a pause/sleep before running the
-- command.
--
-- xmonad retains the keyboard grab during key actions because if they
-- use a Submap, they need the keyboard to be grabbed, and if they had
-- to assert their own grab then the asynchronous nature of X11 allows
-- race conditions between xmonad, other clients, and the X server that
-- would cause keys to sometimes be "leaked" to the focused window.
-- | Release xmonad's keyboard grab, so other grabbers can do their thing.
unGrab :: X ()
unGrab = withDisplay $ \d -> io (ungrabKeyboard d currentTime >> ungrabPointer d currentTime >> sync d False)