1 ;;; xlib-vidmode.el --- XF86VidMode extension support.
3 ;; Copyright (C) 2004,2005 by XWEM Org.
5 ;; Author: Zajcev Evgeny <zevlg@yandex.ru>
6 ;; Created: Fri Jan 16 18:39:44 MSK 2004
7 ;; Keywords: xlib, xwem
8 ;; X-CVS: $Id: xlib-vidmode.el,v 1.5 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
36 (defconst X-XF86VidMode-major 2 "Major version of VidMode extension.")
37 (defconst X-XF86VidMode-minor 1 "Minor version of VidMode extension.")
39 (defconst X-XF86VidMode-op-QueryVersion 0)
40 (defconst X-XF86VidMode-op-GetModeLine 1 "Opcode to fetch current modeline from server.")
41 (defconst X-XF86VidMode-op-ModModeLine 2)
42 (defconst X-XF86VidMode-op-SwitchMode 3)
43 (defconst X-XF86VidMode-op-GetMonitor 4)
44 (defconst X-XF86VidMode-op-LockModeSwitch 5)
45 (defconst X-XF86VidMode-op-GetAllModeLines 6)
46 (defconst X-XF86VidMode-op-AddModeLine 7)
47 (defconst X-XF86VidMode-op-DeleteModeLine 8)
48 (defconst X-XF86VidMode-op-ValidateModeLine 9)
49 (defconst X-XF86VidMode-op-SwitchToMode 10)
50 (defconst X-XF86VidMode-op-GetViewPort 11)
51 (defconst X-XF86VidMode-op-SetViewPort 12)
53 ;; new for version 2.x of this extension
54 (defconst X-XF86VidMode-op-GetDotClocks 13)
55 (defconst X-XF86VidMode-op-SetClientVersion 14)
56 (defconst X-XF86VidMode-op-SetGamma 15 "Opcode to set new gamma.")
57 (defconst X-XF86VidMode-op-GetGamma 16 "Opcode to fetch current gamma.")
58 (defconst X-XF86VidMode-op-GetGammaRamp 17)
59 (defconst X-XF86VidMode-op-SetGammaRamp 18)
60 (defconst X-XF86VidMode-op-GetGammaRampSize 19)
64 (defun X-XF86VidModeQueryVersion (xdpy)
65 "On display XDPY query for version of XF86VidMode extension."
66 (X-Dpy-p xdpy 'X-XF86VidModeQueryVersion)
68 (let* ((xin-ext (X-Dpy-get-extension xdpy "XFree86-VidModeExtension" 'X-XF86VidModeQueryVersion))
70 (list (vector 1 (nth 4 xin-ext)) ; opcode
71 [1 X-XF86VidMode-op-QueryVersion]
73 (msg (X-Create-message ListOfFields))
75 (list [1 success] ;success field
77 (list [1 nil] ;not used
78 [2 integerp] ;sequence number
80 [2 integerp] ;major version
81 [2 integerp] ;minor version
83 (X-Dpy-send-read xdpy msg ReceiveFields)))
85 (defun X-XF86VidModeGetModeline (xdpy &optional screen-num)
86 "On display XDPY using XF86VidMode extension fetch current modeline."
87 (X-Dpy-p xdpy 'X-XF86VidModeGetModeline)
89 (let* ((xin-ext (X-Dpy-get-extension xdpy "XFree86-VidModeExtension" 'X-XF86VidModeGetModeline))
91 (list (vector 1 (nth 4 xin-ext)) ; opcode
92 [1 X-XF86VidMode-op-GetModeLine]
94 [2 (or screen-num 0)] ; screen
96 (msg (X-Create-message ListOfFields))
98 (list [1 success] ;success field
100 (list [1 nil] ;not used
101 [2 integerp] ;sequence number
103 [4 integerp] ;dotclock
104 [2 integerp] ;hdisplay
105 [2 integerp] ;hsyncstart
106 [2 integerp] ;hsyncend
109 [2 integerp] ;vdisplay
110 [2 integerp] ;vsyncstart
111 [2 integerp] ;vsyncend
114 [4 integerp])))) ; flags
115 (X-Dpy-send-read xdpy msg ReceiveFields)))
118 (defun X-XF86VidModeGetGamma (xdpy &optional screen-num)
119 "On display XDPY using XF86VidMode extension fetch current gamma."
120 (X-Dpy-p xdpy 'X-XF86VidModeGetGamma)
122 (let* ((xin-ext (X-Dpy-get-extension xdpy "XFree86-VidModeExtension" 'X-XF86VidModeGetGamma))
124 (list (vector 1 (nth 4 xin-ext)) ; opcode
125 [1 X-XF86VidMode-op-GetGamma]
127 [2 (or screen-num 0)] ; screen
130 (msg (X-Create-message ListOfFields))
132 (list [1 success] ;success field
134 (list [1 nil] ;not used
135 [2 integerp] ;sequence number
137 [4 integerp] ;red gamma
138 [4 integerp] ;green gamma
139 [4 integerp] ;blue gamma
141 (X-Dpy-send-read xdpy msg ReceiveFields)))
143 (defun X-XF86VidModeSetGamma (xdpy r g b &optional screen-num)
144 "On display XDPY using XF86VidMode extension fetch current gamma."
145 (X-Dpy-p xdpy 'X-XF86VidModeSetGamma)
147 (let* ((xin-ext (X-Dpy-get-extension xdpy "XFree86-VidModeExtension" 'X-XF86VidModeSetGamma))
149 (list (vector 1 (nth 4 xin-ext)) ; opcode
150 [1 X-XF86VidMode-op-SetGamma]
152 [2 (or screen-num 0)] ; screen
154 [4 (* 10000 r)] ; red gamma
155 [4 (* 10000 g)] ; green gamma
156 [4 (* 10000 b)] ; blue gamma
158 (msg (X-Create-message ListOfFields)))
159 (X-Dpy-send xdpy msg)))
161 ;; TODO: write other functions
165 (provide 'xlib-vidmode)
167 ;;; xlib-vidmode.el ends here