forked from sharplispers/clx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
screensaver.lisp
69 lines (60 loc) · 2.7 KB
/
screensaver.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
;;; -*- Mode: Lisp; Syntax: Common-Lisp; Package: XLIB; -*-
;;; ---------------------------------------------------------------------------
;;; Title: X11 MIT Screensaver extension
;;; Created: 2005-08-28 01:41
;;; Author: Istvan Marko <mi-clx@kismala.com>
;;; ---------------------------------------------------------------------------
;;; (c) copyright 2005 by Istvan Marko
;;;
;;; Permission is granted to any individual or institution to use,
;;; copy, modify, and distribute this software, provided that this
;;; complete copyright and permission notice is maintained, intact, in
;;; all copies and supporting documentation.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
;;;
;;; Description:
;;;
;;; This is a partial interface to the MIT-SCREEN-SAVER
;;; extension. Only the ScreenSaverQueryVersion and
;;; ScreenSaverQueryInfo requests are implemented because I couldn't
;;; think of a use for the rest. In fact, the only use I see for this
;;; extension is screen-saver-get-idle which provides and easy way to
;;; find out how long has it been since the last keyboard or mouse
;;; activity.
;;; A description of this extension can be found at
;;; doc/hardcopy/saver/saver.PS.gz in the X11 distribution.
(in-package :xlib)
(export '(screen-saver-query-version
screen-saver-query-info
screen-saver-get-idle)
:xlib)
(define-extension "MIT-SCREEN-SAVER")
(defun screen-saver-query-version (display)
(with-buffer-request-and-reply (display (extension-opcode display "MIT-SCREEN-SAVER")
nil)
((data 0)
(card8 1) ;client major version
(card8 0) ;client minor version
(card16 0)) ; unused
(values
(card16-get 8) ; server major version
(card16-get 10)))) ; server minor version
(defun screen-saver-query-info (display drawable)
(with-buffer-request-and-reply (display (extension-opcode display "MIT-SCREEN-SAVER")
nil)
((data 1)
(drawable drawable))
(values
(card8-get 1) ; state: off, on, disabled
(window-get 8) ; screen saver window if active
(card32-get 12) ; tilorsince msecs. how soon before the screen saver kicks in or how long has it been active
(card32-get 16) ; idle msecs
(card8-get 24)))) ; kind: Blanked, Internal, External
(defun screen-saver-get-idle (display drawable)
"How long has it been since the last keyboard or mouse input"
(multiple-value-bind (state window tilorsince idle kind) (screen-saver-query-info display drawable)
(declare (ignore state window kind))
(values idle tilorsince)))