From 2fee574b4f3c64ae86d3da42950dac07cd134cb8 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 2 Mar 2009 02:55:54 -0600 Subject: [PATCH] Working on X11 backend --- basis/cairo/ffi/ffi.factor | 10 +++++----- basis/glib/glib.factor | 20 ++++++++++---------- basis/pango/cairo/cairo.factor | 10 +++++----- basis/pango/pango.factor | 10 +++++----- basis/ui/backend/x11/x11.factor | 23 ++++++++++++----------- basis/x11/windows/windows.factor | 4 +++- vm/Config.unix | 2 +- 7 files changed, 41 insertions(+), 38 deletions(-) diff --git a/basis/cairo/ffi/ffi.factor b/basis/cairo/ffi/ffi.factor index 03ab6cd61b..e7c0a17660 100644 --- a/basis/cairo/ffi/ffi.factor +++ b/basis/cairo/ffi/ffi.factor @@ -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 diff --git a/basis/glib/glib.factor b/basis/glib/glib.factor index 23badedf44..1805f4bff9 100755 --- a/basis/glib/glib.factor +++ b/basis/glib/glib.factor @@ -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 >> diff --git a/basis/pango/cairo/cairo.factor b/basis/pango/cairo/cairo.factor index e7c1e9fa8c..7683b78890 100644 --- a/basis/pango/cairo/cairo.factor +++ b/basis/pango/cairo/cairo.factor @@ -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 diff --git a/basis/pango/pango.factor b/basis/pango/pango.factor index 3a0e2f1cce..540d1cb9f7 100644 --- a/basis/pango/pango.factor +++ b/basis/pango/pango.factor @@ -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 diff --git a/basis/ui/backend/x11/x11.factor b/basis/ui/backend/x11/x11.factor index 0567c21f74..422efbd188 100755 --- a/basis/ui/backend/x11/x11.factor +++ b/basis/ui/backend/x11/x11.factor @@ -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 @@ -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 + dup + [ window-loc>> ] [ dim>> ] bi glx-window swap + dup "Factor" create-xic + [ window>> register-window ] [ >>handle drop ] 2bi ; : wait-event ( -- event ) diff --git a/basis/x11/windows/windows.factor b/basis/x11/windows/windows.factor index be9f8cf7a9..9619ae0bee 100644 --- a/basis/x11/windows/windows.factor +++ b/basis/x11/windows/windows.factor @@ -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 diff --git a/vm/Config.unix b/vm/Config.unix index a25d0df95e..e8cb877249 100644 --- a/vm/Config.unix +++ b/vm/Config.unix @@ -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