stumpwm-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[STUMP] XTest extension support for portable-clx


From: Lionel Flandrin
Subject: [STUMP] XTest extension support for portable-clx
Date: Wed, 13 Aug 2008 00:38:25 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (berkeley-unix)

Hello stumpwmers,
I've been trying to implement the XTest extension in portable-clx, and
now that I have something that seems to work correctly, I thought I
would ask your advices/comments/impressions about it.

For those who don't know what XTest is, it's an X11 protocol extension
that allows the client to send fake events that look real (unlike
sendevents). Practically, it'll let you do stuff in stumpwm like:

(defcommand middleclick () ()
  "Send a middleclick event"
  (xtest:fake-button-event *display* 2 t)
  (xtest:fake-button-event *display* 2 nil))

This will make the X server believe you made a middleclick (and probably
make it paste the content of the clipboard under the mouse pointer,
what would not happen with sendevents). You can also do something like:

(defcommand mouse-move (x y) ((:number "Horizontal offset: ")
                              (:number "Vertical offset: "))
  "Moves the mouse pointer relatively to its current position"
  (xtest:fake-motion-event *display* x y :relative t))

Or:

(defcommand send-a () ()
  "Send a single 'a' to the focused window"
  (xtest:fake-key-event *display* 38 t)    ; 38 is the keycode for the
  (xtest:fake-key-event *display* 38 nil)) ; key 'a' on my keyboard

Well, ok, this last one is not really useful, but you see how it
works. The fake-key-event function will work with any keycode, including
those of the modifiers, so you could use it to make custom bindings for
applications that usually don't let you do it (I'll work on a better
stumpwm integration in the next days/months/years/centuries depending on
my laziness, for instance allowing custom bindings depending on the
focused window).

I made all my tests using sbcl, I don't know if this code can be made to
work with clisp.

Ok, enough talking, here's the code: I made a tarball with the whole
portable-clx source code from the darcs repo[1] with my code integrated
for simplicity's sake:
http://simias.hd.free.fr/~simias/stumpwm/portable-clx+xtest.tar.bz2
Just de-tar and put a symlink to clx.asd in your ~/.sbcl/systems/
directory, rebuild stumpwm and you should be done.

If you just want the xtest source code, it's here:
http://simias.hd.free.fr/~simias/stumpwm/xtest.lisp

You can just put this file in the clx directory and then add a (:file
"xtest") in the :module extensions section of clx.asd.

Please keep in mind that this code should be considered beta and that
I'm a lisp newbie, so every comment/suggestion will be appreciated :).

[1] darcs get http://common-lisp.net/~crhodes/clx

-- 
Lionel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]