Commits

Anonymous committed e8347a6

Sync with Xlib 2.1 Release

  • Participants
  • Parent commits 7a42f4d

Comments (0)

Files changed (22)

File ChangeLog.upstream

+# do not edit -- automatically generated by arch changelog
+# arch-tag: automatic-ChangeLog--lg@xwem.org--2005/xlib--main--2.1
+#
+
+2005-04-04 18:25:15 GMT Zajcev Evgeny <lg@xwem.org>     version-0
+
+    Summary:
+      Xlib 2.1 is released
+    Revision:
+      xlib--main--2.1--version-0
+
+
+
+2005-03-30 22:24:01 GMT Zajcev Evgeny <lg@xwem.org>     patch-12
+
+    Summary:
+      Support for COMPOUNT_TEXT properties.
+    Revision:
+      xlib--main--2.1--patch-12
+
+    * lisp/xlib-xlib.el (XDecodeCompoundText): [new] Function to extract text
+      from COMPOUND_TEXT text.
+    
+    * lisp/xlib-xlib.el (XGetPropertyString): [fix] Use `XDecodeCompoundText'
+      in case of property in COMPOUND_TEXT encoding.
+
+    modified files:
+     lisp/xlib-xlib.el
+
+    new patches:
+     dev@xwem.org--2004-w/xlib--dev--2.1--patch-7
+
+
+2005-02-26 17:48:25 GMT Zajcev Evgeny <lg@xwem.org>     patch-11
+
+    Summary:
+      merge from ckent, compilation warnings elimination
+    Revision:
+      xlib--main--2.1--patch-11
+
+    * lisp/xlib-xrecord.el (predicateds): Some predicateds moved on top.
+    
+    * lisp/xlib-xwin.el (predicateds): Some predicateds moved on top.
+
+    modified files:
+     lisp/xlib-xrecord.el lisp/xlib-xwin.el
+
+    new patches:
+     dev@xwem.org--2004-w/xlib--dev--2.1--patch-6
+
+
+2005-02-25 10:55:05 GMT Zajcev Evgeny <lg@xwem.org>     patch-10
+
+    Summary:
+      lambda fixes
+    Revision:
+      xlib--main--2.1--patch-10
+
+
+    modified files:
+     lisp/xlib-img.el lisp/xlib-testing.el lisp/xlib-xc.el
+     lisp/xlib-xlib.el lisp/xlib-xpm.el lisp/xlib-xr.el
+     lisp/xlib-xrecord.el lisp/xlib-xwin.el
+
+
+2005-02-13 23:02:44 GMT Zajcev Evgeny <lg@xwem.org>     patch-9
+
+    Summary:
+      Useful addons
+    Revision:
+      xlib--main--2.1--patch-9
+
+    * lisp/xlib-xlib.el (XDeleteProperty): [new] X request to delete X
+      property.
+    
+    * lisp/xlib-xlib.el (XSetWindowBackgroundPixmap): [new] Set window
+      background pixmap.
+    
+    * lisp/xlib-xlib.el (XSetPropertyString): [new] To set textual X
+      properties.
+    
+    * lisp/xlib-xr.el (X-EventsList): [fix] sanitify creation.
+    
+    * lisp/xlib-const.el (errors): [addon] X error codes added.
+
+    modified files:
+     lisp/xlib-const.el lisp/xlib-xlib.el lisp/xlib-xr.el
+
+
+2005-02-10 00:18:24 GMT Zajcev Evgeny <lg@xwem.org>     patch-8
+
+    Summary:
+      logging changed a little
+    Revision:
+      xlib--main--2.1--patch-8
+
+    * lisp/xlib-xr.el: Logging for inter events changed a little. to be used
+      in catching evil bug.
+
+    modified files:
+     lisp/xlib-xr.el
+
+
+2005-02-06 20:00:08 GMT Zajcev Evgeny <lg@xwem.org>     patch-7
+
+    Summary:
+      Merge from ckent
+    Revision:
+      xlib--main--2.1--patch-7
+
+    Patches applied:
+    
+     * dev@xwem.org--2004-w/xlib--dev--2.1--patch-3
+       Copyright string changes
+    
+
+    modified files:
+     lisp/xlib-composer.el lisp/xlib-const.el lisp/xlib-hello.el
+     lisp/xlib-img.el lisp/xlib-keysymdb.el lisp/xlib-math.el
+     lisp/xlib-testing.el lisp/xlib-tray.el lisp/xlib-vidmode.el
+     lisp/xlib-xc.el lisp/xlib-xdpms.el lisp/xlib-xinerama.el
+     lisp/xlib-xlib.el lisp/xlib-xpm.el lisp/xlib-xr.el
+     lisp/xlib-xrecord.el lisp/xlib-xshape.el lisp/xlib-xtest.el
+     lisp/xlib-xwin.el
+
+    new patches:
+     dev@xwem.org--2004-w/xlib--dev--2.1--patch-3
+
+
+2005-02-03 23:52:26 GMT Zajcev Evgeny <lg@xwem.org>     patch-6
+
+    Summary:
+      merge from ckent, X Event define/declare addons
+    Revision:
+      xlib--main--2.1--patch-6
+
+    * lisp/xlib-xr.el (X-Event-define): [addon] DESCR splited to EV-NAME,
+      EV-MSG and WIN-IDX.  New parameter EVENT-WIN-IDX added.
+    
+    * lisp/xlib-xr.el (X-Event-declare): [addon] Ditto.
+
+    modified files:
+     lisp/xlib-xc.el lisp/xlib-xr.el
+
+    new patches:
+     dev@xwem.org--2004-w/xlib--dev--2.1--patch-2
+
+
+2005-02-02 23:52:31 GMT Zajcev Evgeny <lg@xwem.org>     patch-5
+
+    Summary:
+      XDestroy declaration fix|try
+    Revision:
+      xlib--main--2.1--patch-5
+
+
+    modified files:
+     lisp/xlib-xr.el
+
+
+2005-02-02 22:11:17 GMT Zajcev Evgeny <lg@xwem.org>     patch-4
+
+    Summary:
+      2 serious bug fixes
+    Revision:
+      xlib--main--2.1--patch-4
+
+    * lisp/xlib-xlib.el (xlib-opcodes-alist): [rem] moved to xlib-xr.el
+    
+    * lisp/xlib-xr.el (xlib-opcodes-alist): [new] moved from xlib-xlib.el
+    
+    * lisp/xlib-xr.el (X-Dpy-send-read): [BUG fix] Serious BUG fixed.  Do
+      flushing under reading protection, because in some (pretty ofter)
+      circumstances flushing can execute deffered calls by side effect which
+      may lead to desyncronisation.
+    
+    * lisp/xlib-xr.el (X-Dpy-parse-message): [BUG fix] Serious BUG fixed.
+      Dispatch intermediate event or error only after all reply to request is
+      fetched.  Executing intermediate event or error may cause unexpected
+      reading by side effect.
+    
+    * lisp/xlib-xr.el (code): [cleanup] Untabification.
+    
+    * lisp/xlib-xrecord.el (X-XRecord-parse-guess): [fix] fixes to make it
+      more resistable for errors.
+    
+    * lisp/xlib-xrecord.el (code): [cleanup] Untabification.
+
+    modified files:
+     lisp/xlib-xlib.el lisp/xlib-xr.el lisp/xlib-xrecord.el
+
+    new patches:
+     dev@xwem.org--2004-w/xlib--dev--2.1--base-0
+     dev@xwem.org--2004-w/xlib--dev--2.1--patch-1
+
+
+2005-02-01 23:04:15 GMT Zajcev Evgeny <lg@xwem.org>     patch-3
+
+    Summary:
+      Root of most of the X timeout problems founded at last
+    Revision:
+      xlib--main--2.1--patch-3
+
+    * lisp/xlib-xr.el (X-Dpy-send-read): [BUG fix] Root of most of X timeout
+      errors founded here.  This is response parsing problem.  In some
+      circumstances we can request X server for data, while processing data.
+      This eventually lead to desyncronization.  This is caused by
+      xwem-misc-xerr-hook, which can be called from inside `X-Dpy-send-read'
+      and xwem-misc-xerr-hook can also do `X-Dpy-send-read', now we restrict
+      `X-Dpy-send-read' reentering to avoid desyncronization.  This is quite
+      rarely situation when `X-Dpy-send-read' reenters, but when it happens
+      xlib hangs forever.
+    
+    Many thanks to all of you guys for pushing me about this stuff!
+    
+    * lisp/xlib-xr.el (xxx): [misc] Some tiny cleanups, and more some logs
+      added.  Errors raising clarified, etc.
+    
+
+    modified files:
+     lisp/xlib-xr.el
+
+
+2005-01-08 01:51:45 GMT Zajcev Evgeny <lg@xwem.org>     patch-2
+
+    Summary:
+      inhibit C-g while parsing message
+    Revision:
+      xlib--main--2.1--patch-2
+
+    * lisp/xlib-xr.el (X-Dpy-parse-message): [fix] inhibit C-g while parsing,
+      so pressing C-g will not desync xlib.
+
+    modified files:
+     lisp/xlib-xr.el
+
+
+2005-01-01 02:54:34 GMT Zajcev Evgeny <lg@xwem.org>     patch-1
+
+    Summary:
+      start of 2.1
+    Revision:
+      xlib--main--2.1--patch-1
+
+
+    new files:
+     ChangeLog.d/.arch-ids/=id
+     ChangeLog.d/.arch-ids/ChangeLog-2.0.id
+     ChangeLog.d/ChangeLog-2.0
+
+    modified files:
+     Makefile
+
+    new directories:
+     ChangeLog.d ChangeLog.d/.arch-ids
+
+
+2005-01-01 02:44:45 GMT Zajcev Evgeny <lg@xwem.org>     base-0
+
+    Summary:
+      tag of lg@xwem.org--2004/xlib--main--2.0--version-0
+    Revision:
+      xlib--main--2.1--base-0
+
+    (automatically generated log message)
+
+    new patches:
+     dev@xwem.org--2004-w/xlib--dev--2.0--patch-5
+     dev@xwem.org--2004-w/xlib--dev--2.0--patch-6
+     dev@xwem.org--2004-w/xlib--dev--2.0--patch-7
+     dev@xwem.org--2004-w/xlib--dev--2.0--patch-8
+     dev@xwem.org--2004-w/xlib--dev--2.0--patch-9
+     lg@xwem.org--2004/xlib--main--2.0--base-0
+     lg@xwem.org--2004/xlib--main--2.0--patch-1
+     lg@xwem.org--2004/xlib--main--2.0--patch-2
+     lg@xwem.org--2004/xlib--main--2.0--patch-3
+     lg@xwem.org--2004/xlib--main--2.0--patch-4
+     lg@xwem.org--2004/xlib--main--2.0--patch-5
+     lg@xwem.org--2004/xlib--main--2.0--patch-6
+     lg@xwem.org--2004/xlib--main--2.0--patch-7
+     lg@xwem.org--2004/xlib--main--2.0--patch-8
+     lg@xwem.org--2004/xlib--main--2.0--patch-9
+     lg@xwem.org--2004/xlib--main--2.0--version-0
+     steve@eicq.org--2004/xlib--steve--2.0--base-0
+     steve@eicq.org--2004/xlib--steve--2.0--patch-1
+     steve@eicq.org--2004/xlib--steve--2.0--patch-2
+
+
 # do not edit -- automatically generated by arch changelog
 # non-id: automatic-ChangeLog--lg@xwem.org--2004/xlib--main--2.0
 #
 # Boston, MA 02111-1307, USA.
 
 VERSION = 1.13
-AUTHOR_VERSION = lg@xwem.org--2004/xlib--main--2.0--version-0
+AUTHOR_VERSION = lg@xwem.org--2005/xlib--main--2.1--version-0
 MAINTAINER = Zajcev Evgeny <zevlg@yandex.ru>
 PACKAGE = xlib
 PKG_TYPE = regular

File lisp/xlib-composer.el

 ;;; xlib-composer.el --- 
 
-;; Copyright (C) 2004 by Free Software Foundation, Inc.
+;; Copyright (C) 2004,2005 by XWEM Org.
 
 ;; Author: Zajcev Evgeny <zevlg@yandex.ru>
 ;; Created: Fri Jun  4 18:46:04 MSD 2004

File lisp/xlib-const.el

 ;;; xlib-const.el --- Constants used in Xlib for masks and the like.
 
 ;; Copyright (C) 1996, 1997, 1998 Eric M. Ludlam
+;; Copyright (C) 2003-2005 XWEM Org.
 ;;
 ;; Author: Eric M. Ludlam <zappo@gnu.ai.mit.edu>
 ;; Modified: Zajcev Evgeny <zevlg@yandex.ru>
 (defconst X-LSBFirst 0)
 (defconst X-MSBFirst 1)
 
+;; X errors
+(defconst X-BadRequest 1)
+(defconst X-BadValue 2)
+(defconst X-BadWindow 3)
+(defconst X-BadPixmap 4)
+(defconst X-BadAtom 5)
+(defconst X-BadCursor 6)
+(defconst X-BadFont 7)
+(defconst X-BadMatch 8)
+(defconst X-BadDrawable 9)
+(defconst X-BadAccess 10)
+(defconst X-BadAlloc 11)
+(defconst X-BadColor 12)
+(defconst X-BadGC 13)
+(defconst X-BadIDChoice 14)
+(defconst X-BadName 15)
+(defconst X-BadLength 16)
+(defconst X-BadImplementation 17)
+(defconst X-BadFirstExtension 128)
+(defconst X-BadLastExtension 255)
+
 
 (provide 'xlib-const)
 

File lisp/xlib-hello.el

 ;;; xlib-hello.el --- Hello world example using new xlib.
 
-;; Copyright (C) 2003 by Free Software Foundation, Inc.
+;; Copyright (C) 2003-2005 by XWEM Org.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.ai.mit.edu>
 ;; Modified: Zajcev Evgeny <zevlg@yandex.ru>

File lisp/xlib-img.el

 ;;; xlib-img.el --- Imaging for Xlib.
 
-;; Copyright (C) 2003 by Free Software Foundation, Inc.
+;; Copyright (C) 2003-2005 by XWEM Org.
 
 ;; Author: Zajcev Evgeny <zevlg@yandex.ru>
 ;; Created: Fri Dec 12 11:22:19 MSK 2003
         (setq ex-mcc (cons (nreverse tline) ex-mcc)
               tline nil)))
     (setq ex-mcc (nreverse ex-mcc))
-    (setq xdata (mapcar (lambda (l)
-                          (mapconcat  'identity (mapcar 'int->string2 l) ""))
+    (setq xdata (mapcar #'(lambda (l)
+                            (apply 'concat (mapcar 'int->string2 l)))
                         ex-mcc))
 
     (setq ximg (XCreateImage xdpy nil (XDefaultDepth xdpy)

File lisp/xlib-keysymdb.el

 ;;; xlib-keysymdb.el --- XKeysymDB for xlib.
 
-;; Copyright (C) 2004 by Free Software Foundation, Inc.
+;; Copyright (C) 2004,2005 by XWEM Org.
 
 ;; Author: Zajcev Evgeny <zevlg@yandex.ru>
 ;; Created: Tue Dec  7 20:23:10 MSK 2004

File lisp/xlib-math.el

 ;;; xlib-math.el --- icky math things such as 4 byte ints, and int->string stuff.
 
 ;; Copyright (C) 1996, 1997, 1998 Eric M. Ludlam
+;; Copyright (C) 2003-2005 XWEM Org.
 ;;
 ;; Author: Eric M. Ludlam <zappo@gnu.ai.mit.edu>
 ;; Modified: Zajcev Evgeny <zevlg@yandex.ru>

File lisp/xlib-testing.el

 ;;; xlib-testing.el --- Testing suite for xlib.
 
-;; Copyright (C) 2004 by Free Software Foundation, Inc.
+;; Copyright (C) 2004,2005 by XWEM Org.
 
 ;; Author: Zajcev Evgeny <zevlg@yandex.ru>
 ;; Created: Thu Nov 25 15:34:59 MSK 2004
     (insert "===> BEGIN at " (format-time-string "%R %S")
             "\n")
     (let ((X-default-timeout 2.5))        ; 2 seconds
-      (mapc (lambda (r)
-              (let (begtime endtime result)
-                (condition-case err
-                    (setq begtime (current-time)
-                          result (funcall r)
-                          endtime (current-time))
-                  (t (setq result (cons 'error err))))
-                (insert (format "%s ... %f %S" (substring (symbol-name r) 3)
-                                (itimer-time-difference (or endtime (current-time))
-                                                        (or begtime (current-time)))
-                                result)
-                        "\n")))
+      (mapc #'(lambda (r)
+                (let (begtime endtime result)
+                  (condition-case err
+                      (setq begtime (current-time)
+                            result (funcall r)
+                            endtime (current-time))
+                    (t (setq result (cons 'error err))))
+                  (insert (format "%s ... %f %S" (substring (symbol-name r) 3)
+                                  (itimer-time-difference (or endtime (current-time))
+                                                          (or begtime (current-time)))
+                                  result)
+                          "\n")))
             xt-test-routines))
     (insert "<=== DONE at " (format-time-string "%R %S")
             "\n")))

File lisp/xlib-tray.el

 ;;; xlib-tray.el --- XEMBED support.
 
-;; Copyright (C) 2003 by Free Software Foundation, Inc.
+;; Copyright (C) 2003-2005 by XWEM Org.
 
 ;; Author: Zajcev Evgeny <zevlg@yandex.ru>
 ;; Created: Tue Dec  9 14:14:07 MSK 2003

File lisp/xlib-version.el

 ;;; Automatically generated file -- DO NOT EDIT OR DELETE
 ;;;###autoload
 (defconst xlib-version
-  "lg@xwem.org--2004/xlib--main--2.0--version-0")
+  "lg@xwem.org--2005/xlib--main--2.1--version-0")
 (provide 'xlib-version)

File lisp/xlib-vidmode.el

 ;;; xlib-vidmode.el --- XF86VidMode extension support.
 
-;; Copyright (C) 2004 by Free Software Foundation, Inc.
+;; Copyright (C) 2004,2005 by XWEM Org.
 
 ;; Author: Zajcev Evgeny <zevlg@yandex.ru>
 ;; Created: Fri Jan 16 18:39:44 MSK 2004

File lisp/xlib-xc.el

 ;;; xlib-xc.el --- X Connection.
 
-;; Copyright (C) 2003 by Free Software Foundation, Inc.
+;; Copyright (C) 2003-2005 by XWEM Org.
 
 ;; Author: Zajcev Evgeny <zevlg@yandex.ru>
 ;; Created: 18 October 2003
       (save-excursion
         (goto-char (point-min))
         (insert (format "%d %S: " (nth 1 (current-time)) routine))
-        (insert (apply 'format (mapcar (lambda (arg) (eval arg)) args)))
+        (insert (apply 'format (mapcar 'eval args)))
         (insert "\n")))))
 
 (defun X-Dpy-log-verbatim (xdpy arg)
   ;; increase request sequence number
   (incf (X-Dpy-rseq-id xdpy)))
 
-;;; Event dispatcher
-(defun X-Dpy-default-events-dispatcher (xdpy win xev)
-  "Default events  dispatcher."
-  (X-Dpy-log xdpy 'x-event "Get event: %S, for win: %S" '(X-Event-name xev)
-	     '(if (X-Win-p win) (X-Win-id win) win))
-
-  (when (X-Win-p win)
-    ;; First run display handlers
-    (when (X-Dpy-event-handlers xdpy)
-      (X-Dpy-EventHandler-runall xdpy xev))
-
-    ;; Then run WIN specific handlers
-    (when (X-Win-event-handlers win)
-      ;; WIN has its own event handlers
-      (X-Win-EventHandler-runall win xev))
-    ))
-
 ;;; Sending section
 (defmacro X-Force-char-num (maybechar)
   "Force MAYBECHAR to be a number for XEmacs platform."
            (X-type-pack dpy (cadr xtd) val))
 
           ((eq xt 'listof)
-           (mapconcat (lambda (el)
-                        (X-type-pack dpy (cadr xtd) el))
-                      val ""))
+           (apply 'concat (mapcar #'(lambda (el)
+                                      (X-type-pack dpy (cadr xtd) el))
+                                  val)))
 
           ((eq xt 'setof)
            (funcall (cond ((= (cadr xtd) 1) 'int->string1)
                     (apply 'Xmask-or val)))
 
           ((eq xt 'struct)
-           (mapconcat (lambda (tt)
-                        (X-type-pack dpy (cdr tt) (funcall (car tt) val)))
-                      (cddr xt) ""))
+           (apply 'concat (mapcar #'(lambda (tt)
+                                      (X-type-pack dpy (cdr tt)
+                                                   (funcall (car tt) val)))
+                                  (cddr xt))))
 
           ((eq xt 'or)
            (setq xt (cdr xt))
 
           ((eq xt 'struct)
            (let ((rval (funcall (cadr xtd))))
-             (mapc (lambda (tt)
-                     (eval `(setf (,(car tt) rval) (X-type-extract dpy ,(cdr tt)))))
+             (mapc #'(lambda (tt)
+                       (eval `(setf (,(car tt) rval)
+                                    (X-type-extract dpy ,(cdr tt)))))
                    (cdr xtd))
              rval)))))
 

File lisp/xlib-xdpms.el

 ;;; xlib-xdpms.el --- DPMS extension support.
 
-;; Copyright (C) 2003 by Free Software Foundation, Inc.
+;; Copyright (C) 2003-2005 by XWEM Org.
 
 ;; Author: Zajcev Evgeny <zevlg@yandex.ru>
 ;; Created: Tue Nov 18 03:19:16 MSK 2003

File lisp/xlib-xinerama.el

 ;;; xlib-xinerama.el --- Xinerama support.
 
-;; Copyright (C) 2003 by Free Software Foundation, Inc.
+;; Copyright (C) 2003-2005 by XWEM Org.
 
 ;; Author: Zajcev Evgeny <zevlg@yandex.ru>
 ;; Created: Mon Nov 17 19:23:03 MSK 2003

File lisp/xlib-xlib.el

 ;;; xlib-xlib.el --- X library part of new xlib.
 
-;; Copyright (C) 2003 by Free Software Foundation, Inc.
+;; Copyright (C) 2003-2005 by XWEM Org.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.ai.mit.edu>
 ;;	   Zajcev Evgeny <zevlg@yandex.ru>
 
 (require 'xlib-xr)
 
-(defvar xlib-opcodes-alist
-  '((104 . XBell)
-    (1 . XCreateWindow)
-    (2 . XChangeWindowAttributes)
-    (3 . XGetWindowAttributes)
-    (12 . XConfigureWindow)
-    (8 . XMapWindow)
-    (10 . XUnmapWindow)
-    (4 . XDestroyWindow)
-    (5 . XDestroySubwindows)
-    (15 . XQueryTree)
-    (16 . XInternAtom)
-    (17 . XGetAtomName)
-    (18 . XChangeProperty)
-    (20 . XGetWindowProperty)
-    (78 . XCreateColormap)
-    (79 . XFreeColormap)
-    (84 . XAllocColor)
-    (85 . XAllocNamedColor)
-    (86 . XAllocColorCells)
-    (89 . XStoreColors)
-    (88 . XFreeColors)
-    (91 . XQueryColors)
-    (55 . XCreateGC)
-    (56 . XChangeGC)
-    (58 . XSetDashes)
-    (59 . XSetClipRectangles)
-    (60 . XFreeGC)
-    (61 . XClearArea)
-    (62 . XCopyArea)
-    (63 . XCopyPlane)
-    (64 . XDrawPoints)
-    (65 . XDrawLines)
-    (69 . XFillPoly)
-    (66 . XDrawSegments)
-    (67 . XDrawRectangles)
-    (70 . XDrawRectangles)
-    (68 . XDrawArcs)
-    (71 . XDrawArcs)
-    (74 . XDrawString)
-    (76 . XImageString)
-    (72 . XPutImage)
-    (73 . XGetImage)
-    (22 . XSetSelectionOwner)
-    (23 . XGetSelectionOwner)
-    (24 . XConvertSelection)
-    (41 . XWarpPointer)
-    (36 . XGrabServer)
-    (37 . XUngrabServer)
-    (38 . XQueryPointer)
-    (31 . XGrabKeyboard)
-    (32 . XUngrabKeyboard)
-    (26 . XGrabPointer)
-    (27 . XUngrabPointer)
-    (28 . XGrabButton)
-    (29 . XUngrabButton)
-    (33 . XGrabKey)
-    (34 . XUngrabKey)
-    (43 . XGetInputFocus)
-    (42 . XSetInputFocus)
-    (7 . XReparentWindow)
-    (14 . XGetGeometry)
-    (40 . XTranslateCoordinates)
-    (6 . XChangeSaveSet)
-    (25 . XSendEvent)
-    (44 . XQueryKeymap)
-    (101 . XGetKeyboardMapping)
-    (119 . XGetModifierMapping)
-    (45 . XOpenFont)
-    (47 . XQueryFont)
-    (48 . XQueryTextExtents)
-    (53 . XCreatePixmap)
-    (54 . XFreePixmap)
-    (93 . XCreateCursor)
-    (94 . XCreateGlyphCursor)
-    (95 . XFreeCursor)
-    (96 . XRecolorCursor)
-    (30 . XChangeActivePointerGrab)
-    (98 . XQueryExtension)
-    (107 . XSetScreenSaver)
-    (108 . XGetScreenSaver)
-    (113 . XKillClient)
-    (115 . XForceScreenSaver))
-  "Alist of X opcodes in form (OPCODE . FUNCTION).
-This is only informative variable.")
-
 (defun XOpenDisplay (name &optional dispnum screen)
   "Open an X connection to the display named NAME such as host:0.1.
 Optionally you may pass DISPNUM - display number and SCREEN - screen number."
 
 	;; Fill formats list
 	(setf (X-Dpy-formats xdpy)
-	      (mapcar (lambda (fmt)
-			(make-X-ScreenFormat :depth (nth 0 fmt)
-					     :bits-per-pixel (nth 1 fmt)
-					     :scanline-pad (nth 2 fmt)))
+	      (mapcar #'(lambda (fmt)
+                          (make-X-ScreenFormat :depth (nth 0 fmt)
+                                               :bits-per-pixel (nth 1 fmt)
+                                               :scanline-pad (nth 2 fmt)))
 		      (nth 15 X-info)))
 
 	;; Fill screens list
 	(setf (X-Dpy-screens xdpy)
-	      (mapcar (lambda (scr)
-			(let (nscreen)
-			  (setq nscreen (make-X-Screen :root (X-Win-find-or-make xdpy (nth 0 scr))
-						       :colormap (make-X-Colormap :dpy xdpy :id (nth 1 scr))
-						       :white-pixel (make-X-Color :dpy xdpy :id (nth 2 scr))
-						       :black-pixel (make-X-Color :dpy xdpy :id (nth 3 scr))
-						       :root-event-mask (nth 4 scr)
-						       :width (nth 5 scr)
-						       :height (nth 6 scr)
-						       :mwidth (nth 7 scr)
-						       :mheight (nth 8 scr)
-						       :min-maps (nth 9 scr)
-						       :max-maps (nth 10 scr)
-						       :visualid (nth 11 scr)
-						       :backingstores (nth 12 scr)
-						       :save-unders (nth 13 scr)
-						       :root-depth (nth 14 scr)))
+	      (mapcar #'(lambda (scr)
+                          (let (nscreen)
+                            (setq nscreen
+                                  (make-X-Screen
+                                   :root (X-Win-find-or-make xdpy (nth 0 scr))
+                                   :colormap (make-X-Colormap :dpy xdpy :id (nth 1 scr))
+                                   :white-pixel (make-X-Color :dpy xdpy :id (nth 2 scr))
+                                   :black-pixel (make-X-Color :dpy xdpy :id (nth 3 scr))
+                                   :root-event-mask (nth 4 scr)
+                                   :width (nth 5 scr)
+                                   :height (nth 6 scr)
+                                   :mwidth (nth 7 scr)
+                                   :mheight (nth 8 scr)
+                                   :min-maps (nth 9 scr)
+                                   :max-maps (nth 10 scr)
+                                   :visualid (nth 11 scr)
+                                   :backingstores (nth 12 scr)
+                                   :save-unders (nth 13 scr)
+                                   :root-depth (nth 14 scr)))
 
-			  (setf (X-Screen-depths nscreen)
-				(mapcar (lambda (dpth)
-					  (make-X-Depth :depth (nth 0 dpth)
-							:visuals (mapcar (lambda (vis)
-									   (make-X-Visual :id (nth 0 vis)
-											  :class (nth 1 vis)
-											  :bits-per-rgb (nth 2 vis)
-											  :cmap-entries (nth 3 vis)
-											  :red-mask (nth 4 vis)
-											  :green-mask (nth 6 vis)
-											  :blue-mask (nth 5 vis)))
-									 (nth 1 dpth))))
-					(nth 15 scr)))
+                            (setf (X-Screen-depths nscreen)
+                                  (mapcar #'(lambda (dpth)
+                                              (make-X-Depth :depth (nth 0 dpth)
+                                                            :visuals (mapcar #'(lambda (vis)
+                                                                                 (make-X-Visual :id (nth 0 vis)
+                                                                                                :class (nth 1 vis)
+                                                                                                :bits-per-rgb (nth 2 vis)
+                                                                                                :cmap-entries (nth 3 vis)
+                                                                                                :red-mask (nth 4 vis)
+                                                                                                :green-mask (nth 6 vis)
+                                                                                                :blue-mask (nth 5 vis)))
+                                                                             (nth 1 dpth))))
+                                          (nth 15 scr)))
 
-			  ;; Create default GC
-			  (setf (X-Screen-default-gc nscreen)
-				(XCreateGC xdpy (X-Screen-root nscreen)
-					   (make-X-Gc :dpy xdpy :id (X-Dpy-get-id xdpy)
-						      :foreground (X-Screen-white-pixel nscreen)
-						      :background (X-Screen-black-pixel nscreen))))
-			  nscreen))
+                            ;; Create default GC
+                            (setf (X-Screen-default-gc nscreen)
+                                  (XCreateGC xdpy (X-Screen-root nscreen)
+                                             (make-X-Gc :dpy xdpy :id (X-Dpy-get-id xdpy)
+                                                        :foreground (X-Screen-white-pixel nscreen)
+                                                        :background (X-Screen-black-pixel nscreen))))
+                            nscreen))
 		      (nth 16 X-info)))
 
 	;; Alert user
   "On display XDPY for window WIN, set the background to PIXEL."
   (XChangeWindowAttributes xdpy win (make-X-Attr :background-pixel pixel)))
 
-;(defun X-SetWindowForeground (xdpy win pixel)
-;  "On display XDPY for window WIN, set the foreground to PIXEL."
-;  (XChangeWindowAttributes xdpy win (make-X-Attr :foreground-pixel pixel)))
+(defun XSetWindowBackgroundPixmap (xdpy win pixmap)
+  "On display XDPY for window WIN, set the background pixmap to PIXMAP."
+  (XChangeWindowAttributes xdpy win (make-X-Attr :background-pixmap pixmap)))
   
 (defun XSetWindowBorder (xdpy win pixel)
   "On display XDPY for window WIN, set the border color to PIXEL."
 		data (cdr data)))))
     (X-Dpy-send xdpy (X-Create-message ListOfFields))))
 
+(defun XDeleteProperty (xdpy win atom)
+  "On display XDPY for window WIN delete property denoted by ATOM."
+  (X-Win-p win 'XDeleteProperty)
+  (X-Atom-p atom 'XDeleteProperty)
+
+  (let ((ListOfFields
+         (list [1 19]			;opcode
+               [1 nil]                  ;unused
+               [2 3]                    ;length
+               [4 (X-Win-id win)]       ;window
+               [4 (X-Atom-id atom)])))  ;atom
+    (X-Dpy-send xdpy (X-Create-message ListOfFields))))
+
 ;; These are Xlib convenience routines
-;;
+(defun XSetPropertyString (xdpy win atom string &optional mode)
+  "On display XDPY and window WIN set ATOM property to STRING."
+  (XChangeProperty xdpy win atom XA-string X-format-8 (or mode X-PropModeReplace)
+		    string))
+
 (defun XSetWMProtocols (xdpy win protocol_atoms)
   "On display XDPY, set window's WIN protocols to PROTOCOL_ATOMS.
 Convenience routine which calls `XChangeProperty'"
 		     :base-height (Xtruncate (nth 16 wmnh))
 		     :gravity (Xtruncate (nth 17 wmnh))))))
 
+(defun XDecodeCompoundText (text)
+  "Decode compound TEXT, to native string.
+Evil hack, invent something better."
+  (if (string-match "\x1b\x25\x2f\x31\\(.\\)\\(.\\)\\(.*?\\)\x02" text)
+      (let ((len (+ (* (- (char-to-int (string-to-char (match-string 1 text))) 128) 128)
+                    (- (char-to-int (string-to-char (match-string 2 text))) 128))))
+        (let ((seq-beg (match-beginning 0))
+              (data-beg (match-end 0))
+              (data-end (+ len (match-beginning 3)))
+              (cs (intern (match-string 3 text))))
+          (concat (substring text 0 seq-beg)
+                  (if (fboundp 'decode-coding-string)
+                      (decode-coding-string (substring text data-beg data-end) cs)
+                    (substring text data-beg data-end))
+                  (XDecodeCompoundText (substring text data-end)))))
+    text))
+
 (defun XGetPropertyString (xdpy win atom)
   "On display XDPY, and window XWIN, get string property of type ATOM."
-  (let ((propdata (XGetWindowProperty xdpy win atom 0 1024 nil XA-string))
+  (let ((propdata (XGetWindowProperty xdpy win atom 0 1024))
+        (tdata nil)
 	(retstring ""))
-    (when propdata
-      (setq retstring (nth 2 propdata))
+    (when (and propdata (setq tdata (nth 2 propdata)))
+      (setq retstring tdata)
+      (when (= (car propdata)
+               (X-Atom-id (XInternAtom xdpy "COMPOUND_TEXT")))
+        ;; Adjust RETSTRING in case of COMPOUND_TEXT
+        (setq retstring (XDecodeCompoundText retstring)))
+
       (when (> (nth 1 propdata) 0.0)
-        (setq propdata (XGetWindowProperty xdpy win atom
-                                           1024 (nth 0 propdata) nil XA-string))
-        (when propdata
-          (setq retstring (concat retstring (nth 2 propdata))))))
+        (setq propdata
+              (XGetWindowProperty xdpy win atom
+                                  1024 (nth 0 propdata)))
+        (when (and propdata (setq tdata (nth 2 propdata)))
+          (if (= (car propdata)
+                 (X-Atom-id (XInternAtom xdpy "COMPOUND_TEXT")))
+              (setq retstring
+                    (concat retstring (XDecodeCompoundText tdata)))
+            (setq retstring (concat retstring tdata))))))
     retstring))
 
 (defun XGetWMName (xdpy win)
 		[4 (X-Colormap-id cmap)] ;Colormap
 		[4 planes]))		;plane mask
 	 (msg (concat (X-Create-message ListOfFields)
-		      (X-Generate-message-for-list colors
-                        (lambda (col) (int->string4 (X-Color-id col)))))))
+		      (X-Generate-message-for-list
+                       colors
+                       #'(lambda (col) (int->string4 (X-Color-id col)))))))
     (X-Dpy-send xdpy msg)
  
     ;; NOTE:
 		[4 (X-Colormap-id cmap)] ;COLORMAP
 		))
 	 (msg (concat (X-Create-message ListOfFields)
-		      (X-Generate-message-for-list color-ids (lambda (colid) (int->string4 colid)))))
+		      (X-Generate-message-for-list
+                       color-ids
+                       #'(lambda (colid) (int->string4 colid)))))
 	 (ReceiveFields
 	  (list [1 success]
 		nil
   (X-Dpy-p xdpy 'XSetDashes)
   (X-Gc-p gc 'XSetDashes)
 
-  (let* ((dstr (mapconcat (lambda (d) (int->string1 d)) dashes ""))
+  (let* ((dstr (apply 'concat (mapcar 'int->string1 dashes)))
 	 (ListOfFields 
 	  (list [1 58]			;opcode
 		[1 nil]			;unused
   ;; Check len, must be < 255
   (when (or (and len (>= len 255))
 	    (>= (length str) 255))
-    (signal 'overflow-error (list str (or len (length str)))))
+    (setq str (substring str 0 254)))
 
   (let* ((slen (if len len (length str))) ;make len optional
 	 (ListOfFields
 		[2 (+ 2 (X-padlen (concat string string)))] ;length
 		[4 (X-Font-id font)]))
 	 (msg (concat (X-Create-message ListOfFields)
-		      (mapconcat (lambda (c) (string ?\0 c)) string "")
+		      (apply 'concat
+                             (mapcar #'(lambda (c) (string ?\0 c)) string))
 		      (when (> (% (length string) 2) 0) (make-string 2 ?\0))
 		      ))
 	 (ReceiveFields

File lisp/xlib-xpm.el

 ;;; xlib-xpm.el --- XPM library for Xlib.
 
-;; Copyright (C) 2003 by Free Software Foundation, Inc.
+;; Copyright (C) 2003-2005 by XWEM Org.
 
 ;; Author: Zajcev Evgeny <zevlg@yandex.ru>
 ;; Created: Fri Nov 28 01:28:18 MSK 2003
 
       (setq xpm-index (1+ xpm-index)))
 
-    (setq data (mapvector (lambda (row)
-			    (X-formatpad xdpy depth
-					 (mapconcat (lambda (col)
-						      (X-formatint xdpy depth col))
-						    row "")))
+    (setq data (mapvector #'(lambda (row)
+                              (X-formatpad xdpy depth
+                                           (apply 'concat
+                                                  (mapcar #'(lambda (col)
+                                                              (X-formatint xdpy depth col))
+                                                          row))))
 			  xpm))
     ;; XXX
     (setq ximg (XCreateImage xdpy nil depth X-ZPixmap 0 data

File lisp/xlib-xr.el

 ;;; xlib-xr.el --- X receive part.
 
-;; Copyright (C) 2003 by Free Software Foundation, Inc.
+;; Copyright (C) 2003-2005 by XWEM Org.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.ai.mit.edu>
-;;	   Zajcev Evgeny <zevlg@yandex.ru>
+;;         Zajcev Evgeny <zevlg@yandex.ru>
 ;; Keywords: xlib, xwem
 ;; X-CVS: $Id$
 
   "Take list LST and turn it into a vector.
 This makes random access of its fields much faster."
   (let ((nv (make-vector (length lst) nil))
-	(cnt 0))
+        (cnt 0))
     (while lst
       (aset nv cnt (if (and (car lst) (listp (car lst)))
-		       (XVectorizeList (car lst))
-		     (car lst)))
+                       (XVectorizeList (car lst))
+                     (car lst)))
       (setq cnt (1+ cnt))
       (setq lst (cdr lst)))
     nv))
 NOTE: * Core event are less than 35, but extensions may generate greater.
       * Eight bit is syntetic bit.")
 
-(defvar X-EventsList (make-vector X-Event-LASTEvent nil)
+(defvar X-EventsList (make-vector X-Event-LASTEvent ["Unknown" nil 0 0])
   "List of event descriptions.")
 
 (defstruct (X-Event (:predicate X-Event-isevent-p))
-  dpy					; display
-  type					; type of event
-  synth-p				; non-nil if event came from SendEvent request
-  evdata				; binary event represetation
-  evinfo				; parsed variant of evdata
+  dpy                                   ; display
+  type                                  ; type of event
+  synth-p                               ; non-nil if event came from SendEvent request
+  evdata                                ; binary event represetation
+  evinfo                                ; parsed variant of evdata
 
-  list					;for use in X-Generate-message
-  properties				; User defined plist
+  list                                  ;for use in X-Generate-message
+  properties                            ; User defined plist
   )
 
 (defsubst X-Event-put-property (xev prop val)
   "Put property PROP with value VAL in XEV's properties list."
   (setf (X-Event-properties xev)
-	(plist-put (X-Event-properties xev) prop val)))
+        (plist-put (X-Event-properties xev) prop val)))
 
 (defsubst X-Event-get-property (xev prop)
   "Get property PROP from XEV's properties list."
   "Return non-nil if EV is X-Event."
   (let ((isev (X-Event-isevent-p ev)))
     (if (and (not isev) sig)
-	(signal 'wrong-type-argument (list sig 'X-Event-p ev))
+        (signal 'wrong-type-argument (list sig 'X-Event-p ev))
       isev)))
 
 (defsubst X-Event-detail (xev)
   (nth 1 (X-Event-evinfo xev)))
 
 (defsubst X-Event-win (xev)
-  "Return window for which EV generated.
-Return nil if there no window for which event XEV is generated."
+  "Return window which is the subject of the XEV.
+Return nil if there no such window."
   (let ((evd (aref (aref X-EventsList (X-Event-type xev)) 2)))
     (and (numberp evd) (nth evd (X-Event-evinfo xev)))))
 
+(defsubst X-Event-win-event (xev)
+  "Return window for which XEV is generated.
+Return nil if there is no such window."
+  (let ((evd (aref (aref X-EventsList (X-Event-type xev)) 3)))
+    (and (numberp evd) (nth evd (X-Event-evinfo xev)))))
+
 (defsubst X-Event-name (xev)
   "Return symbolic XEV name."
   (aref (aref X-EventsList (X-Event-type xev)) 0))
 (defun X-Event-make (&rest args)
   "Like `make-X-Event', but also fills list field automatically."
   (let* ((xev (apply 'make-X-Event args))
-	 (evspec (aref (X-Event-type xev) X-EventsList)))
+         (evspec (aref (X-Event-type xev) X-EventsList)))
     ;; TODO: write me ..
     ))
 
-(defmacro X-Event-declare (type descr)
+(defmacro X-Event-declare (type ev-name ev-msg &optional win-idx event-win-idx)
   "Only declare event of TYPE with DESCR in `X-EventsList'."
-  `(aset X-EventsList ,type ,descr))
+  `(aset X-EventsList ,type
+        (vector ,ev-name (quote ,ev-msg) ,win-idx (or ,event-win-idx ,win-idx))))
 
-(defmacro X-Event-define (type name dnames descr)
+(defmacro X-Event-define (type name dnames ev-name ev-msg &optional win-idx event-win-idx)
   "Define new event of TYPE, NAME and description of event DESCR."
   (let ((offs 0)
-	fsym forms)
-    (push `(aset X-EventsList ,type ,descr) forms)
+        fsym forms)
+    (push `(aset X-EventsList ,type
+                 (vector ,ev-name (quote ,ev-msg) ,win-idx (or ,event-win-idx ,win-idx)))
+          forms)
     (while dnames
       (when (car dnames)
-	(setq fsym (intern (concat "X-Event-" name "-" (symbol-name (car dnames)))))
-	(push `(defsubst* ,fsym (ev)
+        (setq fsym (intern (concat "X-Event-" name "-" (symbol-name (car dnames)))))
+        (push `(defsubst* ,fsym (ev)
                  (nth ,offs (X-Event-evinfo ev)))
               forms))
       (setq offs (1+ offs))
   "Convert XEV type to symbolic name, return keyword."
   (let ((evt (X-Event-type xev)))
     (cond ((= evt X-KeyPress) :X-KeyPress)
-	  ((= evt X-KeyRelease) :X-KeyRelease)
-	  ((= evt X-ButtonPress) :X-ButtonPress)
-	  ((= evt X-ButtonRelease) :X-ButtonRelease)
-	  ((= evt X-MotionNotify) :X-MotionNotify)
-	  ((= evt X-EnterNotify) :X-EnterNotify)
-	  ((= evt X-LeaveNotify) :X-LeaveNotify)
-	  ((= evt X-FocusIn) :X-FocusIn)
-	  ((= evt X-FocusOut) :X-FocusOut)
-	  ((= evt X-KeymapNotify) :X-KeymapNotify)
-	  ((= evt X-Expose) :X-Expose)
-	  ((= evt X-GraphicsExpose) :X-GraphicsExpose)
-	  ((= evt X-NoExpose) :X-NoExpose)
-	  ((= evt X-VisibilityNotify) :X-VisibilityNotify)
-	  ((= evt X-CreateNotify) :X-CreateNotify)
-	  ((= evt X-DestroyNotify) :X-DestroyNotify)
-	  ((= evt X-UnmapNotify) :X-UnmapNotify)
-	  ((= evt X-MapNotify) :X-MapNotify)
-	  ((= evt X-MapRequest) :X-MapRequest)
-	  ((= evt X-ReparentNotify) :X-ReparentNotify)
-	  ((= evt X-ConfigureRequest) :X-ConfigureRequest)
-	  ((= evt X-ConfigureNotify) :X-ConfigureNotify)
-	  ((= evt X-GravityNotify) :X-GravityNotify)
-	  ((= evt X-ResizeRequest) :X-ResizeRequest)
-	  ((= evt X-CirculateNotify) :X-CirculateNotify)
-	  ((= evt X-CirculateRequest) :X-CirculateRequest)
-	  ((= evt X-PropertyNotify) :X-PropertyNotify)
-	  ((= evt X-SelectionClear) :X-SelectionClear)
-	  ((= evt X-SelectionRequest) :X-SelectionRequest)
-	  ((= evt X-SelectionNotify) :X-SelectionNotify)
-	  ((= evt X-ColormapNotify) :X-ColormapNotify)
-	  ((= evt X-ClientMessage) :X-ClientMessage)
-	  ((= evt X-MappingNotify) :X-MappingNotify)
+          ((= evt X-KeyRelease) :X-KeyRelease)
+          ((= evt X-ButtonPress) :X-ButtonPress)
+          ((= evt X-ButtonRelease) :X-ButtonRelease)
+          ((= evt X-MotionNotify) :X-MotionNotify)
+          ((= evt X-EnterNotify) :X-EnterNotify)
+          ((= evt X-LeaveNotify) :X-LeaveNotify)
+          ((= evt X-FocusIn) :X-FocusIn)
+          ((= evt X-FocusOut) :X-FocusOut)
+          ((= evt X-KeymapNotify) :X-KeymapNotify)
+          ((= evt X-Expose) :X-Expose)
+          ((= evt X-GraphicsExpose) :X-GraphicsExpose)
+          ((= evt X-NoExpose) :X-NoExpose)
+          ((= evt X-VisibilityNotify) :X-VisibilityNotify)
+          ((= evt X-CreateNotify) :X-CreateNotify)
+          ((= evt X-DestroyNotify) :X-DestroyNotify)
+          ((= evt X-UnmapNotify) :X-UnmapNotify)
+          ((= evt X-MapNotify) :X-MapNotify)
+          ((= evt X-MapRequest) :X-MapRequest)
+          ((= evt X-ReparentNotify) :X-ReparentNotify)
+          ((= evt X-ConfigureRequest) :X-ConfigureRequest)
+          ((= evt X-ConfigureNotify) :X-ConfigureNotify)
+          ((= evt X-GravityNotify) :X-GravityNotify)
+          ((= evt X-ResizeRequest) :X-ResizeRequest)
+          ((= evt X-CirculateNotify) :X-CirculateNotify)
+          ((= evt X-CirculateRequest) :X-CirculateRequest)
+          ((= evt X-PropertyNotify) :X-PropertyNotify)
+          ((= evt X-SelectionClear) :X-SelectionClear)
+          ((= evt X-SelectionRequest) :X-SelectionRequest)
+          ((= evt X-SelectionNotify) :X-SelectionNotify)
+          ((= evt X-ColormapNotify) :X-ColormapNotify)
+          ((= evt X-ClientMessage) :X-ClientMessage)
+          ((= evt X-MappingNotify) :X-MappingNotify)
 
-	  (t :X-Unknown))))
+          (t :X-Unknown))))
 
 (defmacro X-Event-CASE (xev &rest body)
   "Run event case. BODY in form (EVTYPE FORMS) (EVTYPE FORMS) ..
 
 (defstruct X-EventHandler
   priority
-  evtypes-list				; list of event types
-  handler				; function to call
-  (active t)				; Non-nil mean event handler activated
+  evtypes-list                          ; list of event types
+  handler                               ; function to call
+  (active t)                            ; Non-nil mean event handler activated
 
-  plist)				; user defined plist
+  plist)                                ; user defined plist
 
 ;;;###autoload
 (defun X-EventHandler-add (evhlist handler &optional priority evtypes-list)
     (setq priority 0))
 
   (let ((xeh (make-X-EventHandler :priority priority
-				  :evtypes-list evtypes-list
-				  :handler handler)))
+                                  :evtypes-list evtypes-list
+                                  :handler handler)))
 
     ;; Insert new event handler and sort event handlers by priority.
     (sort (cons xeh evhlist)
-	  (lambda (xeh1 xeh2)
-	    (> (X-EventHandler-priority xeh1)
-	       (X-EventHandler-priority xeh2))))))
+          #'(lambda (xeh1 xeh2)
+              (> (X-EventHandler-priority xeh1)
+                 (X-EventHandler-priority xeh2))))))
 
 ;;;###autoload
 (defun X-EventHandler-isset (evhlist handler &optional prioritiy evtypes-list)
   (let ((evhs evhlist))
     ;; Find appopriate handler
     (while (and evhs
-		(not (and (eq (X-EventHandler-handler (car evhs)) handler)
-			  (if prioritiy (equal prioritiy (X-EventHandler-priority (car evhs))) t)
-			  (if evtypes-list (equal evtypes-list (X-EventHandler-evtypes-list (car evhs))) t))))
+                (not (and (eq (X-EventHandler-handler (car evhs)) handler)
+                          (if prioritiy (equal prioritiy (X-EventHandler-priority (car evhs))) t)
+                          (if evtypes-list (equal evtypes-list (X-EventHandler-evtypes-list (car evhs))) t))))
       (setq evhs (cdr evhs)))
 
     (car evhs)))
 (defun X-EventHandler-runall (evhlist xev)
   "Run all event handlers in EVHLIST on XEV.
 Signal `X-Events-stop' to stop events processing."
-  (let ((evhs evhlist))			; EVHS should be already sorted by priority
+  (let ((evhs evhlist))                 ; EVHS should be already sorted by priority
     (condition-case nil
-	(while evhs
-	  ;; Check is there appopriate event handler to handle XEV event.
-	  (when (and (X-EventHandler-active (car evhs))
-		     (or (null (X-EventHandler-evtypes-list (car evhs)))
-			 (memq (X-Event-type xev) (X-EventHandler-evtypes-list (car evhs)))))
+        (while evhs
+          ;; Check is there appopriate event handler to handle XEV event.
+          (when (and (X-EventHandler-active (car evhs))
+                     (or (null (X-EventHandler-evtypes-list (car evhs)))
+                         (memq (X-Event-type xev) (X-EventHandler-evtypes-list (car evhs)))))
             (funcall (X-EventHandler-handler (car evhs)) (X-Event-dpy xev) (X-Event-win xev) xev))
-	  (setq evhs (cdr evhs)))
+          (setq evhs (cdr evhs)))
       (X-Events-stop nil))))
 
 ;;; X Events description.
 ;; TODO:
 ;;   - Should be X-Dpy depended to support extensions derived events
 (X-Event-define X-KeyPress "xkey" (keycode nil time root event child root-x root-y event-x event-y state same-screen)
-		[ "KeyPress"
-		  ( [1 integerp]	; keycode
-		    [2 integerp]	; sequence
-		    [4 integerp]	; time
-		    [4 :X-Win]		; root
-		    [4 :X-Win]		; event
-		    [4 :X-Win]		; child
-		    [2 integerp]	; root_x
-		    [2 integerp]	; root_y
-		    [2 integerp]	; event_x
-		    [2 integerp]	; event_y
-		    [2 integerp]	; state
-		    [1 booleanp]	; same_screen
-		    [1 nil] )
-		  4 ])
+                "KeyPress"
+               ([1 integerp]           ; keycode
+                [2 integerp]           ; sequence
+                [4 integerp]           ; time
+                [4 :X-Win]             ; root
+                [4 :X-Win]             ; event  (WIN-EVENT)
+                [4 :X-Win]             ; child
+                [2 integerp]           ; root_x
+                [2 integerp]           ; root_y
+                [2 integerp]           ; event_x
+                [2 integerp]           ; event_y
+                [2 integerp]           ; state
+                [1 booleanp]           ; same_screen
+                [1 nil])
+               4)
 (X-Event-declare X-KeyRelease
-		 [ "KeyRelease"
-		   ( [1 integerp]	; keycode
-		     [2 integerp]	; sequence
-		     [4 integerp]	; time
-		     [4 :X-Win]		; root
-		     [4 :X-Win]		; event
-		     [4 :X-Win]		; child
-		     [2 integerp]	; root_x
-		     [2 integerp]	; root_y
-		     [2 integerp]	; event_x
-		     [2 integerp]	; event_y
-		     [2 integerp]	; state
-		     [1 booleanp]	; same_screen
-		     [1 nil] )
-		   4 ])
+                 "KeyRelease"
+                ([1 integerp]          ; keycode
+                 [2 integerp]          ; sequence
+                 [4 integerp]          ; time
+                 [4 :X-Win]            ; root
+                 [4 :X-Win]            ; event
+                 [4 :X-Win]            ; child
+                 [2 integerp]          ; root_x
+                 [2 integerp]          ; root_y
+                 [2 integerp]          ; event_x
+                 [2 integerp]          ; event_y
+                 [2 integerp]          ; state
+                 [1 booleanp]          ; same_screen
+                 [1 nil])
+                4)
 (X-Event-define X-ButtonPress "xbutton" (button nil time root event child root-x root-y event-x event-y state same-screen)
-		[ "ButtonPress"
-		  ( [1 integerp]	; button
-		    [2 integerp]	; sequence
-		    [4 integerp]	; time
-		    [4 :X-Win]		; root
-		    [4 :X-Win]		; event
-		    [4 :X-Win]		; child
-		    [2 integerp]	; root_x
-		    [2 integerp]	; root_y
-		    [2 integerp]	; event_x
-		    [2 integerp]	; event_y
-		    [2 integerp]	; state
-		    [1 booleanp]	; same_screen
-		    [1 nil] )
-		  4 ])
+                "ButtonPress"
+               ( [1 integerp]          ; button
+                 [2 integerp]          ; sequence
+                 [4 integerp]          ; time
+                 [4 :X-Win]            ; root
+                 [4 :X-Win]            ; event
+                 [4 :X-Win]            ; child
+                 [2 integerp]          ; root_x
+                 [2 integerp]          ; root_y
+                 [2 integerp]          ; event_x
+                 [2 integerp]          ; event_y
+                 [2 integerp]          ; state
+                 [1 booleanp]          ; same_screen
+                 [1 nil] )
+               4)
 (X-Event-declare X-ButtonRelease
-		 [ "ButtonRelease"
-		   ( [1 integerp]	; button
-		     [2 integerp]	; sequence
-		     [4 integerp]	; time
-		     [4 :X-Win]		; root
-		     [4 :X-Win]		; event
-		     [4 :X-Win]		; child
-		     [2 integerp]	; root_x
-		     [2 integerp]	; root_y
-		     [2 integerp]	; event_x
-		     [2 integerp]	; event_y
-		     [2 integerp]	; state
-		     [1 booleanp]	; same_screen
-		     [1 nil] )
-		   4 ])
+                 "ButtonRelease"
+                ( [1 integerp]         ; button
+                  [2 integerp]         ; sequence
+                  [4 integerp]         ; time
+                  [4 :X-Win]           ; root
+                  [4 :X-Win]           ; event
+                  [4 :X-Win]           ; child
+                  [2 integerp]         ; root_x
+                  [2 integerp]         ; root_y
+                  [2 integerp]         ; event_x
+                  [2 integerp]         ; event_y
+                  [2 integerp]         ; state
+                  [1 booleanp]         ; same_screen
+                  [1 nil] )
+                4)
 (X-Event-define X-MotionNotify "xmotion" (nil nil time root event child root-x root-y event-x event-y state same-screen)
-		[ "MotionNotify"
-		  ( [1 integerp]	; detail
-		    [2 integerp]	; sequence
-		    [4 integerp]	; time
-		    [4 :X-Win]          ; root
-		    [4 :X-Win]		; event
-		    [4 :X-Win]          ; child
-		    [2 integerp]	; root_x
-		    [2 integerp]	; root_y
-		    [2 integerp]	; event_x
-		    [2 integerp]	; event_y
-		    [2 integerp]	; state
-		    [1 booleanp]	; same_screen
-		    [1 nil] )
-		  4 ])
+                "MotionNotify"
+               ( [1 integerp]          ; detail
+                 [2 integerp]          ; sequence
+                 [4 integerp]          ; time
+                 [4 :X-Win]            ; root
+                 [4 :X-Win]            ; event
+                 [4 :X-Win]            ; child
+                 [2 integerp]          ; root_x
+                 [2 integerp]          ; root_y
+                 [2 integerp]          ; event_x
+                 [2 integerp]          ; event_y
+                 [2 integerp]          ; state
+                 [1 booleanp]          ; same_screen
+                 [1 nil] )
+               4)
 (X-Event-define X-EnterNotify "xcrossing" (nil nil time root event child root-x root-y event-x event-y state mode same-screen-focus)
-		[ "EnterNotify"
-		  ( [1 integerp]	; detail
-		    [2 integerp]	; sequence
-		    [4 integerp]	; time
-		    [4 :X-Win]          ; root
-		    [4 :X-Win]		; event
-		    [4 :X-Win]          ; child
-		    [2 integerp]	; root_x
-		    [2 integerp]	; root_y
-		    [2 integerp]	; event_x
-		    [2 integerp]	; event_y
-		    [2 integerp]	; state
-		    [1 integerp]	; mode
-		    [1 integerp])	; same-screen, focus
-		  4 ])
+                "EnterNotify"
+               ( [1 integerp]          ; detail
+                 [2 integerp]          ; sequence
+                 [4 integerp]          ; time
+                 [4 :X-Win]            ; root
+                 [4 :X-Win]            ; event
+                 [4 :X-Win]            ; child
+                 [2 integerp]          ; root_x
+                 [2 integerp]          ; root_y
+                 [2 integerp]          ; event_x
+                 [2 integerp]          ; event_y
+                 [2 integerp]          ; state
+                 [1 integerp]          ; mode
+                 [1 integerp])         ; same-screen, focus
+               4)
 (X-Event-declare X-LeaveNotify
-		 [ "LeaveNotify"
-		   ( [1 integerp]	; detail
-		     [2 integerp]	; sequence
-		     [4 integerp]	; time
-		     [4 :X-Win]         ; root
-		     [4 :X-Win]		; event
-		     [4 :X-Win]         ; child
-		     [2 integerp]	; root_x
-		     [2 integerp]	; root_y
-		     [2 integerp]	; event_x
-		     [2 integerp]	; event_y
-		     [2 integerp]	; state
-		     [1 integerp]	; mode
-		     [1 integerp] )	; same-screen, focus
-		   4 ])
+                 "LeaveNotify"
+                ( [1 integerp]         ; detail
+                  [2 integerp]         ; sequence
+                  [4 integerp]         ; time
+                  [4 :X-Win]           ; root
+                  [4 :X-Win]           ; event
+                  [4 :X-Win]           ; child
+                  [2 integerp]         ; root_x
+                  [2 integerp]         ; root_y
+                  [2 integerp]         ; event_x
+                  [2 integerp]         ; event_y
+                  [2 integerp]         ; state
+                  [1 integerp]         ; mode
+                  [1 integerp] )       ; same-screen, focus
+                4)
 (X-Event-define X-FocusIn "xfocus" (nil nil event mode)
-		[ "FocusIn"
-		  ( [1 integerp]	; detail
-		    [2 integerp]	; sequence
-		    [4 :X-Win]		; event
-		    [1 integerp]	; mode
-		    [23 nil] )
-		  2 ])
+                "FocusIn"
+               ( [1 integerp]          ; detail
+                 [2 integerp]          ; sequence
+                 [4 :X-Win]            ; event
+                 [1 integerp]          ; mode
+                 [23 nil] )
+               2)
 (X-Event-declare X-FocusOut
-		 [ "FocusOut"
-		   ( [1 integerp]	; detail
-		     [2 integerp]	; sequence
-		     [4 :X-Win]		; event
-		     [1 integerp]	; mode
-		     [23 nil] )
-		   2 ])
+                 "FocusOut"
+                ( [1 integerp]         ; detail
+                  [2 integerp]         ; sequence
+                  [4 :X-Win]           ; event
+                  [1 integerp]         ; mode
+                  [23 nil] )
+                2)
 
 ;; TODO: X-KeymapNotify
 
 (X-Event-define X-Expose "xexpose" (nil nil window x y width height count)
-		[ "Expose"
-		  ( [1 integerp]	; detail
-		    [2 integerp]	; sequence
-		    [4 :X-Win]		; window
-		    [2 integerp]	; x
-		    [2 integerp]	; y
-		    [2 integerp]	; width
-		    [2 integerp]	; height
-		    [2 integerp]	; count
-		    [14 nil] )
-		  2 ])
+                "Expose"
+               ( [1 integerp]          ; detail
+                 [2 integerp]          ; sequence
+                 [4 :X-Win]            ; window
+                 [2 integerp]          ; x
+                 [2 integerp]          ; y
+                 [2 integerp]          ; width
+                 [2 integerp]          ; height
+                 [2 integerp]          ; count
+                 [14 nil] )
+               2)
 (X-Event-define X-GraphicsExpose "xgraphicsexpose" (nil nil drawable x y width height minor-event count major-event)
-		[ "GraphicsExpose"
-		  ([1 integerp]
-		   [2 integerp]
-		   [4 integerp]		; drawable
-		   [2 integerp]		; x
-		   [2 integerp]		; y
-		   [2 integerp]		; width
-		   [2 integerp]		; height
-		   [2 integerp]		; minorEvent
-		   [2 integerp]		; count
-		   [1 integerp]		; majorEvent
-		   [11 nil])
-		  2 ])
+                "GraphicsExpose"
+               ([1 integerp]
+                [2 integerp]
+                [4 integerp]           ; drawable
+                [2 integerp]           ; x
+                [2 integerp]           ; y
+                [2 integerp]           ; width
+                [2 integerp]           ; height
+                [2 integerp]           ; minorEvent
+                [2 integerp]           ; count
+                [1 integerp]           ; majorEvent
+                [11 nil])
+               2)
 (X-Event-define X-NoExpose "xnoexpose" (nil nil drawable minor-event major-event)
-		[ "NoExpose"
-		  ([1 integerp]
-		   [2 integerp]
-		   [4 integerp]		; drawable
-		   [2 integerp]		; minorEvent
-		   [1 integerp]		; majorEvent
-		   [21 nil])
-		  2 ])
+                "NoExpose"
+               ([1 integerp]
+                [2 integerp]
+                [4 integerp]           ; drawable
+                [2 integerp]           ; minorEvent
+                [1 integerp]           ; majorEvent
+                [21 nil])
+               2)
 (X-Event-define X-VisibilityNotify "xvisibility" (nil nil window state)
-		[ "VisibilityNotify"
-		  ([1 integerp]
-		   [2 integerp]
-		   [4 :X-Win]		; window
-		   [1 integerp]		; state
-		   [23 nil])
-		  2 ])
+                "VisibilityNotify"
+               ([1 integerp]
+                [2 integerp]
+                [4 :X-Win]             ; window
+                [1 integerp]           ; state
+                [23 nil])
+               2)
 (X-Event-define X-CreateNotify "xcreatewindow" (nil nil parent window x y width height border-width override)
-		[ "CreateNotify"     
-		  ([1 integerp]		; detail
-		   [2 integerp]		; sequence
-		   [4 :X-Win]		; parent window
-		   [4 :X-Win]		; window
-		   [2 integerp]		; x
-		   [2 integerp]		; y
-		   [2 integerp]		; width
-		   [2 integerp]		; height
-		   [2 integerp]		; border width
-		   [1 booleanp]		; override-redirect
-		   [9 nil])
-		  2 ])
+                "CreateNotify"     
+               ([1 integerp]           ; detail
+                [2 integerp]           ; sequence
+                [4 :X-Win]             ; parent window
+                [4 :X-Win]             ; window
+                [2 integerp]           ; x
+                [2 integerp]           ; y
+                [2 integerp]           ; width
+                [2 integerp]           ; height
+                [2 integerp]           ; border width
+                [1 booleanp]           ; override-redirect
+                [9 nil])
+               2)
 (X-Event-define X-DestroyNotify "xdestroywindow" (nil nil event window)
-		[ "DestroyNotify"    
-		  ( [1 integerp]	; detail
-		    [2 integerp]	; sequence
-		    [4 :X-Win]		; event window
-		    [4 :X-Win]		; window
-		    [20 nil])
-		  3 ])
+                "DestroyNotify"    
+               ( [1 integerp]          ; detail
+                 [2 integerp]          ; sequence
+                 [4 :X-Win]            ; event window
+                 [4 :X-Win]            ; window
+                 [20 nil])
+               3 2)
 (X-Event-define X-UnmapNotify "xunmap" (nil nil event window from-configure)
-		[ "UnmapNotify"      
-		  ( [1 integerp]	; detail
-		    [2 integerp]	; sequence
-		    [4 :X-Win]		; event
-		    [4 :X-Win]		; window
-		    [1 booleanp]	; fromconfigure
-		    [19 nil])
-		  2 ])
+                "UnmapNotify"      
+               ( [1 integerp]          ; detail
+                 [2 integerp]          ; sequence
+                 [4 :X-Win]            ; event
+                 [4 :X-Win]            ; window
+                 [1 booleanp]          ; fromconfigure
+                 [19 nil])
+               3  2)
 (X-Event-define X-MapNotify "xmap" (nil nil event window override)
-		[ "MapNotify"
-		  ( [1 integerp]	; detail
-		    [2 integerp]	; sequence
-		    [4 :X-Win]		; event window
-		    [4 :X-Win]		; window
-		    [1 booleanp]	; override-redirect
-		    [19 nil])
-		  2 ])
+                "MapNotify"
+               ( [1 integerp]          ; detail
+                 [2 integerp]          ; sequence
+                 [4 :X-Win]            ; event window
+                 [4 :X-Win]            ; window
+                 [1 booleanp]          ; override-redirect
+                 [19 nil])
+               3 2)
 (X-Event-define X-MapRequest "xmaprequest" (nil nil parent window)
-		[ "MapRequest"
-		  ( [1 integerp]	; detail
-		    [2 integerp]	; sequence
-		    [4 :X-Win]		; parent window
-		    [4 :X-Win]		; window
-		    [20 nil])
-		  2 ])
+                "MapRequest"
+               ( [1 integerp]          ; detail
+                 [2 integerp]          ; sequence
+                 [4 :X-Win]            ; parent window
+                 [4 :X-Win]            ; window
+                 [20 nil])
+               3 2)
 (X-Event-define X-ReparentNotify "xreparent" (nil nil event window parent x y override)
-		[ "ReparentNotify"
-		  ( [1 integerp]	; detail
-		    [2 integerp]	; sequence
-		    [4 :X-Win]		; event
-		    [4 :X-Win]		; window
-		    [4 :X-Win]		; parent
-		    [2 integerp]	; x
-		    [2 integerp]	; y
-		    [1 integerp]	; override
-		    [11 nil])
-		  2 ])
+                "ReparentNotify"
+               ( [1 integerp]          ; detail
+                 [2 integerp]          ; sequence
+                 [4 :X-Win]            ; event
+                 [4 :X-Win]            ; window
+                 [4 :X-Win]            ; parent
+                 [2 integerp]          ; x
+                 [2 integerp]          ; y
+                 [1 integerp]          ; override
+                 [11 nil])
+               3 2)
 (X-Event-define X-ConfigureNotify "xconfigure" (nil nil event window above-sibling x y width height border-width override-redirect)
-		[ "ConfigureNotify"
-		  ( [1 integerp]	; detail
-		    [2 integerp]	; sequence
-		    [4 :X-Win]		; event
-		    [4 :X-Win]		; window
-		    [4 :X-Win]		; above-sibling
-		    [2 integerp]	; x
-		    [2 integerp]	; y
-		    [2 integerp]	; width
-		    [2 integerp]	; height
-		    [2 integerp]	; border-width
-		    [1 booleanp]	; override-redirect
-		    [5 nil] )
-		  2 ])
+                "ConfigureNotify"
+               ( [1 integerp]          ; detail
+                 [2 integerp]          ; sequence
+                 [4 :X-Win]            ; event
+                 [4 :X-Win]            ; window
+                 [4 :X-Win]            ; above-sibling
+                 [2 integerp]          ; x
+                 [2 integerp]          ; y
+                 [2 integerp]          ; width
+                 [2 integerp]          ; height
+                 [2 integerp]          ; border-width
+                 [1 booleanp]          ; override-redirect
+                 [5 nil] )
+               3 2)
 (X-Event-define X-ConfigureRequest "xconfigurerequest" (stackmode nil parent window sibling x y width height border-width value-mask)
-		[ "ConfigureRequest"
-		  ( [1 integerp]	; detail
-		    [2 integerp]	; sequence
-		    [4 :X-Win]		; parent window
-		    [4 :X-Win]		; window
-		    [4 :X-Win]		; sibling
-		    [2 integerp]	; x
-		    [2 integerp]	; y
-		    [2 integerp]	; width
-		    [2 integerp]	; height
-		    [2 integerp]	; border width
-		    [2 integerp]	; value mask
-		    [4 nil])
-		  2 ])
+                "ConfigureRequest"
+               ( [1 integerp]          ; detail
+                 [2 integerp]          ; sequence
+                 [4 :X-Win]            ; parent window
+                 [4 :X-Win]            ; window
+                 [4 :X-Win]            ; sibling
+                 [2 integerp]          ; x
+                 [2 integerp]          ; y
+                 [2 integerp]          ; width
+                 [2 integerp]          ; height
+                 [2 integerp]          ; border width
+                 [2 integerp]          ; value mask
+                 [4 nil])
+               3 2)
 (X-Event-define X-GravityNotify "xgravity" (nil nil event window x y)
-		[ "GravityNotify" 
-		  ([1 integerp]
-		   [2 integerp]
-		   [4 :X-Win]		; event window
-		   [4 :X-Win]		; window
-		   [2 integerp]		; x
-		   [2 integerp]		; y
-		   [16 nil])
-		  2 ])
+                "GravityNotify" 
+               ([1 integerp]
+                [2 integerp]
+                [4 :X-Win]             ; event window
+                [4 :X-Win]             ; window
+                [2 integerp]           ; x
+                [2 integerp]           ; y
+                [16 nil])
+               3 2)
 (X-Event-define X-ResizeRequest "xresizerequest" (nil nil window width height)
-		[ "ResizeRequest"
-		  ( [1 integerp]	; detail
-		    [2 integerp]	; sequence
-		    [4 :X-Win]		; window
-		    [2 integerp]	; width
-		    [2 integerp]	; height
-		    [20 nil] )
-		  2 ])
+                "ResizeRequest"
+               ( [1 integerp]          ; detail
+                 [2 integerp]          ; sequence
+                 [4 :X-Win]            ; window
+                 [2 integerp]          ; width
+                 [2 integerp]          ; height
+                 [20 nil] )
+               2)
 (X-Event-define X-CirculateNotify "xcirculate" (nil nil event window parent place)
-		[ "CirculateNotify" 
-		  ([1 integerp]
-		   [2 integerp]
-		   [4 :X-Win]		; event window
-		   [4 :X-Win]		; window
-		   [4 :X-Win]		; parent
-		   [1 integerp]		; place
-		   [15 nil])
-		  2 ])
+                "CirculateNotify" 
+               ([1 integerp]
+                [2 integerp]
+                [4 :X-Win]             ; event window
+                [4 :X-Win]             ; window
+                [4 :X-Win]             ; parent
+                [1 integerp]           ; place
+                [15 nil])
+               3 2)
 ;; The event field in the xcirculate record is really the parent when this
 ;; is used as a CirculateRequest instead of a CircluateNotify
 (X-Event-declare X-CirculateRequest
-		 [ "CirculateRequest"
-		  ([1 integerp]
-		   [2 integerp]
-		   [4 :X-Win]		; event window
-		   [4 :X-Win]		; window
-		   [4 :X-Win]		; parent
-		   [1 integerp]		; place
-		   [15 nil])
-		  2 ])
+                 "CirculateRequest"
+                ([1 integerp]
+                 [2 integerp]
+                 [4 :X-Win]            ; event window
+                 [4 :X-Win]            ; window
+                 [4 :X-Win]            ; parent
+                 [1 integerp]          ; place
+                 [15 nil])
+                3 2)
 
 (X-Event-define X-PropertyNotify "xproperty" (nil nil window atom time state)
-		[ "PropertyNotify"
-		  ( [1 integerp]
-		    [2 integerp]
-		    [4 :X-Win]		; window
-		    [4 :X-Atom]		; atom
-		    [4 integerp]	; time
-		    [1 integerp]	; state
-		    [15 nil]
-		    ) 2 ])
+                "PropertyNotify"
+               ( [1 integerp]
+                 [2 integerp]
+                 [4 :X-Win]            ; window
+                 [4 :X-Atom]           ; atom
+                 [4 integerp]          ; time
+                 [1 integerp]          ; state
+                 [15 nil])
+               2)
 (X-Event-define X-SelectionClear "xselectionclear" (nil nil time window atom)
-		[ "SelectionClear"
-		  ([1 integerp]
-		   [2 integerp]
-		   [4 integerp]		; time
-		   [4 :X-Win]		; window
-		   [4 :X-Atom]		; atom
-		   [16 nil])
-		  3 ])
+                "SelectionClear"
+               ([1 integerp]
+                [2 integerp]
+                [4 integerp]           ; time
+                [4 :X-Win]             ; window
+                [4 :X-Atom]            ; atom
+                [16 nil])
+               3)
 (X-Event-define X-SelectionRequest "xselectionrequest" (nil nil time owner requestor selection target property)
-		[ "SelectionRequest"
-		  ([1 integerp]
-		   [2 integerp]
-		   [4 integerp]		; time
-		   [4 :X-Win]		; owner
-		   [4 :X-Win]		; requestor
-		   [4 :X-Atom]		; selection atom
-		   [4 :X-Atom]		; target atom
-		   [4 :X-Atom]		; property atom
-		   [4 nil])
-		  4 ])
+                "SelectionRequest"
+               ([1 integerp]
+                [2 integerp]
+                [4 integerp]           ; time
+                [4 :X-Win]             ; owner
+                [4 :X-Win]             ; requestor
+                [4 :X-Atom]            ; selection atom
+                [4 :X-Atom]            ; target atom
+                [4 :X-Atom]            ; property atom
+                [4 nil])
+               4)
 (X-Event-define X-SelectionNotify "xselection" (nil nil time requestor selection target property)
-		[ "SelectionNotify"
-		  ([1 integerp]
-		   [2 integerp]
-		   [4 integerp]		; time
-		   [4 :X-Win]		; requestor
-		   [4 :X-Atom]		; selection atom
-		   [4 :X-Atom]		; target atom
-		   [4 :X-Atom]		; property atom
-		   [8 nil])
-		  3 ])
+                "SelectionNotify"
+               ([1 integerp]
+                [2 integerp]
+                [4 integerp]           ; time
+                [4 :X-Win]             ; requestor
+                [4 :X-Atom]            ; selection atom
+                [4 :X-Atom]            ; target atom
+                [4 :X-Atom]            ; property atom
+                [8 nil])
+               3)
 (X-Event-define X-ColormapNotify "xcolormap" (nil nil window colormap new state)
-		[ "ColormapNotify"
-		  ([1 integerp]		; detail
-		   [2 integerp]		; sequence
-		   [4 :X-Win]		; window
-		   [4 integerp]		; colormap
-		   [1 booleanp]		; new
-		   [1 booleanp]		; state
-		   [18 nil])
-		  2 ])
+                "ColormapNotify"
+               ([1 integerp]           ; detail
+                [2 integerp]           ; sequence
+                [4 :X-Win]             ; window
+                [4 integerp]           ; colormap
+                [1 booleanp]           ; new
+                [1 booleanp]           ; state
+                [18 nil])
+               2)
 (X-Event-define X-ClientMessage "xclient" (nil window atom msg)
-		[ "ClientMessage"
-		  ([1 length-1]		; format
-		   [2 integerp]		; sequence number
-		   [4 :X-Win]		; window
-		   [4 :X-Atom]		; atom
-		   ;; This reads in the correct number of integers of a type
-		   ;; specified by the format which is 8, 16, or 32.
-		   [(/ 20 (/ length-1 8)) ( [ (/ length-1 8) integerp ] ) ] )
-		  1 ])
+                "ClientMessage"
+               ([1 length-1]           ; format
+                [2 integerp]           ; sequence number
+                [4 :X-Win]             ; window
+                [4 :X-Atom]            ; atom
+                ;; This reads in the correct number of integers of a type
+                ;; specified by the format which is 8, 16, or 32.
+                [(/ 20 (/ length-1 8)) ( [ (/ length-1 8) integerp ] ) ] )
+               1)
 (X-Event-define X-MappingNotify "xmapping" (nil nil request first-keycode count)
-		[ "MappingNotify"
-		  ([1 integerp]
-		   [2 integerp]
-		   [1 integerp]		; request
-		   [1 integerp]		; firstKeyCode
-		   [1 integerp]		; count
-		   [25 nil])
-		  nil ])
+                "MappingNotify"
+               ([1 integerp]
+                [2 integerp]
+                [1 integerp]           ; request
+                [1 integerp]           ; firstKeyCode
+                [1 integerp]           ; count
+                [25 nil]))
 
 ;; error event
 (X-Event-define 0 "xerror" (code nil resourceid min-op maj-op)
-		["XError"
-		 ([1 integerp]		; err code
-		  [2 integerp]		; sequence
-		  [4 integerp]		; id
-		  [2 integerp]		; minor opcode
-		  [1 integerp]		; major opcode
-		  [21 nil])])
-		 
+                "XError"
+               ([1 integerp]           ; err code
+                [2 integerp]           ; sequence
+                [4 integerp]           ; id
+                [2 integerp]           ; minor opcode
+                [1 integerp]           ; major opcode
+                [21 nil]))
+                 
 ;;; All receive message types will exclude the first byte which IDs it.
 ;;
 ;; a symbol gets 'set, functions such as integerp mean turn it into that,
 
 (defconst X-connect-response
   (list [1 success]
-	(list [1 length-1]		; fail message len
-	      [2 integerp]		; major version
-	      [2 integerp]		; minor version
-	      [2 length-2]		; pad length
-	      [length-1 stringp]	; error conditions
-	      [(X-mod-4 length-1) nil]	; padding
-	      )
-	(list [1 nil]			; successful list (this is unused)
-	      [2 integerp]		; major version
-	      [2 integerp]		; minor version
-	      [2 length-1]		; len additional data (pad)
-	      [4 integerp]		; release number
-	      [4 integerp]		; resource id base
-	      [4 integerp]		; resource id mask
-	      [4 integerp]		; motion buffer size
-	      [2 length-2]		; vendor length
-	      [2 integerp]		; max request len
-	      [1 length-4]		; number of screens
-	      [1 length-3]		; number of formats in pix list
-	      [1 integerp]		; image byte order
-	      [1 integerp]		; bitmap byte order
-	      [1 integerp]		; bitmap format scanline thingy
-	      [1 integerp]		; bitmap format scanline pad
-	      [1 integerp]		; min keycode
-	      [1 integerp]		; max keycode
-	      [4 nil]			; unused
-	      [length-2 stringp]	; the vendor
-	      [(X-mod-4 length-2) nil]	; padding
-	      [length-3 		; sublist of formats
-	       ( [1 integerp]		; depth
-		 [1 integerp]		; bits/pixel
-		 [1 integerp]		; scanline-pad
-		 [5 nil] ) ]		; padding
-	      [length-4
-	       ( [4 integerp]		; root window
-		 [4 integerp]		; colormap
-		 [4 integerp]		; white-pixel
-		 [4 integerp]		; black-pixel
-		 [4 integerp]		; event-flags
-		 [2 integerp]		; screen-width
-		 [2 integerp]		; screen-height
-		 [2 integerp]		; milimeters width
-		 [2 integerp]		; milimeters height
-		 [2 integerp]		; min-installed-maps
-		 [2 integerp]		; max installed maps
-		 [4 integerp]		; visualid
-		 [1 integerp]		; backingstores
-		 [1 booleanp]		; save-unders
-		 [1 integerp]		; root depth
-		 [1 length-1]		; # depths in depth
-		 [length-1		; list of depths
-		  ( [1 integerp]	; depth
-		    [1 nil]
-		    [2 length-1]	; # visual types
-		    [4 nil]
-		    [length-1		; the visuals
-		     ( [4 integerp]	; visual id
-		       [1 integerp]	; class
-		       [1 integerp]	; bits/rgb value
-		       [2 integerp]	; colormap entities
-		       [4 integerp]	; red mask
-		       [4 integerp]	; green mask
-		       [4 integerp]	; blue mask
-		       [4 nil])
-		     ] )
-		  ] )
-	       ] )
-	)
+        (list [1 length-1]              ; fail message len
+              [2 integerp]              ; major version
+              [2 integerp]              ; minor version
+              [2 length-2]              ; pad length
+              [length-1 stringp]        ; error conditions
+              [(X-mod-4 length-1) nil]  ; padding
+              )
+        (list [1 nil]                   ; successful list (this is unused)
+              [2 integerp]              ; major version
+              [2 integerp]              ; minor version
+              [2 length-1]              ; len additional data (pad)
+              [4 integerp]              ; release number
+              [4 integerp]              ; resource id base
+              [4 integerp]              ; resource id mask
+              [4 integerp]              ; motion buffer size
+              [2 length-2]              ; vendor length
+              [2 integerp]              ; max request len
+              [1 length-4]              ; number of screens
+              [1 length-3]              ; number of formats in pix list
+              [1 integerp]              ; image byte order
+              [1 integerp]              ; bitmap byte order
+              [1 integerp]              ; bitmap format scanline thingy
+              [1 integerp]              ; bitmap format scanline pad
+              [1 integerp]              ; min keycode
+              [1 integerp]              ; max keycode
+              [4 nil]                   ; unused
+              [length-2 stringp]        ; the vendor
+              [(X-mod-4 length-2) nil]  ; padding
+              [length-3                 ; sublist of formats
+               ( [1 integerp]           ; depth
+                 [1 integerp]           ; bits/pixel
+                 [1 integerp]           ; scanline-pad
+                 [5 nil] ) ]            ; padding
+              [length-4
+               ( [4 integerp]           ; root window
+                 [4 integerp]           ; colormap
+                 [4 integerp]           ; white-pixel
+                 [4 integerp]           ; black-pixel
+                 [4 integerp]           ; event-flags
+                 [2 integerp]           ; screen-width
+                 [2 integerp]           ; screen-height
+                 [2 integerp]           ; milimeters width
+                 [2 integerp]           ; milimeters height
+                 [2 integerp]           ; min-installed-maps
+                 [2 integerp]           ; max installed maps
+                 [4 integerp]           ; visualid
+                 [1 integerp]           ; backingstores
+                 [1 booleanp]           ; save-unders
+                 [1 integerp]           ; root depth
+                 [1 length-1]           ; # depths in depth
+                 [length-1              ; list of depths
+                  ( [1 integerp]        ; depth
+                    [1 nil]
+                    [2 length-1]        ; # visual types
+                    [4 nil]
+                    [length-1           ; the visuals
+                     ( [4 integerp]     ; visual id
+                       [1 integerp]     ; class
+                       [1 integerp]     ; bits/rgb value
+                       [2 integerp]     ; colormap entities
+                       [4 integerp]     ; red mask
+                       [4 integerp]     ; green mask
+                       [4 integerp]     ; blue mask
+                       [4 nil])
+                     ] )
+                  ] )
+               ] )
+        )
   "Connection response structure.")
 
 (defun X-invalidate-cl-struct (cl-x)
 ;;; Protecting macros
 (defmacro X-Dpy-read-excursion (xdpy &rest forms)
   "Execute FORMS in reading mode."
-  `(let ((gc-cons-threshold most-positive-fixnum))	; inhibit GC'ing
+  `(let ((gc-cons-threshold most-positive-fixnum)) ; inhibit GC'ing
      (incf (X-Dpy-readings ,xdpy))
      (prog1
          (condition-case err
 
 (defun X-Dpy-send-read (xdpy s rf)
   "Send S to display XDPY and receive answer according to receive fields RF."
-  (let (reqid)
-    ;; Remember request id
-    (setq reqid (X-Dpy-rseq-id xdpy))
-
-    ;; Flush output buffer
-    (X-Dpy-send xdpy s)
-    (X-Dpy-send-flush xdpy)
-
+  (let ((reqid (X-Dpy-rseq-id xdpy)))   ; Remember request id
     (X-Dpy-read-excursion xdpy
-      (X-Dpy-parse-message rf reqid xdpy)
-      )))
+      ;; Flush output buffer
+      (X-Dpy-send xdpy s)
+      (X-Dpy-send-flush xdpy)
+      (X-Dpy-parse-message rf reqid xdpy))))
 
 ;;;###autoload
 (defvar X-default-timeout 60
     (while (< (length (X-Dpy-message-buffer xdpy)) num)
       (when (null (accept-process-output (X-Dpy-proc xdpy)
                                          (or to-secs X-default-timeout) (or to-msecs 0)))
-	;; Timeouted
<