1 ;;; xlib-xinerama.el --- Xinerama support.
3 ;; Copyright (C) 2003-2005 by XWEM Org.
5 ;; Author: Zajcev Evgeny <zevlg@yandex.ru>
6 ;; Created: Mon Nov 17 19:23:03 MSK 2003
7 ;; Keywords: xlib, xwem
8 ;; X-CVS: $Id: xlib-xinerama.el,v 1.7 2005-04-04 19:55:29 lg Exp $
10 ;; This file is part of XWEM.
12 ;; XWEM is free software; you can redistribute it and/or modify it
13 ;; under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; XWEM is distributed in the hope that it will be useful, but WITHOUT
18 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
20 ;; License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with XEmacs; see the file COPYING. If not, write to the Free
24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 ;;; Synched up with: Not in FSF
37 (defconst X-XInerama-major 1)
38 (defconst X-XInerama-minor 1)
40 (defconst X-XInerama-op-QueryVersion 0)
41 (defconst X-XInerama-op-GetState 1)
42 (defconst X-XInerama-op-GetScreenCount 2)
43 (defconst X-XInerama-op-GetScreenSize 3)
45 (defconst X-XInerama-op-IsActive 4)
46 (defconst X-XInerama-op-QueryScreens 5)
48 (defun X-XIneramaQueryVersion (xdpy &optional major minor)
49 "On display XDPY query for version of XInerama extension."
50 (X-Dpy-p xdpy 'X-XIneramaQueryVersion)
52 (let* ((xin-ext (X-Dpy-get-extension xdpy "XINERAMA"))
54 (list (vector 1 (nth 4 xin-ext)) ; opcode
55 [1 X-XInerama-op-QueryVersion]
58 [2 (or major X-XInerama-major)]
59 [2 (or minor X-XInerama-minor)]))
60 (msg (X-Create-message ListOfFields))
62 (list [1 success] ;success field
64 (list [1 nil] ;not used
65 [2 integerp] ;sequence number
67 [2 integerp] ;major version
68 [2 integerp] ;minor version
71 (X-Dpy-send-read xdpy msg ReceiveFields))))
73 (defun X-XIneramaGetState (xdpy d)
74 "Get state of drawable D."
75 (X-Dpy-p xdpy 'X-XIneramaGetState)
77 (let* ((xin-ext (X-Dpy-get-extension xdpy "XINERAMA" 'X-XIneramaGetState))
79 (list (vector 1 (nth 4 xin-ext)) ; opcode
80 [1 X-XInerama-op-GetState]
82 [4 (X-Drawable-id d)]))
83 (msg (X-Create-message ListOfFields))
87 (list [1 integerp] ; state
88 [2 nil] ; sequence number
92 (r (X-Dpy-send-read xdpy msg ReceiveFields)))
95 (defun X-XIneramaGetScreenCount (xdpy d)
97 (X-Dpy-p xdpy 'X-XIneramaGetScreenCount)
99 (let* ((xin-ext (X-Dpy-get-extension xdpy "XINERAMA" 'X-XIneramaGetScreenCount))
101 (list (vector 1 (nth 4 xin-ext)) ; opcode
102 [1 X-XInerama-op-GetScreenCount]
104 [4 (X-Drawable-id d)]))
105 (msg (X-Create-message ListOfFields))
109 (list [1 integerp] ; screen count
110 [2 nil] ; sequence number
114 (r (X-Dpy-send-read xdpy msg ReceiveFields)))
117 (defun X-XIneramaGetScreenSize (xdpy d scr)
119 (X-Dpy-p xdpy 'X-XIneramaGetScreenSize)
121 (let* ((xin-ext (X-Dpy-get-extension xdpy "XINERAMA" 'X-XIneramaGetScreenSize))
123 (list (vector 1 (nth 4 xin-ext)) ; opcode
124 [1 X-XInerama-op-GetScreenSize]
126 [4 (X-Drawable-id d)]
128 (msg (X-Create-message ListOfFields))
132 (list [1 nil] ; unused
133 [2 nil] ; sequence number
136 [4 integerp] ; height
137 [4 integerp] ; window
138 [4 integerp] ; screen
140 (r (X-Dpy-send-read xdpy msg ReceiveFields)))
143 ;;; Alternative protocol
145 (defun X-XIneramaIsActive (xdpy)
146 "Return non-nil if XINERAMA is active."
147 (X-Dpy-p xdpy 'X-XIneramaIsActive)
149 (let* ((xin-ext (X-Dpy-get-extension xdpy "XINERAMA" 'X-XIneramaIsActive))
151 (list (vector 1 (nth 4 xin-ext)) ; opcode
152 [1 X-XInerama-op-IsActive]
155 (msg (X-Create-message ListOfFields))
159 (list [1 nil] ; unused
164 (r (X-Dpy-send-read xdpy msg ReceiveFields)))
165 (and (car r) (nth 1 r))))
167 (defun X-XIneramaQueryScreens (xdpy)
168 "On display XDPY query for XINERAMA screens."
169 (X-Dpy-p xdpy 'X-XIneramaIsActive)
171 (let* ((xin-ext (X-Dpy-get-extension xdpy "XINERAMA"))
173 (list (vector 1 (nth 4 xin-ext)) ; opcode
174 [1 X-XInerama-op-QueryScreens]
177 (msg (X-Create-message ListOfFields))
181 (list [1 nil] ; unused
184 [4 length-1] ; number
186 [(* 8 length-1) :X-Rect]))))
188 (X-Dpy-send-read xdpy msg ReceiveFields))))
191 (provide 'xlib-xinerama)
193 ;;; xlib-xinerama.el ends here