diff --git a/Makefile b/Makefile index 733b0da..07c04ff 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ ### update this to fit your system -SCSH_PREFIX = /usr/local +SCSH_PREFIX = /afs/wsi/i386_fbsd43/scsh-0.6.1/ X11_PATH = /usr/X11R6 -LIB_DL = -ldl +LIB_DL = ### the following does not have to be changed (hopefully) SCHEME_INCLUDE = $(SCSH_PREFIX)/include @@ -53,6 +53,7 @@ SCM_FILES = scheme/xlib/types.scm \ scheme/xlib/text.scm scheme/xlib/utility.scm \ scheme/xlib/visual-type.scm scheme/xlib/visual.scm \ scheme/xlib/window-type.scm scheme/xlib/window.scm \ + scheme/xlib/sync-event.scm \ scheme/xlib/wm.scm \ scheme/libs/xpm.scm @@ -100,3 +101,6 @@ $(SCX): $(SCX_IMAGE) main.o $(OBJECTS) clean: rm -f $(SCX_VM) $(SCX) $(SCX_IMAGE) *.o c/*.o c/xlib/*.o c/libs/*.o + +tags: + find . -name "*.c" -or -name "*.h" -or -name "*.scm" | etags - diff --git a/scheme/xlib/sync-event.scm b/scheme/xlib/sync-event.scm new file mode 100644 index 0000000..74bc717 --- /dev/null +++ b/scheme/xlib/sync-event.scm @@ -0,0 +1,36 @@ +(define-record-type sync-x-event :sync-x-event + (really-make-sync-x-event event next) + sync-x-event? + (event sync-x-event-event) + (next really-next-sync-x-event really-set-next-sync-x-event)) + +(define (make-sync-x-event event) + (really-make-sync-x-event event (make-placeholder))) + +(define (next-sync-x-event sync-x-event) + (placeholder-value (really-make-sync-x-event sync-x-event))) + +(define (set-next-sync-x-event! sync-x-event next-sync-x-event) + (placeholder-set! + (really-next-sync-x-event sync-x-event) + next-sync-x-event)) + +(define (advance-most-recent-sync-x-event!) + (set! *most-recent-sync-x-event* + (next-sync-x-event *most-recent-sync-x-event*))) + +(define *most-recent-sync-x-event* (make-sync-x-event 'no-event)) + +(define (most-recent-sync-x-event) + *most-recent-sync-x-event*) + +(define (with-sync-x-events dpy thunk) + (spawn (lambda () + (let lp () + (let ((next (wait-event dpy))) + (set-next-sync-x-event! *most-recent-sync-x-event* + (make-sync-x-event next)) + (advance-most-recent-sync-x-event!))))) + (thunk)) + + diff --git a/scheme/xlib/xlib-interfaces.scm b/scheme/xlib/xlib-interfaces.scm index 59a97c4..2d46348 100644 --- a/scheme/xlib/xlib-interfaces.scm +++ b/scheme/xlib/xlib-interfaces.scm @@ -287,373 +287,382 @@ special-pixmap:none special-pixmap:copy-from-parent special-pixmap:parent-relative)) -(define-interface xlib-event-interface - (export event-ready? +(define-interface xlib-event-internal-interface + (export next-event + peek-event + event-ready? events-pending events-queued - ((queued-mode) :syntax) - next-event - peek-event - wait-event - send-event + ((queued-mode) :syntax))) + +(define-interface xlib-sync-x-events-interface + (export sync-x-event-event + most-recent-sync-x-event + with-sync-x-events + next-sync-x-event)) + +(define-interface xlib-event-interface + (export + wait-event + send-event - ((event-type) :syntax) - any-event-type - any-event-serial - any-event-send-event? - any-event-display - any-event-window + ((event-type) :syntax) + any-event-type + any-event-serial + any-event-send-event? + any-event-display + any-event-window - create-key-event - key-event? - key-event-type - key-event-serial - key-event-send-event? - key-event-display - key-event-window - key-event-root - key-event-subwindow - key-event-time - key-event-x - key-event-y - key-event-x-root - key-event-y-root - key-event-state - key-event-keycode - key-event-same-screen? + create-key-event + key-event? + key-event-type + key-event-serial + key-event-send-event? + key-event-display + key-event-window + key-event-root + key-event-subwindow + key-event-time + key-event-x + key-event-y + key-event-x-root + key-event-y-root + key-event-state + key-event-keycode + key-event-same-screen? - create-button-event - button-event? - button-event-type - button-event-serial - button-event-send-event? - button-event-display - button-event-window - button-event-root - button-event-subwindow - button-event-time - button-event-x - button-event-y - button-event-x-root - button-event-y-root - button-event-state - button-event-button - button-event-same-screen? + create-button-event + button-event? + button-event-type + button-event-serial + button-event-send-event? + button-event-display + button-event-window + button-event-root + button-event-subwindow + button-event-time + button-event-x + button-event-y + button-event-x-root + button-event-y-root + button-event-state + button-event-button + button-event-same-screen? - create-motion-event - motion-event? - motion-event-type - motion-event-serial - motion-event-send-event? - motion-event-display - motion-event-window - motion-event-root - motion-event-subwindow - motion-event-time - motion-event-x - motion-event-y - motion-event-x-root - motion-event-y-root - motion-event-state - motion-event-is-hint? - motion-event-same-screen? + create-motion-event + motion-event? + motion-event-type + motion-event-serial + motion-event-send-event? + motion-event-display + motion-event-window + motion-event-root + motion-event-subwindow + motion-event-time + motion-event-x + motion-event-y + motion-event-x-root + motion-event-y-root + motion-event-state + motion-event-is-hint? + motion-event-same-screen? - create-crossing-event - crossing-event? - crossing-event-type - crossing-event-serial - crossing-event-send-event? - crossing-event-display - crossing-event-window - crossing-event-root - crossing-event-subwindow - crossing-event-time - crossing-event-x - crossing-event-y - crossing-event-x-root - crossing-event-y-root - crossing-event-mode - crossing-event-detail - crossing-event-same-screen? - crossing-event-focus? - crossing-event-state + create-crossing-event + crossing-event? + crossing-event-type + crossing-event-serial + crossing-event-send-event? + crossing-event-display + crossing-event-window + crossing-event-root + crossing-event-subwindow + crossing-event-time + crossing-event-x + crossing-event-y + crossing-event-x-root + crossing-event-y-root + crossing-event-mode + crossing-event-detail + crossing-event-same-screen? + crossing-event-focus? + crossing-event-state - create-focus-change-event - focus-change-event? - focus-change-event-type - focus-change-event-serial - focus-change-event-send-event? - focus-change-event-display - focus-change-event-window - focus-change-event-mode - focus-change-event-detail + create-focus-change-event + focus-change-event? + focus-change-event-type + focus-change-event-serial + focus-change-event-send-event? + focus-change-event-display + focus-change-event-window + focus-change-event-mode + focus-change-event-detail - create-expose-event - expose-event? - expose-event-type - expose-event-serial - expose-event-send-event? - expose-event-display - expose-event-window - expose-event-x - expose-event-y - expose-event-width - expose-event-height - expose-event-count + create-expose-event + expose-event? + expose-event-type + expose-event-serial + expose-event-send-event? + expose-event-display + expose-event-window + expose-event-x + expose-event-y + expose-event-width + expose-event-height + expose-event-count - create-graphics-expose-event - graphics-expose-event? - graphics-expose-event-type - graphics-expose-event-serial - graphics-expose-event-send-event? - graphics-expose-event-display - graphics-expose-event-drawable - graphics-expose-event-x - graphics-expose-event-y - graphics-expose-event-width - graphics-expose-event-height - graphics-expose-event-major-code - graphics-expose-event-minor-code + create-graphics-expose-event + graphics-expose-event? + graphics-expose-event-type + graphics-expose-event-serial + graphics-expose-event-send-event? + graphics-expose-event-display + graphics-expose-event-drawable + graphics-expose-event-x + graphics-expose-event-y + graphics-expose-event-width + graphics-expose-event-height + graphics-expose-event-major-code + graphics-expose-event-minor-code - create-no-expose-event - no-expose-event? - no-expose-event-type - no-expose-event-serial - no-expose-event-send-event? - no-expose-event-display - no-expose-event-drawable - no-expose-event-major-code - no-expose-event-minor-code + create-no-expose-event + no-expose-event? + no-expose-event-type + no-expose-event-serial + no-expose-event-send-event? + no-expose-event-display + no-expose-event-drawable + no-expose-event-major-code + no-expose-event-minor-code - create-visibility-event - visibility-event? - visibility-event-type - visibility-event-serial - visibility-event-send-event? - visibility-event-display - visibility-event-window - visibility-event-state + create-visibility-event + visibility-event? + visibility-event-type + visibility-event-serial + visibility-event-send-event? + visibility-event-display + visibility-event-window + visibility-event-state - create-create-window-event - create-window-event? - create-window-event-type - create-window-event-serial - create-window-event-send-event? - create-window-event-display - create-window-event-parent - create-window-event-window - create-window-event-x - create-window-event-y - create-window-event-width - create-window-event-height - create-window-event-border-width - create-window-event-override-redirect? + create-create-window-event + create-window-event? + create-window-event-type + create-window-event-serial + create-window-event-send-event? + create-window-event-display + create-window-event-parent + create-window-event-window + create-window-event-x + create-window-event-y + create-window-event-width + create-window-event-height + create-window-event-border-width + create-window-event-override-redirect? - create-destroy-window-event - destroy-window-event? - destroy-window-event-type - destroy-window-event-serial - destroy-window-event-send-event? - destroy-window-event-display - destroy-window-event-event - destroy-window-event-window + create-destroy-window-event + destroy-window-event? + destroy-window-event-type + destroy-window-event-serial + destroy-window-event-send-event? + destroy-window-event-display + destroy-window-event-event + destroy-window-event-window - create-unmap-event - unmap-event? - unmap-event-type - unmap-event-serial - unmap-event-send-event? - unmap-event-display - unmap-event-event - unmap-event-window - unmap-event-from-configure? + create-unmap-event + unmap-event? + unmap-event-type + unmap-event-serial + unmap-event-send-event? + unmap-event-display + unmap-event-event + unmap-event-window + unmap-event-from-configure? - create-map-event - map-event? - map-event-type - map-event-serial - map-event-send-event? - map-event-display - map-event-event - map-event-window - map-event-override-redirect? + create-map-event + map-event? + map-event-type + map-event-serial + map-event-send-event? + map-event-display + map-event-event + map-event-window + map-event-override-redirect? - create-map-request-event - map-request-event? - map-request-event-type - map-request-event-serial - map-request-event-send-event? - map-request-event-display - map-request-event-parent - map-request-event-window + create-map-request-event + map-request-event? + map-request-event-type + map-request-event-serial + map-request-event-send-event? + map-request-event-display + map-request-event-parent + map-request-event-window - create-reparent-event - reparent-event? - reparent-event-type - reparent-event-serial - reparent-event-send-event? - reparent-event-display - reparent-event-event - reparent-event-window - reparent-event-parent - reparent-event-x - reparent-event-y - reparent-event-override-redirect? + create-reparent-event + reparent-event? + reparent-event-type + reparent-event-serial + reparent-event-send-event? + reparent-event-display + reparent-event-event + reparent-event-window + reparent-event-parent + reparent-event-x + reparent-event-y + reparent-event-override-redirect? - create-configure-event - configure-event? - configure-event-type - configure-event-serial - configure-event-send-event? - configure-event-display - configure-event-event - configure-event-window - configure-event-x - configure-event-y - configure-event-width - configure-event-height - configure-event-border-width - configure-event-above - configure-event-override-redirect? + create-configure-event + configure-event? + configure-event-type + configure-event-serial + configure-event-send-event? + configure-event-display + configure-event-event + configure-event-window + configure-event-x + configure-event-y + configure-event-width + configure-event-height + configure-event-border-width + configure-event-above + configure-event-override-redirect? - create-gravity-event - gravity-event? - gravity-event-type - gravity-event-serial - gravity-event-send-event? - gravity-event-display - gravity-event-event - gravity-event-window - gravity-event-x - gravity-event-y + create-gravity-event + gravity-event? + gravity-event-type + gravity-event-serial + gravity-event-send-event? + gravity-event-display + gravity-event-event + gravity-event-window + gravity-event-x + gravity-event-y - create-resize-request-event - resize-request-event? - resize-request-event-type - resize-request-event-serial - resize-request-event-send-event? - resize-request-event-display - resize-request-event-window - resize-request-event-width - resize-request-event-height + create-resize-request-event + resize-request-event? + resize-request-event-type + resize-request-event-serial + resize-request-event-send-event? + resize-request-event-display + resize-request-event-window + resize-request-event-width + resize-request-event-height - create-configure-request-event - configure-request-event? - configure-request-event-type - configure-request-event-serial - configure-request-event-send-event? - configure-request-event-display - configure-request-event-parent - configure-request-event-window - configure-request-event-window-change-alist + create-configure-request-event + configure-request-event? + configure-request-event-type + configure-request-event-serial + configure-request-event-send-event? + configure-request-event-display + configure-request-event-parent + configure-request-event-window + configure-request-event-window-change-alist - create-circulate-event - circulate-event? - circulate-event-type - circulate-event-serial - circulate-event-send-event? - circulate-event-display - circulate-event-event - circulate-event-window - circulate-event-place + create-circulate-event + circulate-event? + circulate-event-type + circulate-event-serial + circulate-event-send-event? + circulate-event-display + circulate-event-event + circulate-event-window + circulate-event-place - create-circulate-request-event - circulate-request-event? - circulate-request-event-type - circulate-request-event-serial - circulate-request-event-send-event? - circulate-request-event-display - circulate-request-event-parent - circulate-request-event-window - circulate-request-event-place + create-circulate-request-event + circulate-request-event? + circulate-request-event-type + circulate-request-event-serial + circulate-request-event-send-event? + circulate-request-event-display + circulate-request-event-parent + circulate-request-event-window + circulate-request-event-place - create-property-event - property-event? - property-event-type - property-event-serial - property-event-send-event? - property-event-display - property-event-window - property-event-atom - property-event-time - property-event-state + create-property-event + property-event? + property-event-type + property-event-serial + property-event-send-event? + property-event-display + property-event-window + property-event-atom + property-event-time + property-event-state - create-selection-clear-event - selection-clear-event? - selection-clear-event-type - selection-clear-event-serial - selection-clear-event-send-event? - selection-clear-event-display - selection-clear-event-window - selection-clear-event-selection - selection-clear-event-time + create-selection-clear-event + selection-clear-event? + selection-clear-event-type + selection-clear-event-serial + selection-clear-event-send-event? + selection-clear-event-display + selection-clear-event-window + selection-clear-event-selection + selection-clear-event-time - create-selection-request-event - selection-request-event? - selection-request-event-type - selection-request-event-serial - selection-request-event-send-event? - selection-request-event-display - selection-request-event-owner - selection-request-event-requestor - selection-request-event-selection - selection-request-event-target - selection-request-event-property - selection-request-event-time + create-selection-request-event + selection-request-event? + selection-request-event-type + selection-request-event-serial + selection-request-event-send-event? + selection-request-event-display + selection-request-event-owner + selection-request-event-requestor + selection-request-event-selection + selection-request-event-target + selection-request-event-property + selection-request-event-time - create-selection-event - selection-event? - selection-event-type - selection-event-serial - selection-event-send-event? - selection-event-display - selection-event-requestor - selection-event-selection - selection-event-target - selection-event-property - selection-event-time + create-selection-event + selection-event? + selection-event-type + selection-event-serial + selection-event-send-event? + selection-event-display + selection-event-requestor + selection-event-selection + selection-event-target + selection-event-property + selection-event-time - create-colormap-event - colormap-event? - colormap-event-type - colormap-event-serial - colormap-event-send-event? - colormap-event-display - colormap-event-window - colormap-event-colormap - colormap-event-new? - colormap-event-state + create-colormap-event + colormap-event? + colormap-event-type + colormap-event-serial + colormap-event-send-event? + colormap-event-display + colormap-event-window + colormap-event-colormap + colormap-event-new? + colormap-event-state - create-client-message-event - client-message-event? - client-message-event-type - client-message-event-serial - client-message-event-send-event? - client-message-event-display - client-message-event-window - client-message-event-message-type - client-message-event-format - client-message-event-data + create-client-message-event + client-message-event? + client-message-event-type + client-message-event-serial + client-message-event-send-event? + client-message-event-display + client-message-event-window + client-message-event-message-type + client-message-event-format + client-message-event-data - create-mapping-event - mapping-event? - mapping-event-type - mapping-event-serial - mapping-event-send-event? - mapping-event-display - mapping-event-window - mapping-event-request - mapping-event-first-keycode - mapping-event-count + create-mapping-event + mapping-event? + mapping-event-type + mapping-event-serial + mapping-event-send-event? + mapping-event-display + mapping-event-window + mapping-event-request + mapping-event-first-keycode + mapping-event-count - create-keymap-event - keymap-event? - keymap-event-type - keymap-event-serial - keymap-event-send-event? - keymap-event-display - keymap-event-bit-vector -)) + create-keymap-event + keymap-event? + keymap-event-type + keymap-event-serial + keymap-event-send-event? + keymap-event-display + keymap-event-bit-vector + )) (define-interface xlib-text-interface (export text-width @@ -909,4 +918,5 @@ xlib-grab-interface xlib-visual-interface xlib-region-interface + xlib-sync-x-events-interface )) diff --git a/scheme/xlib/xlib-packages.scm b/scheme/xlib/xlib-packages.scm index 1f6424b..f8f902f 100644 --- a/scheme/xlib/xlib-packages.scm +++ b/scheme/xlib/xlib-packages.scm @@ -79,7 +79,8 @@ finite-types) (files graphics)) -(define-structure xlib-event xlib-event-interface +(define-structures ((xlib-event xlib-event-interface) + (xlib-event-internal xlib-event-internal-interface)) (open scsh-level-0 ;; for port->channel scheme external-calls @@ -91,6 +92,14 @@ xlib-internal-types) (files event event-types)) +(define-structure xlib-sync-x-events xlib-sync-x-events-interface + (open scheme + placeholders + define-record-types + threads + xlib-event) + (files sync-event)) + (define-structure xlib-font xlib-font-interface (open scheme signals ;; for error @@ -231,5 +240,6 @@ xlib-grab xlib-visual xlib-region + xlib-sync-x-events ) (optimize auto-integrate))