Working on X11 backend

db4
Slava Pestov 2009-03-02 02:55:54 -06:00
parent 5ff2b19ffe
commit 2fee574b4f
7 changed files with 41 additions and 38 deletions

View File

@ -8,11 +8,11 @@ USING: system combinators alien alien.syntax alien.c-types
alien.destructors kernel accessors sequences arrays ui.gadgets ; alien.destructors kernel accessors sequences arrays ui.gadgets ;
IN: cairo.ffi IN: cairo.ffi
<< "cairo" { << {
{ [ os winnt? ] [ "libcairo-2.dll" ] } { [ os winnt? ] [ "cairo" "libcairo-2.dll" "cdecl" add-library ] }
{ [ os macosx? ] [ "/opt/local/lib/libcairo.dylib" ] } { [ os macosx? ] [ "cairo" "/opt/local/lib/libcairo.dylib" "cdecl" add-library ] }
{ [ os unix? ] [ "libcairo.so.2" ] } { [ os unix? ] [ ] }
} cond "cdecl" add-library >> } cond >>
LIBRARY: cairo LIBRARY: cairo

View File

@ -6,17 +6,17 @@ IN: glib
<< <<
"glib" { {
{ [ os winnt? ] [ "libglib-2.0-0.dll" ] } { [ os winnt? ] [ "glib" "libglib-2.0-0.dll" "cdecl" add-library ] }
{ [ os macosx? ] [ "/opt/local/lib/libglib-2.0.0.dylib" ] } { [ os macosx? ] [ "glib" "/opt/local/lib/libglib-2.0.0.dylib" "cdecl" add-library ] }
{ [ os unix? ] [ "libglib-2.0.0.so" ] } { [ os unix? ] [ ] }
} cond "cdecl" add-library } cond
"gobject" { {
{ [ os winnt? ] [ "libgobject-2.0-0.dll" ] } { [ os winnt? ] [ "gobject" "libgobject-2.0-0.dll" "cdecl" add-library ] }
{ [ os macosx? ] [ "/opt/local/lib/libgobject-2.0.0.dylib" ] } { [ os macosx? ] [ "gobject" "/opt/local/lib/libgobject-2.0.0.dylib" "cdecl" add-library ] }
{ [ os unix? ] [ "libgobject-2.0.0.so" ] } { [ os unix? ] [ ] }
} cond "cdecl" add-library } cond
>> >>

View File

@ -6,11 +6,11 @@
USING: alien alien.syntax combinators system cairo.ffi ; USING: alien alien.syntax combinators system cairo.ffi ;
IN: pango.cairo IN: pango.cairo
<< "pangocairo" { << {
{ [ os winnt? ] [ "libpangocairo-1.0-0.dll" ] } { [ os winnt? ] [ "pangocairo" "libpangocairo-1.0-0.dll" "cdecl" add-library ] }
{ [ os macosx? ] [ "/opt/local/lib/libpangocairo-1.0.0.dylib" ] } { [ os macosx? ] [ "pangocairo" "/opt/local/lib/libpangocairo-1.0.0.dylib" "cdecl" add-library ] }
{ [ os unix? ] [ "libpangocairo-1.0.so" ] } { [ os unix? ] [ ] }
} cond "cdecl" add-library >> } cond >>
LIBRARY: pangocairo LIBRARY: pangocairo

View File

@ -9,11 +9,11 @@ IN: pango
! Helpful functions from other parts of pango ! Helpful functions from other parts of pango
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<< "pango" { << {
{ [ os winnt? ] [ "libpango-1.0-0.dll" ] } { [ os winnt? ] [ "pango" "libpango-1.0-0.dll" "cdecl" add-library ] }
{ [ os macosx? ] [ "/opt/local/lib/libpango-1.0.0.dylib" ] } { [ os macosx? ] [ "pango" "/opt/local/lib/libpango-1.0.0.dylib" "cdecl" add-library ] }
{ [ os unix? ] [ "libpango-1.0.so" ] } { [ os unix? ] [ ] }
} cond "cdecl" add-library >> } cond >>
LIBRARY: pango LIBRARY: pango

View File

@ -1,10 +1,10 @@
! Copyright (C) 2005, 2009 Eduardo Cavazos and Slava Pestov ! Copyright (C) 2005, 2009 Eduardo Cavazos and Slava Pestov
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien alien.c-types arrays ui ui.gadgets USING: accessors alien alien.c-types arrays ui ui.private ui.gadgets
ui.gestures ui.backend ui.clipboards ui.gadgets.worlds ui.render ui.gadgets.private ui.gestures ui.backend ui.clipboards
ui.event-loop assocs kernel math namespaces opengl ui.gadgets.worlds ui.render ui.event-loop assocs kernel math
sequences strings x11.xlib x11.events x11.xim x11.glx namespaces opengl sequences strings x11.xlib x11.events x11.xim
x11.clipboard x11.constants x11.windows io.encodings.string x11.glx x11.clipboard x11.constants x11.windows io.encodings.string
io.encodings.ascii io.encodings.utf8 combinators command-line io.encodings.ascii io.encodings.utf8 combinators command-line
math.vectors classes.tuple opengl.gl threads math.rectangles math.vectors classes.tuple opengl.gl threads math.rectangles
environment ascii ; environment ascii ;
@ -15,7 +15,7 @@ SINGLETON: x11-ui-backend
: XA_NET_WM_NAME ( -- atom ) "_NET_WM_NAME" x-atom ; : XA_NET_WM_NAME ( -- atom ) "_NET_WM_NAME" x-atom ;
TUPLE: x11-handle-base glx ; TUPLE: x11-handle-base glx ;
TUPLE: x11-handle < x11-handle-base xic window ; TUPLE: x11-handle < x11-handle-base window xic ;
TUPLE: x11-pixmap-handle < x11-handle-base pixmap glx-pixmap ; TUPLE: x11-pixmap-handle < x11-handle-base pixmap glx-pixmap ;
C: <x11-handle> x11-handle C: <x11-handle> x11-handle
@ -132,11 +132,11 @@ M: world motion-event
M: world focus-in-event M: world focus-in-event
nip nip
dup handle>> xic>> XSetICFocus focus-world ; [ handle>> xic>> XSetICFocus ] [ focus-world ] bi ;
M: world focus-out-event M: world focus-out-event
nip nip
dup handle>> xic>> XUnsetICFocus unfocus-world ; [ handle>> xic>> XUnsetICFocus ] [ unfocus-world ] bi ;
M: world selection-notify-event M: world selection-notify-event
[ handle>> window>> selection-from-event ] keep [ handle>> window>> selection-from-event ] keep
@ -186,9 +186,10 @@ M: world client-event
swap close-box? [ ungraft ] [ drop ] if ; swap close-box? [ ungraft ] [ drop ] if ;
: gadget-window ( world -- ) : gadget-window ( world -- )
[ [ window-loc>> ] [ dim>> ] bi glx-window ] dup
[ "Factor" create-xic ] [ window-loc>> ] [ dim>> ] bi glx-window swap
[ ] tri <x11-handle> dup "Factor" create-xic
<x11-handle>
[ window>> register-window ] [ >>handle drop ] 2bi ; [ window>> register-window ] [ >>handle drop ] 2bi ;
: wait-event ( -- event ) : wait-event ( -- event )

View File

@ -42,9 +42,11 @@ IN: x11.windows
: auto-position ( window loc -- ) : auto-position ( window loc -- )
{ 0 0 } = [ drop ] [ set-size-hints ] if ; { 0 0 } = [ drop ] [ set-size-hints ] if ;
: >xy ( pair -- x y ) first2 [ >integer ] bi@ ;
: create-window ( loc dim visinfo -- window ) : create-window ( loc dim visinfo -- window )
pick [ pick [
[ [ [ dpy get root get ] dip first2 ] dip { 1 1 } vmax first2 0 ] dip [ [ [ dpy get root get ] dip >xy ] dip { 1 1 } vmax >xy 0 ] dip
[ XVisualInfo-depth InputOutput ] keep [ XVisualInfo-depth InputOutput ] keep
[ XVisualInfo-visual create-window-mask ] keep [ XVisualInfo-visual create-window-mask ] keep
window-attributes XCreateWindow window-attributes XCreateWindow

View File

@ -13,7 +13,7 @@ PLAF_EXE_OBJS += vm/main-unix.o
ifdef NO_UI ifdef NO_UI
X11_UI_LIBS = X11_UI_LIBS =
else else
X11_UI_LIBS = -lfreetype -lGL -lGLU -lX11 X11_UI_LIBS = -lpango-1.0 -lpangocairo-1.0 -lcairo -lglib-2.0 -lgobject-2.0 -lGL -lGLU -lX11
endif endif
# CFLAGS += -fPIC # CFLAGS += -fPIC