Split off x11 vocab from x11.xlib, and add x11.unix for event loop integration

db4
Slava Pestov 2009-04-18 01:56:29 -05:00
parent 86e4e314f3
commit 4f74810c15
11 changed files with 64 additions and 36 deletions

View File

@ -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

2
basis/x11/authors.txt Normal file
View File

@ -0,0 +1,2 @@
Eduardo Cavazos
Slava Pestov

View File

@ -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

View File

@ -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 -- )

View File

@ -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

View File

@ -0,0 +1 @@
Slava Pestov

View File

@ -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 ;

View File

@ -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

44
basis/x11/x11.factor Normal file
View File

@ -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

View File

@ -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

View File

@ -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