[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
local-utils.scm
From: |
Thien-Thi Nguyen |
Subject: |
local-utils.scm |
Date: |
Sun, 08 Sep 2002 13:01:52 -0700 |
playing w/ X... (see next post).
thi
___________________________________________________
;;; local-utils.scm
;;; Copyright (C) 2002 Thien-Thi Nguyen
;;; This program is part of xplay, released under GNU GPL v2 with ABSOLUTELY
;;; NO WARRANTY. See http://www.gnu.org/copyleft/gpl.txt for details.
;;; Version: 0.20020908
;;; Commentary:
;; save as ./local-utils.scm
;;
;; hardcoded values in compute-center-[xy] reflect hardcoded values in
;; guile-xlib's xlib.c.
;;; Code:
(define-module (local-utils)
:use-module (xlib core)
:use-module (xlib xlib)
:export (new-d/w/gc/show/clear
simple-kick
root->black!
compute-center-x
compute-center-y))
(define (new-d/w/gc/show/clear)
(let* ((root? (member "root" (command-line))) ; ugh
(d (x-open-display!))
(w (if root?
(x-root-window d)
(x-create-window! d)))
(gc (if root?
(x-create-gc! w
GCForeground (x-white-pixel d)
GCBackground (x-black-pixel d)
;;GCFillStyle FillSolid
)
(x-default-gc d))))
(values d w gc
(lambda () (or root? (x-map-window! w)))
(lambda () (and root? (root->black! d))))))
(define (simple-kick proc)
(call-with-values new-d/w/gc/show/clear proc))
(define (root->black! d)
(let* ((w (x-display-width d))
(h (x-display-height d))
(r (x-root-window d))
(gc (x-create-gc! r
GCForeground (x-black-pixel d)
GCBackground (x-white-pixel d))))
(do ((x 0 (1+ x)))
((= w x))
(x-draw-line! r gc x 0 x h))
(x-flush! d)))
(define (compute-center-x d w)
(inexact->exact (/ (if (eq? w (x-root-window d))
(x-display-width d)
600)
2)))
(define (compute-center-y d w)
(inexact->exact (/ (if (eq? w (x-root-window d))
(x-display-height d)
400)
2)))
;;; local-utils.scm ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- local-utils.scm,
Thien-Thi Nguyen <=