Assorted Cocoa and X11 backend improvements

slava 2006-03-21 22:15:53 +00:00
parent ccf28d5473
commit 3c55513324
11 changed files with 26 additions and 28 deletions

View File

@ -20,7 +20,7 @@ DEFAULT_LIBS = -lm
ifdef NO_UI ifdef NO_UI
UNIX_UI_LIBS = UNIX_UI_LIBS =
else else
UNIX_UI_LIBS = -lfreetype -lGL -lGLU -lX11 UNIX_UI_LIBS = -lfreetype -lGL -lGLU -L/usr/X11R6/lib -lX11
endif endif
WIN32_OBJS = native/win32/ffi.o \ WIN32_OBJS = native/win32/ffi.o \

View File

@ -31,9 +31,8 @@ objc-NSNotificationCenter objc-NSObject objc-NSView threads ;
: event-loop ( -- ) : event-loop ( -- )
[ [
NSApplication [sharedApplication] do-events NSApplication [sharedApplication] do-events ui-step
do-timers layout-queued ] with-autorelease-pool event-loop ;
] with-autorelease-pool 10 sleep event-loop ;
: add-observer ( observer selector name object -- ) : add-observer ( observer selector name object -- )
>r >r >r >r NSNotificationCenter [defaultCenter] r> r> >r >r >r >r NSNotificationCenter [defaultCenter] r> r>

View File

@ -165,7 +165,7 @@ H{ } clone views set-global
IN: gadgets IN: gadgets
: repaint-handle ( handle -- ) : draw-handle ( handle -- )
1 [setNeedsDisplay:] ; 1 [setNeedsDisplay:] ;
: in-window ( gadget status dim title -- ) : in-window ( gadget status dim title -- )

View File

@ -229,7 +229,6 @@ DEFER: do-crap
[ { 1 2 } ] [ [ uncons ] infer ] unit-test [ { 1 2 } ] [ [ uncons ] infer ] unit-test
[ { 1 1 } ] [ [ unit ] infer ] unit-test [ { 1 1 } ] [ [ unit ] infer ] unit-test
[ { 1 2 } ] [ [ unswons ] infer ] unit-test [ { 1 2 } ] [ [ unswons ] infer ] unit-test
[ { 1 1 } ] [ [ last ] infer ] unit-test
[ { 1 1 } ] [ [ list? ] infer ] unit-test [ { 1 1 } ] [ [ list? ] infer ] unit-test
[ { 1 0 } ] [ [ >n ] infer ] unit-test [ { 1 0 } ] [ [ >n ] infer ] unit-test

View File

@ -1,10 +1,6 @@
IN: temporary IN: temporary
USING: kernel lists sequences test ; USING: kernel lists sequences test ;
[ [ 3 ] ] [ [ 3 ] last ] unit-test
[ [ 3 ] ] [ [ 1 2 3 ] last ] unit-test
[ [[ 3 4 ]] ] [ [[ 1 [[ 2 [[ 3 4 ]] ]] ]] last ] unit-test
[ 3 ] [ [ 3 ] peek ] unit-test [ 3 ] [ [ 3 ] peek ] unit-test
[ 3 ] [ [ 1 2 3 ] peek ] unit-test [ 3 ] [ [ 1 2 3 ] peek ] unit-test
[ 3 ] [ [[ 1 [[ 2 [[ 3 4 ]] ]] ]] peek ] unit-test [ 3 ] [ [[ 1 [[ 2 [[ 3 4 ]] ]] ]] peek ] unit-test

View File

@ -1,7 +1,7 @@
IN: gadgets IN: gadgets
USING: kernel opengl ; USING: kernel opengl ;
DEFER: repaint-handle ( handle -- ) DEFER: draw-handle ( handle -- )
DEFER: in-window ( gadget status dim title -- ) DEFER: in-window ( gadget status dim title -- )

View File

@ -1,8 +1,8 @@
! Copyright (C) 2005, 2006 Slava Pestov. ! Copyright (C) 2005, 2006 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
IN: gadgets IN: gadgets
USING: gadgets-labels gadgets-layouts kernel math namespaces USING: gadgets-labels gadgets-layouts hashtables kernel math
queues sequences ; namespaces queues sequences threads ;
! Hand state ! Hand state
@ -110,8 +110,19 @@ V{ } clone hand-buttons set-global
hand-loc get-global swap move-hand ; hand-loc get-global swap move-hand ;
: layout-queued ( -- ) : layout-queued ( -- )
invalid dup queue-empty? invalid dup queue-empty? [
[ drop ] [ deque dup layout repaint layout-queued ] if ; drop
] [
deque dup layout
find-world [ world-handle dup set ] when*
layout-queued
] if ;
: ui-step ( -- )
do-timers
[ layout-queued ] make-hash
[ drop [ draw-handle ] when* ] hash-each
10 sleep ;
: close-world ( world -- ) : close-world ( world -- )
f over request-focus* dup remove-notify f over request-focus* dup remove-notify

View File

@ -46,9 +46,6 @@ M: gadget find-world gadget-parent find-world ;
M: world find-world ; M: world find-world ;
: repaint ( gadget -- )
find-world [ world-handle [ repaint-handle ] when* ] when* ;
: focused-ancestors ( world -- seq ) : focused-ancestors ( world -- seq )
world-focus parents reverse-slice ; world-focus parents reverse-slice ;

View File

@ -7,6 +7,7 @@ USING: kernel parser words compiler sequences ;
"/library/x11/glx.factor" "/library/x11/glx.factor"
"/library/x11/constants.factor" "/library/x11/constants.factor"
"/library/x11/utilities.factor" "/library/x11/utilities.factor"
"/library/x11/ui.factor"
} [ run-resource ] each } [ run-resource ] each
{ "x11" } compile-vocabs { "x11" } compile-vocabs

View File

@ -3,8 +3,7 @@ USING: arrays errors freetype gadgets gadgets-launchpad
gadgets-layouts gadgets-listener hashtables kernel gadgets-layouts gadgets-listener hashtables kernel
kernel-internals math namespaces opengl sequences x11 ; kernel-internals math namespaces opengl sequences x11 ;
M: world handle-expose-event ( event world -- ) M: world handle-expose-event ( event world -- ) nip draw-world ;
nip draw-world ;
M: world handle-resize-event ( event world -- ) M: world handle-resize-event ( event world -- )
>r >r
@ -19,14 +18,13 @@ M: world handle-resize-event ( event world -- )
IN: gadgets IN: gadgets
: repaint-handle ( handle -- ) : draw-handle ( handle -- ) first windows get hash draw-world ;
drop ; ! windows get hash draw-glx-world ;
: in-window ( gadget status dim title -- ) : in-window ( gadget status dim title -- )
>r <world> r> drop gadget-window ; >r <world> r> drop gadget-window ;
: select-gl-context ( handle -- ) : select-gl-context ( handle -- )
second >r dpy get swap r> glXMakeCurrent dpy get swap first2 glXMakeCurrent
[ "Failed to set current GLX context" throw ] unless ; [ "Failed to set current GLX context" throw ] unless ;
: flush-gl-context ( handle -- ) : flush-gl-context ( handle -- )

View File

@ -66,11 +66,8 @@ SYMBOL: root
dpy get "XEvent" <c-object> dup >r XNextEvent drop r> ; dpy get "XEvent" <c-object> dup >r XNextEvent drop r> ;
: wait-event ( -- event ) : wait-event ( -- event )
QueuedAfterFlush events-queued 0 > [ QueuedAfterFlush events-queued 0 >
next-event [ next-event ] [ ui-step wait-event ] if ;
] [
do-timers layout-queued 10 sleep wait-event
] if ;
GENERIC: handle-expose-event ( event window -- ) GENERIC: handle-expose-event ( event window -- )