ui.backend.gtk: split off unix io support into ui.backend.gtk.io.unix;
parent
73a07eee31
commit
e9515c1a9c
|
@ -3,12 +3,12 @@
|
|||
USING: accessors alien.accessors alien.c-types alien.data
|
||||
alien.strings arrays assocs classes.struct command-line destructors
|
||||
gdk.ffi gdk.gl.ffi glib.ffi gobject-introspection.standard-types
|
||||
gobject.ffi gtk.ffi gtk.gl.ffi io.backend io.backend.unix.multiplexers
|
||||
io.encodings.utf8 io.thread kernel libc literals locals math
|
||||
math.bitwise math.order math.vectors namespaces sequences strings
|
||||
system threads ui ui.backend ui.clipboards ui.event-loop ui.gadgets
|
||||
ui.gadgets.editors ui.gadgets.private ui.gadgets.worlds ui.gestures
|
||||
ui.pixel-formats ui.pixel-formats.private ui.private ;
|
||||
gobject.ffi gtk.ffi gtk.gl.ffi io.encodings.utf8 kernel libc literals
|
||||
locals math math.bitwise math.order math.vectors namespaces sequences
|
||||
strings system threads ui ui.backend ui.backend.gtk.io ui.clipboards
|
||||
ui.event-loop ui.gadgets ui.gadgets.editors ui.gadgets.private
|
||||
ui.gadgets.worlds ui.gestures ui.pixel-formats
|
||||
ui.pixel-formats.private ui.private vocabs.loader ;
|
||||
IN: ui.backend.gtk
|
||||
|
||||
SINGLETON: gtk-ui-backend
|
||||
|
@ -51,48 +51,7 @@ M: gtk-clipboard set-clipboard-contents
|
|||
gtk_clipboard_get <gtk-clipboard> swap set-global
|
||||
] 2bi@ ;
|
||||
|
||||
! IO events
|
||||
|
||||
: io-source-prepare ( source timeout -- ? )
|
||||
2drop f ;
|
||||
|
||||
: io-source-check ( source -- ? )
|
||||
poll_fds>> 0 g_slist_nth_data GPollFD memory>struct
|
||||
revents>> 0 = not ;
|
||||
|
||||
: io-source-dispatch ( source callback user_data -- ? )
|
||||
3drop
|
||||
0 mx get wait-for-events
|
||||
yield t ;
|
||||
|
||||
CONSTANT: poll-fd-events
|
||||
flags{
|
||||
G_IO_IN
|
||||
G_IO_OUT
|
||||
G_IO_PRI
|
||||
G_IO_ERR
|
||||
G_IO_HUP
|
||||
G_IO_NVAL
|
||||
}
|
||||
|
||||
: create-poll-fd ( -- poll-fd )
|
||||
GPollFD malloc-struct &free
|
||||
mx get fd>> >>fd
|
||||
poll-fd-events >>events ;
|
||||
|
||||
HOOK: init-io-event-source io-backend ( -- )
|
||||
|
||||
M: f init-io-event-source ;
|
||||
M: c-io-backend init-io-event-source ;
|
||||
|
||||
M: object init-io-event-source
|
||||
GSourceFuncs malloc-struct &free
|
||||
[ io-source-prepare ] GSourceFuncsPrepareFunc >>prepare
|
||||
[ io-source-check ] GSourceFuncsCheckFunc >>check
|
||||
[ io-source-dispatch ] GSourceFuncsDispatchFunc >>dispatch
|
||||
GSource heap-size g_source_new &g_source_unref
|
||||
[ create-poll-fd g_source_add_poll ]
|
||||
[ f g_source_attach drop ] bi ;
|
||||
! Timeouts
|
||||
|
||||
SYMBOL: next-timeout
|
||||
|
||||
|
@ -546,7 +505,6 @@ M: gtk-ui-backend (with-ui)
|
|||
0 gint <ref> f void* <ref> gtk_gl_init
|
||||
init-clipboard
|
||||
start-ui
|
||||
stop-io-thread
|
||||
[
|
||||
init-io-event-source
|
||||
init-timeout
|
||||
|
@ -557,4 +515,7 @@ M: gtk-ui-backend (with-ui)
|
|||
|
||||
gtk-ui-backend ui-backend set-global
|
||||
|
||||
{ "ui.backend.gtk" "io.backend.unix" }
|
||||
"ui.backend.gtk.io.unix" require-when
|
||||
|
||||
[ "ui.tools" ] main-vocab-hook set-global
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Anton Gorenko
|
|
@ -0,0 +1,8 @@
|
|||
! Copyright (C) 2011 Anton Gorenko.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: io.backend kernel ;
|
||||
IN: ui.backend.gtk.io
|
||||
|
||||
HOOK: init-io-event-source io-backend ( -- )
|
||||
|
||||
M: object init-io-event-source ;
|
|
@ -0,0 +1 @@
|
|||
Anton Gorenko
|
|
@ -0,0 +1,43 @@
|
|||
! Copyright (C) 2011 Anton Gorenko.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors alien.c-types classes.struct glib.ffi
|
||||
io.backend.unix.multiplexers io.thread kernel libc literals namespaces
|
||||
system threads ui.backend.gtk.io ;
|
||||
IN: ui.backend.gtk.io.unix
|
||||
|
||||
: prepare ( source timeout -- ? )
|
||||
2drop f ;
|
||||
|
||||
: check ( source -- ? )
|
||||
poll_fds>> 0 g_slist_nth_data GPollFD memory>struct
|
||||
revents>> 0 = not ;
|
||||
|
||||
: dispatch ( source callback user-data -- ? )
|
||||
3drop
|
||||
0 mx get wait-for-events
|
||||
yield t ;
|
||||
|
||||
CONSTANT: poll-fd-events
|
||||
flags{
|
||||
G_IO_IN
|
||||
G_IO_OUT
|
||||
G_IO_PRI
|
||||
G_IO_ERR
|
||||
G_IO_HUP
|
||||
G_IO_NVAL
|
||||
}
|
||||
|
||||
: <poll-fd> ( -- poll-fd )
|
||||
GPollFD malloc-struct &free
|
||||
mx get fd>> >>fd
|
||||
poll-fd-events >>events ;
|
||||
|
||||
M: unix init-io-event-source
|
||||
stop-io-thread
|
||||
GSourceFuncs malloc-struct &free
|
||||
[ prepare ] GSourceFuncsPrepareFunc >>prepare
|
||||
[ check ] GSourceFuncsCheckFunc >>check
|
||||
[ dispatch ] GSourceFuncsDispatchFunc >>dispatch
|
||||
GSource heap-size g_source_new &g_source_unref
|
||||
[ <poll-fd> g_source_add_poll ]
|
||||
[ f g_source_attach drop ] bi ;
|
Loading…
Reference in New Issue