(start-gtk program-name (vector->list line)))))))))
(define (start-gtk name args)
+ (if (let ((s (get-environment-variable "DISPLAY")))
+ (and (string? s) (not (string-null? s))))
+ (let ((path (system-library-pathname "gtk-shim.so" #f)))
+ (if path
+ (if (file-loadable? path)
+ (start-gtk* name args)
+ (begin
+ (warn "Gtk shim not loadable")
+ args))
+ (begin
+ (warn "No Gtk shim")
+ args)))
+ (begin
+ (warn "DISPLAY not set")
+ args)))
+
+(define (start-gtk* name args)
;; Call start_gtk. Signals an error if gtk_init_check returns 0.
;; Returns a list of unused ARGS.
(let ((arg-count (guarantee-list-of-type->length
(define gtk-thread #f)
+;;; With the gtk-thread always running, the runtime system should no
+;;; longer use wait-for-io and thus never signal
+;;; condition-type:no-thread!
+
+;;; GC daemons cannot be allowed to run during a callback. After-gc
+;;; interrupts are currently serviced with interrupt-mask/timer-ok!,
+;;; which might allow a switch to a different thread, which might
+;;; return from a different callback.
+
+;;; The Gtk system's "GC cleanups" are run by gtk-thread sometime
+;;; after a flip. The secondary gc daemons are also run by gtk-thread
+;;; after some number of flips.
+
;; Number of GCs between applications of trigger-secondary-gc-daemons!
(define secondary-gc-rate 100)
-;;; With the following thread always running, the runtime system
-;;; should no longer use wait-for-io, nor need to signal
-;;; condition-type:no-thread!
-
-;;; Note that GC daemons cannot be allowed to run during a callback.
-;;; After-gc interrupts are currently serviced with
-;;; interrupt-mask/timer-ok!, which might allow a switch to a
-;;; different thread, which might return from a different callback.
+(define (gtk-thread-running?)
+ ;; Used by dependent systems, e.g. gtk-screen, to defer while the
+ ;; Gtks are unavailable, e.g. when "DISPLAY not set".
+ (and gtk-thread (memq (thread-execution-state gtk-thread)
+ '(RUNNING RUNNING-WITHOUT-PREEMPTION))))
(define (create-gtk-thread)
(if gtk-thread (error "A GTk thread already exists."))