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 ;
IN: cairo.ffi
<< "cairo" {
{ [ os winnt? ] [ "libcairo-2.dll" ] }
{ [ os macosx? ] [ "/opt/local/lib/libcairo.dylib" ] }
{ [ os unix? ] [ "libcairo.so.2" ] }
} cond "cdecl" add-library >>
<< {
{ [ os winnt? ] [ "cairo" "libcairo-2.dll" "cdecl" add-library ] }
{ [ os macosx? ] [ "cairo" "/opt/local/lib/libcairo.dylib" "cdecl" add-library ] }
{ [ os unix? ] [ ] }
} cond >>
LIBRARY: cairo

View File

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

View File

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

View File

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

View File

@ -1,10 +1,10 @@
! Copyright (C) 2005, 2009 Eduardo Cavazos and Slava Pestov
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien alien.c-types arrays ui ui.gadgets
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 x11.glx
x11.clipboard x11.constants x11.windows io.encodings.string
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
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
environment ascii ;
@ -15,7 +15,7 @@ SINGLETON: x11-ui-backend
: XA_NET_WM_NAME ( -- atom ) "_NET_WM_NAME" x-atom ;
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 ;
C: <x11-handle> x11-handle
@ -132,11 +132,11 @@ M: world motion-event
M: world focus-in-event
nip
dup handle>> xic>> XSetICFocus focus-world ;
[ handle>> xic>> XSetICFocus ] [ focus-world ] bi ;
M: world focus-out-event
nip
dup handle>> xic>> XUnsetICFocus unfocus-world ;
[ handle>> xic>> XUnsetICFocus ] [ unfocus-world ] bi ;
M: world selection-notify-event
[ handle>> window>> selection-from-event ] keep
@ -186,9 +186,10 @@ M: world client-event
swap close-box? [ ungraft ] [ drop ] if ;
: gadget-window ( world -- )
[ [ window-loc>> ] [ dim>> ] bi glx-window ]
[ "Factor" create-xic ]
[ ] tri <x11-handle>
dup
[ window-loc>> ] [ dim>> ] bi glx-window swap
dup "Factor" create-xic
<x11-handle>
[ window>> register-window ] [ >>handle drop ] 2bi ;
: wait-event ( -- event )

View File

@ -42,9 +42,11 @@ IN: x11.windows
: auto-position ( window loc -- )
{ 0 0 } = [ drop ] [ set-size-hints ] if ;
: >xy ( pair -- x y ) first2 [ >integer ] bi@ ;
: create-window ( loc dim visinfo -- window )
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-visual create-window-mask ] keep
window-attributes XCreateWindow

View File

@ -13,7 +13,7 @@ PLAF_EXE_OBJS += vm/main-unix.o
ifdef NO_UI
X11_UI_LIBS =
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
# CFLAGS += -fPIC