Split off x11 vocab from x11.xlib, and add x11.unix for event loop integration
parent
86e4e314f3
commit
4f74810c15
|
@ -3,7 +3,7 @@
|
|||
USING: accessors alien alien.c-types arrays ui ui.private ui.gadgets
|
||||
ui.gadgets.private ui.gestures ui.backend ui.clipboards
|
||||
ui.gadgets.worlds ui.render ui.event-loop assocs kernel math
|
||||
namespaces opengl sequences strings x11.xlib x11.events x11.xim
|
||||
namespaces opengl sequences strings x11 x11.xlib x11.events x11.xim
|
||||
x11.glx x11.clipboard x11.constants x11.windows io.encodings.string
|
||||
io.encodings.ascii io.encodings.utf8 combinators command-line
|
||||
math.vectors classes.tuple opengl.gl threads math.rectangles
|
||||
|
@ -196,7 +196,7 @@ M: world client-event
|
|||
QueuedAfterFlush events-queued 0 > [
|
||||
next-event dup
|
||||
None XFilterEvent 0 = [ drop wait-event ] unless
|
||||
] [ ui-wait wait-event ] if ;
|
||||
] [ wait-for-display wait-event ] if ;
|
||||
|
||||
M: x11-ui-backend do-events
|
||||
wait-event dup XAnyEvent-window window dup
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Eduardo Cavazos
|
||||
Slava Pestov
|
|
@ -2,7 +2,7 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: alien alien.c-types alien.strings alien.syntax arrays
|
||||
kernel math namespaces sequences io.encodings.string
|
||||
io.encodings.utf8 io.encodings.ascii x11.xlib x11.constants
|
||||
io.encodings.utf8 io.encodings.ascii x11 x11.xlib x11.constants
|
||||
specialized-arrays.int accessors ;
|
||||
IN: x11.clipboard
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: alien alien.c-types arrays hashtables io kernel math
|
||||
math.order namespaces prettyprint sequences strings combinators
|
||||
x11.xlib ;
|
||||
x11 x11.xlib ;
|
||||
IN: x11.events
|
||||
|
||||
GENERIC: expose-event ( event window -- )
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
!
|
||||
! based on glx.h from xfree86, and some of glxtokens.h
|
||||
USING: alien alien.c-types alien.syntax x11.xlib namespaces make
|
||||
USING: alien alien.c-types alien.syntax x11 x11.xlib namespaces make
|
||||
kernel sequences parser words specialized-arrays.int accessors ;
|
||||
IN: x11.glx
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Slava Pestov
|
|
@ -0,0 +1,10 @@
|
|||
! Copyright (C) 2009 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: io.backend.unix namespaces system x11 x11.xlib ;
|
||||
IN: x11.unix
|
||||
|
||||
SYMBOL: dpy-fd
|
||||
|
||||
M: unix init-x-io dpy get XConnectionNumber <fd> dpy-fd set-global ;
|
||||
|
||||
M: unix wait-for-display dpy-fd get +input+ wait-for-fd ;
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2005, 2006 Eduardo Cavazos and Slava Pestov
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: alien alien.c-types hashtables kernel math math.vectors
|
||||
math.bitwise namespaces sequences x11.xlib x11.constants x11.glx
|
||||
math.bitwise namespaces sequences x11 x11.xlib x11.constants x11.glx
|
||||
arrays fry ;
|
||||
IN: x11.windows
|
||||
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
! Copyright (C) 2005, 2009 Eduardo Cavazos, Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: alien.strings continuations io io.backend
|
||||
io.encodings.ascii kernel namespaces x11.xlib
|
||||
vocabs vocabs.loader calendar threads ;
|
||||
IN: x11
|
||||
|
||||
SYMBOL: dpy
|
||||
SYMBOL: scr
|
||||
SYMBOL: root
|
||||
|
||||
: init-locale ( -- )
|
||||
LC_ALL "" setlocale [ "setlocale() failed" print flush ] unless
|
||||
XSupportsLocale [ "XSupportsLocale() failed" print flush ] unless ;
|
||||
|
||||
: flush-dpy ( -- ) dpy get XFlush drop ;
|
||||
|
||||
: x-atom ( string -- atom ) [ dpy get ] dip 0 XInternAtom ;
|
||||
|
||||
: check-display ( alien -- alien' )
|
||||
[ "Cannot connect to X server - check $DISPLAY" throw ] unless* ;
|
||||
|
||||
HOOK: init-x-io io-backend ( -- )
|
||||
|
||||
M: object init-x-io ;
|
||||
|
||||
HOOK: wait-for-display io-backend ( -- )
|
||||
|
||||
M: object wait-for-display 10 milliseconds sleep ;
|
||||
|
||||
: init-x ( display-string -- )
|
||||
init-locale
|
||||
dup [ ascii string>alien ] when
|
||||
XOpenDisplay check-display dpy set-global
|
||||
dpy get XDefaultScreen scr set-global
|
||||
dpy get scr get XRootWindow root set-global
|
||||
init-x-io ;
|
||||
|
||||
: close-x ( -- ) dpy get XCloseDisplay drop ;
|
||||
|
||||
: with-x ( display-string quot -- )
|
||||
[ init-x ] dip [ close-x ] [ ] cleanup ; inline
|
||||
|
||||
"io.backend.unix" vocab [ "x11.unix" require ] when
|
|
@ -2,7 +2,7 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: alien alien.c-types alien.strings arrays byte-arrays
|
||||
hashtables io io.encodings.string kernel math namespaces
|
||||
sequences strings continuations x11.xlib specialized-arrays.uint
|
||||
sequences strings continuations x11 x11.xlib specialized-arrays.uint
|
||||
accessors io.encodings.utf16n ;
|
||||
IN: x11.xim
|
||||
|
||||
|
|
|
@ -1412,32 +1412,3 @@ FUNCTION: char* setlocale ( int category, char* name ) ;
|
|||
FUNCTION: Bool XSupportsLocale ( ) ;
|
||||
|
||||
FUNCTION: char* XSetLocaleModifiers ( char* modifier_list ) ;
|
||||
|
||||
SYMBOL: dpy
|
||||
SYMBOL: scr
|
||||
SYMBOL: root
|
||||
|
||||
: init-locale ( -- )
|
||||
LC_ALL "" setlocale [ "setlocale() failed" print flush ] unless
|
||||
XSupportsLocale [ "XSupportsLocale() failed" print flush ] unless ;
|
||||
|
||||
: flush-dpy ( -- ) dpy get XFlush drop ;
|
||||
|
||||
: x-atom ( string -- atom ) dpy get swap 0 XInternAtom ;
|
||||
|
||||
: check-display ( alien -- alien' )
|
||||
[
|
||||
"Cannot connect to X server - check $DISPLAY" throw
|
||||
] unless* ;
|
||||
|
||||
: initialize-x ( display-string -- )
|
||||
init-locale
|
||||
dup [ ascii string>alien ] when
|
||||
XOpenDisplay check-display dpy set-global
|
||||
dpy get XDefaultScreen scr set-global
|
||||
dpy get scr get XRootWindow root set-global ;
|
||||
|
||||
: close-x ( -- ) dpy get XCloseDisplay drop ;
|
||||
|
||||
: with-x ( display-string quot -- )
|
||||
[ initialize-x ] dip [ close-x ] [ ] cleanup ; inline
|
||||
|
|
Loading…
Reference in New Issue