
On 2008.09.12 20:57:08 -0700, Devin Mullins
On Fri, Sep 12, 2008 at 10:56:47PM -0400, Gwern Branwen wrote:
Oh. Hmm, it still sounds useful. Incidentally, how exactly does one use it? I gave it a desultorily try, but I was unsure how exactly one gets the Window argument - I tried using withWindowSet, but got bogged down extracting the Window parameter from it.
You're probably looking for withFocused. You can see its definition in Operations.hs -- it uses withWindowSet.
Ah, I see. I was searching for the wrong type signature after all. So I've been working up a basic XPaste module, and here's what I have thus far" -------------------------------- sendSelection :: KeyMask -> X () sendSelection m = getSelection >>= (sendString m) sendString :: KeyMask -> String -> X () sendString mo = mapM_ (sendChar mo) sendChar :: KeyMask -> Char -> X () sendChar modm c = sendKeyScreen modm (stringToKeysym [c]) sendKeyScreen :: KeyMask -> KeySym -> X () sendKeyScreen modmk key = withFocused (sendKeysym modmk key) sendKeysym :: KeyMask -> KeySym -> Window -> X () sendKeysym mods key w = withDisplay $ \d -> do rootw <- asks theRoot keycode <- io $ keysymToKeycode d key io $ allocaXEvent $ \ev -> do setEventType ev keyPress setKeyEvent ev w rootw none mods keycode True sendEvent d w True keyPressMask ev setEventType ev keyRelease sendEvent d w True keyReleaseMask ev -------------------------------- My first question is, is there any way to scrap all the KeyMask plumbing? I looked at the X11 docs, but there doesn't seem to be any null modmask - mod1Mask is Alt, Shift is Shift, and so on. My second question is, why does 'keysymToKeycode' take a String? I manually played around with it in GHCi and it seems every String which isn't a Char always gets evaluated to '0'. -- gwern Scully .375 PLA TWA Active White dog Amherst WISDIM rita