Initial Commit
[packages] / xemacs-packages / xlib / lisp / xlib-xtest.el
1 ;;; xlib-xtest.el --- XTEST extension for xlib.
2
3 ;; Copyright (C) 2003-2005 by XWEM Org.
4
5 ;; Author: Zajcev Evgeny <zevlg@yandex.ru>
6 ;; Created: 18 October 2003
7 ;; Keywords: xlib, xwem
8 ;; X-CVS: $Id: xlib-xtest.el,v 1.5 2005-04-04 19:55:31 lg Exp $
9 ;; X-URL: http://lgarc.narod.ru/xwem/index.html
10
11 ;; This file is part of XWEM.
12
13 ;; XWEM is free software; you can redistribute it and/or modify it
14 ;; under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; any later version.
17
18 ;; XWEM is distributed in the hope that it will be useful, but WITHOUT
19 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 ;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
21 ;; License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with XEmacs; see the file COPYING.  If not, write to the Free
25 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 ;; 02111-1307, USA.
27
28 ;;; Synched up with: Not in FSF
29
30 ;;; Commentary:
31
32 ;; 
33
34 ;;; TODO:
35
36 ;;    * add X-XTestGetVersion, X-XTestCompareCursor, X-XTestGrabControl
37
38 ;;; Code:
39 \f
40 (require 'xlib-xlib)
41
42 (defconst X-XTest-op-GetVersion 0)
43 (defconst X-XTest-op-CompareCursor      1)
44 (defconst X-XTest-op-FakeInput          2)
45 (defconst X-XTest-op-GrabControl        3)
46
47 (defconst X-Xtest-KeyPress 2)
48 (defconst X-Xtest-KeyRelease 3)
49 (defconst X-Xtest-ButtonPress 4)
50 (defconst X-Xtest-ButtonRelease 5)
51 (defconst X-Xtest-MotionNotify 6)
52
53 (defun X-XTest-FakeInput (xdpy evtype detail root rootx rooty &optional time)
54   "On display XDPY send fake event of EVTYPE with DETAIL at TIME."
55   (X-Dpy-p xdpy 'X-XTest-FakeInput)
56
57   (let* ((test-ext (X-Dpy-get-extension xdpy "XTEST" 'X-XTest-FakeInput))
58          (ListOfFields
59           (list (vector 1 (nth 4 test-ext)) ; opcode
60                 [1 X-XTest-op-FakeInput]
61                 [2 (+ 1 (* 1 8))]       ;length
62
63                 [1 evtype]
64                 [1 detail]
65                 [2 nil]                 ;pad
66                 [4 (or time X-CurrentTime)]
67                 [4 (if (X-Win-p root) (X-Win-id root) root)]
68                 [8 nil]
69                 [2 rootx]
70                 [2 rooty]
71                 [8 nil]
72                 ))
73          (msg (X-Create-message ListOfFields)))
74     (X-Dpy-send xdpy msg)))
75
76 (provide 'xlib-xtest)
77
78 ;;; xlib-xtest.el ends here