diff --git a/contrib/x11/concurrent-widgets.factor b/contrib/x11/concurrent-widgets.factor new file mode 100644 index 0000000000..1758438059 --- /dev/null +++ b/contrib/x11/concurrent-widgets.factor @@ -0,0 +1,119 @@ + +IN: concurrent-widgets +USING: namespaces kernel hashtables math generic threads concurrency xlib x ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +TUPLE: window display id ; + +! dpy get create-window + +! window-object [ { 100 100 } move-window ] with-window-object + +: create-window-object + dpy get create-window ; + +: with-window-object ( quot -- ) + [ swap dup window-display dpy set window-id win set call ] with-scope ; inline + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +! window-table add-to-window-table +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +SYMBOL: window-table + +10 window-table set + +: add-to-window-table ( -- ) +dup window-id window-table get set-hash ; + +! The window-table is keyed on window ids. If support is added for +! multiple displays, then perhaps there should be a window table for +! each open display. + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +! handle-event +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +GENERIC: handle-key-press-event +GENERIC: handle-key-release-event +GENERIC: handle-button-press-event +GENERIC: handle-button-release-event +GENERIC: handle-expose-event + +: handle-event ( event obj -- ) +over XAnyEvent-type +dup KeyPress = [ handle-key-press-event ] when +dup KeyRelease = [ handle-key-release-event ] when +dup ButtonPress = [ drop handle-button-press-event ] when +dup ButtonRelease = [ handle-button-release-event ] when +dup Expose = [ drop handle-expose-event ] when ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +TUPLE: label text ; + +: create-label ( text --