2003-03-10 21:47:38 -05:00
|
|
|
;; Copyright (c) 2001-2003 by Norbert Freudemann, David Frese
|
|
|
|
|
|
|
|
;; TODO: pixmap-formats (XListPixmapFormats)
|
|
|
|
(define-record-type display :display
|
|
|
|
(make-display cpointer connection-number protocol-version protocol-revision
|
|
|
|
server-vendor image-byte-order bitmap-unit bitmap-pad
|
|
|
|
bitmap-bit-order vendor-release queue-length name
|
2003-03-25 13:27:18 -05:00
|
|
|
default-screen screens after-function wakeup)
|
2003-03-10 21:47:38 -05:00
|
|
|
display?
|
|
|
|
(cpointer display:cpointer)
|
|
|
|
(connection-number display:connection-number)
|
|
|
|
(protocol-version display:protocol-version)
|
|
|
|
(protocol-revision display:protocol-revision)
|
|
|
|
(server-vendor display:server-vendor)
|
|
|
|
(image-byte-order display:image-byte-order)
|
|
|
|
(bitmap-unit display:bitmap-unit)
|
|
|
|
(bitmap-pad display:bitmap-pad)
|
|
|
|
(bitmap-bit-order display:bitmap-bit-order)
|
|
|
|
(vendor-release display:vendor-release)
|
|
|
|
(queue-length display:queue-length)
|
|
|
|
(name display:name)
|
|
|
|
(default-screen display:default-screen)
|
|
|
|
(screens display:screens)
|
2003-03-25 13:27:18 -05:00
|
|
|
(after-function display:after-function set-display:after-function!)
|
|
|
|
(wakeup display:wakeup set-display:wakeup!))
|
2003-03-10 21:47:38 -05:00
|
|
|
|
|
|
|
(define-exported-binding "scx-display" :display)
|
|
|
|
|
2003-03-25 13:27:18 -05:00
|
|
|
;(define (wakeup-display dpy)
|
|
|
|
; (placeholder-set! dpy #t))
|
|
|
|
|
|
|
|
;(define (sleep-display dpy)
|
|
|
|
; (let ((ph (make-placeholder)))
|
|
|
|
; (set-display:wakeup! dpy ph)
|
|
|
|
; (placeholder-value ph)))
|
|
|
|
|
|
|
|
(define (initialize-display dpy)
|
|
|
|
; (set-display:wakeup! dpy (make-placeholder))
|
|
|
|
; ;; spawn a thread that weaks up a waiting wait-event call if the
|
|
|
|
; ;; inport has data available
|
|
|
|
; (spawn (lambda ()
|
|
|
|
; (let loop ()
|
|
|
|
; (block-on-message-inport dpy)
|
|
|
|
; (wakeup-display dpy)
|
|
|
|
; (loop))))
|
|
|
|
;; the after-function may also send a wakup
|
|
|
|
#t)
|
|
|
|
|
|
|
|
(define-exported-binding "scx-initialize-display" initialize-display)
|
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
(define (display-message-inport display)
|
|
|
|
(fdes->inport (display:connection-number display)))
|
|
|
|
|
2003-03-25 13:27:18 -05:00
|
|
|
(define (block-on-message-inport dpy . maybe-timeout)
|
|
|
|
(let ((port (display-message-inport dpy)))
|
|
|
|
(call-with-values
|
|
|
|
(lambda () (apply select (vector port) (vector) (vector) maybe-timeout))
|
|
|
|
(lambda (ready-read ready-write ex)
|
|
|
|
(member port (vector->list ready-read))))))
|
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
(define-enumerated-type byte-order :byte-order
|
|
|
|
byte-order? byte-orders byte-order-name byte-order-index
|
|
|
|
(lsb-first msb-first))
|
|
|
|
|
|
|
|
(define-exported-binding "scx-byte-order" :byte-order)
|
|
|
|
(define-exported-binding "scx-byte-orders" byte-orders)
|
|
|
|
|
|
|
|
(define-enumerated-type bit-order :bit-order
|
|
|
|
bit-order? bit-orders bit-order-name bit-order-index
|
|
|
|
(lsb-first msb-first))
|
|
|
|
|
|
|
|
(define-exported-binding "scx-bit-order" :bit-order)
|
|
|
|
(define-exported-binding "scx-bit-orders" bit-orders)
|
|
|
|
|
|
|
|
(define-record-type screen-format :screen-format ;; aka pixmap-format
|
|
|
|
(make-screen-format depth bits-per-pixel scanline-pad)
|
|
|
|
screen-format?
|
|
|
|
(depth screen-format:depth)
|
|
|
|
(bits-per-pixel screen-format:bits-per-pixel)
|
|
|
|
(scanline-pad screen-format:scanline-pad))
|
|
|
|
|
|
|
|
(define-exported-binding "scx-screen-format" :screen-format)
|
|
|
|
|
|
|
|
(define-record-type screen :screen
|
|
|
|
(make-screen cpointer display root-window width height width-mm
|
2003-03-13 08:47:17 -05:00
|
|
|
height-mm number root-depth default-visual default-gc
|
2003-03-10 21:47:38 -05:00
|
|
|
default-colormap white-pixel black-pixel max-maps min-maps
|
|
|
|
does-backing-store does-save-unders? event-mask)
|
2003-03-13 08:47:17 -05:00
|
|
|
;; maybe add depths ?? (TODO)
|
2003-03-10 21:47:38 -05:00
|
|
|
;; does event-mask change ?? (TODO)
|
|
|
|
screen?
|
|
|
|
(cpointer screen:cpointer)
|
|
|
|
(display screen:display)
|
|
|
|
(root-window screen:root-window)
|
|
|
|
(width screen:width)
|
|
|
|
(height screen:height)
|
|
|
|
(width-mm screen:width-mm)
|
|
|
|
(height-mm screen:height-mm)
|
2003-03-13 08:47:17 -05:00
|
|
|
(number screen:number)
|
2003-03-10 21:47:38 -05:00
|
|
|
(root-depth screen:root-depth)
|
|
|
|
(default-visual screen:default-visual)
|
|
|
|
(default-gc screen:default-gc)
|
|
|
|
(default-colormap screen:default-colormap)
|
|
|
|
(white-pixel screen:white-pixel)
|
|
|
|
(black-pixel screen:black-pixel)
|
|
|
|
(max-maps screen:max-maps)
|
|
|
|
(min-maps screen:min-maps)
|
|
|
|
(does-backing-store screen:does-backing-store)
|
|
|
|
(does-save-unders? screen:does-save-unders?)
|
|
|
|
(event-mask screen:event-mask))
|
|
|
|
|
|
|
|
(define-exported-binding "scx-screen" :screen)
|
|
|
|
|
|
|
|
;(define (screen:cells screen)
|
|
|
|
; (visual:map-entries (screen:default-visual screen)))
|
|
|
|
|
|
|
|
;; *** connect or disconnect to X server *****************************
|
|
|
|
|
|
|
|
(import-lambda-definition %open-display (display-name)
|
|
|
|
"scx_Open_Display")
|
2001-07-16 09:12:11 -04:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
;; returns a display or #f
|
2001-05-21 11:32:01 -04:00
|
|
|
(define (open-display . args)
|
|
|
|
(let ((display-name (if (null? args)
|
2003-03-10 21:47:38 -05:00
|
|
|
""
|
|
|
|
(if (null? (cdr args))
|
|
|
|
(cadr args)
|
|
|
|
(error "invalid arguments" (cdr args))))));; TODO
|
|
|
|
(%open-display display-name)))
|
2001-05-21 11:32:01 -04:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
(import-lambda-definition close-display (display)
|
|
|
|
"scx_Close_Display")
|
2001-05-21 11:32:01 -04:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
(define none 0)
|
|
|
|
(define parent-relative 1)
|
|
|
|
(define copy-from-parent 0)
|
|
|
|
(define pointer-window 0)
|
|
|
|
(define input-focus 1)
|
|
|
|
(define pointer-root 1)
|
|
|
|
(define any-property-type 0)
|
|
|
|
(define any-key 0)
|
|
|
|
(define all-temporary 0)
|
|
|
|
(define current-time 0)
|
|
|
|
(define no-symbol 0)
|
|
|
|
(define all-planes (- (arithmetic-shift 1 32) 1))
|
2001-05-21 11:32:01 -04:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
(import-lambda-definition display:last-request-read (display)
|
|
|
|
"scx_Display_Last_Request_Read")
|
2001-05-21 11:32:01 -04:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
;; *** convenience functions *****************************************
|
2001-05-21 11:32:01 -04:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
(define (default-root-window display)
|
2003-03-13 10:17:36 -05:00
|
|
|
(screen:root-window (display:default-screen display)))
|
2001-05-21 11:32:01 -04:00
|
|
|
|
2003-03-13 08:47:17 -05:00
|
|
|
(define (black-pixel display)
|
2003-03-13 10:17:36 -05:00
|
|
|
(screen:black-pixel (display:default-screen display)))
|
2003-03-13 08:47:17 -05:00
|
|
|
|
|
|
|
(define (white-pixel display)
|
2003-03-13 10:17:36 -05:00
|
|
|
(screen:white-pixel (display:default-screen display)))
|
2003-03-13 08:47:17 -05:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
(import-lambda-definition next-request (display)
|
|
|
|
"scx_Next_Request")
|
2001-05-21 11:32:01 -04:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
;; *** enable or disable synchronization *****************************
|
2001-05-21 11:32:01 -04:00
|
|
|
|
2003-03-25 13:27:18 -05:00
|
|
|
(define (synchronize dpy on?)
|
2003-03-10 21:47:38 -05:00
|
|
|
(if on?
|
2003-03-25 13:27:18 -05:00
|
|
|
(set-after-function! dpy
|
|
|
|
(lambda (dpy)
|
|
|
|
(display-sync dpy #f)))
|
|
|
|
(set-after-function! dpy #f)))
|
2001-05-21 11:32:01 -04:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
;; returns the previous after-function. An after-function is called
|
|
|
|
;; with the display object.
|
2001-05-21 11:32:01 -04:00
|
|
|
|
2003-03-25 13:27:18 -05:00
|
|
|
(define (general-after-function display)
|
|
|
|
(if (display:after-function display)
|
|
|
|
((display:after-function display) display)
|
|
|
|
;; else the default behaviour ;; TODO: check if this is the real one
|
|
|
|
(display-flush display))
|
|
|
|
)
|
|
|
|
;; if events are in the queue now, then wakeup a wait-event call
|
|
|
|
;;(if (> (events-queued display (queued-mode already)) 0)
|
|
|
|
;; (wakeup-display display)))
|
|
|
|
|
|
|
|
(define-exported-binding "scx-general-after-function" general-after-function)
|
2001-05-21 11:32:01 -04:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
(define (set-after-function! display fun)
|
|
|
|
(let ((prev (display:after-function display)))
|
|
|
|
(set-display:after-function! display fun)
|
|
|
|
prev))
|
2001-05-21 11:32:01 -04:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
;; *** handle output buffer or event queue ***************************
|
2001-05-21 11:32:01 -04:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
(import-lambda-definition display-flush (display)
|
|
|
|
"scx_Display_Flush")
|
2001-05-21 11:32:01 -04:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
(import-lambda-definition display-sync (display discard?)
|
|
|
|
"scx_Display_Sync")
|
2001-05-21 11:32:01 -04:00
|
|
|
|
2001-07-16 09:12:11 -04:00
|
|
|
;; display-no-op sends a NoOperation protocol request to the X server, thereby
|
|
|
|
;; exercising the connection. See XNoOp.
|
2001-05-21 11:32:01 -04:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
(import-lambda-definition display-no-op (display)
|
2001-07-31 10:54:53 -04:00
|
|
|
"scx_No_Op")
|
2001-05-21 11:32:01 -04:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
;; *** select input events *******************************************
|
2001-05-21 11:32:01 -04:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
(import-lambda-definition display-select-input (display window event-mask)
|
2001-10-09 11:33:45 -04:00
|
|
|
"scx_Display_Select_Input")
|