1 ;;; xwem-gamma.el --- XWEM addon used to adjust gamma.
3 ;; Copyright (C) 2004,2005 by XWEM Org.
5 ;; Author: Zajcev Evgeny <zevlg@yandex.ru>
6 ;; Steve Youngs <steve@youngs.au.com>
7 ;; Created: Tue Jan 20 13:10:28 MSK 2004
9 ;; X-CVS: $Id: xwem-gamma.el,v 1.7 2005-04-04 19:54:12 lg Exp $
11 ;; This file is part of XWEM.
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)
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.
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
28 ;;; Synched up with: Not in FSF
32 ;; `xwem-gamma' uses uses `xlib-vidmode' Xlib extension and
33 ;; `color-selector' package.
35 ;; To use it do something like:
37 ;; (xwem-gamma-widget (xwem-dpy))
41 (require 'xlib-vidmode)
42 (require 'color-selector)
47 (defface xwem-gamma-face
48 `((t (:foreground "#1a1a1a" :background "black")))
49 "Face used to adjust gamma.")
51 (defvar xwem-gamma-display nil
54 (defvar xwem-gamma-screen 0
59 (defun xwem-gamma-corector (selector)
60 "Using SELECTOR adjust gamma."
61 (let* ((k (/ 9.9 256))
62 (clist (color-selector-get-color selector))
63 (rg (+ 0.1 (* k (car clist))))
64 (gg (+ 0.1 (* k (cadr clist))))
65 (bg (+ 0.1 (* k (caddr clist)))))
66 (X-XF86VidModeSetGamma xwem-gamma-display rg gg bg xwem-gamma-screen)
67 (XFlush xwem-gamma-display)
68 (xwem-message 'nolog "New gamma: r=%f g=%f b=%f" rg gg bg)))
70 (defun xwem-gamma-widget (xdpy &optional screen-num)
71 "Start correcting gama on display XDPY and screen SCREEN-NUM."
72 (setq xwem-gamma-display xdpy)
73 (setq xwem-gamma-screen (or (and (numberp screen-num) screen-num) 0))
74 (color-selector-make-selector 'xwem-gamma-face 'foreground
75 'xwem-gamma-corector))
80 ;;; xwem-gamma.el ends here