Paste.hs: implement noModMask suggestion

This commit is contained in:
gwern0
2008-09-26 23:20:56 +00:00
parent b663075990
commit 300d9cf2b7

View File

@@ -23,7 +23,6 @@ import Data.Char (isUpper)
import Graphics.X11.Xlib.Misc (stringToKeysym) import Graphics.X11.Xlib.Misc (stringToKeysym)
import XMonad.Util.XSelection (getSelection) import XMonad.Util.XSelection (getSelection)
{- $usage {- $usage
Import this module into your xmonad.hs as usual: Import this module into your xmonad.hs as usual:
@@ -47,7 +46,7 @@ pasteSelection = getSelection >>= pasteString
-- | Send a string to the window with current focus. This function correctly -- | Send a string to the window with current focus. This function correctly
-- handles capitalization. -- handles capitalization.
pasteString :: String -> X () pasteString :: String -> X ()
pasteString = mapM_ (\x -> if isUpper x then pasteChar shiftMask x else pasteChar 0 x) pasteString = mapM_ (\x -> if isUpper x then pasteChar shiftMask x else pasteChar noModMask x)
{- | Send a character to the current window. This is more low-level. {- | Send a character to the current window. This is more low-level.
Remember that you must handle the case of capitalization appropriately. Remember that you must handle the case of capitalization appropriately.
@@ -78,3 +77,8 @@ sendKeyWindow mods key w = withDisplay $ \d -> do
sendEvent d w True keyPressMask ev sendEvent d w True keyPressMask ev
setEventType ev keyRelease setEventType ev keyRelease
sendEvent d w True keyReleaseMask ev sendEvent d w True keyReleaseMask ev
-- | A null 'KeyMask'. Used when you don't want a character or string shifted, control'd, or what.
-- TODO: This really should be a function in the X11 binding. When noModMask shows up there, remove.
noModMask :: KeyMask
noModMask = 0