Assorted Cocoa and X11 backend improvements
parent
ccf28d5473
commit
3c55513324
2
Makefile
2
Makefile
|
@ -20,7 +20,7 @@ DEFAULT_LIBS = -lm
|
|||
ifdef NO_UI
|
||||
UNIX_UI_LIBS =
|
||||
else
|
||||
UNIX_UI_LIBS = -lfreetype -lGL -lGLU -lX11
|
||||
UNIX_UI_LIBS = -lfreetype -lGL -lGLU -L/usr/X11R6/lib -lX11
|
||||
endif
|
||||
|
||||
WIN32_OBJS = native/win32/ffi.o \
|
||||
|
|
|
@ -31,9 +31,8 @@ objc-NSNotificationCenter objc-NSObject objc-NSView threads ;
|
|||
|
||||
: event-loop ( -- )
|
||||
[
|
||||
NSApplication [sharedApplication] do-events
|
||||
do-timers layout-queued
|
||||
] with-autorelease-pool 10 sleep event-loop ;
|
||||
NSApplication [sharedApplication] do-events ui-step
|
||||
] with-autorelease-pool event-loop ;
|
||||
|
||||
: add-observer ( observer selector name object -- )
|
||||
>r >r >r >r NSNotificationCenter [defaultCenter] r> r>
|
||||
|
|
|
@ -165,7 +165,7 @@ H{ } clone views set-global
|
|||
|
||||
IN: gadgets
|
||||
|
||||
: repaint-handle ( handle -- )
|
||||
: draw-handle ( handle -- )
|
||||
1 [setNeedsDisplay:] ;
|
||||
|
||||
: in-window ( gadget status dim title -- )
|
||||
|
|
|
@ -229,7 +229,6 @@ DEFER: do-crap
|
|||
[ { 1 2 } ] [ [ uncons ] infer ] unit-test
|
||||
[ { 1 1 } ] [ [ unit ] infer ] unit-test
|
||||
[ { 1 2 } ] [ [ unswons ] infer ] unit-test
|
||||
[ { 1 1 } ] [ [ last ] infer ] unit-test
|
||||
[ { 1 1 } ] [ [ list? ] infer ] unit-test
|
||||
|
||||
[ { 1 0 } ] [ [ >n ] infer ] unit-test
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
IN: temporary
|
||||
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 ] [ [ 1 2 3 ] peek ] unit-test
|
||||
[ 3 ] [ [[ 1 [[ 2 [[ 3 4 ]] ]] ]] peek ] unit-test
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
IN: gadgets
|
||||
USING: kernel opengl ;
|
||||
|
||||
DEFER: repaint-handle ( handle -- )
|
||||
DEFER: draw-handle ( handle -- )
|
||||
|
||||
DEFER: in-window ( gadget status dim title -- )
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
! Copyright (C) 2005, 2006 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
IN: gadgets
|
||||
USING: gadgets-labels gadgets-layouts kernel math namespaces
|
||||
queues sequences ;
|
||||
USING: gadgets-labels gadgets-layouts hashtables kernel math
|
||||
namespaces queues sequences threads ;
|
||||
|
||||
! Hand state
|
||||
|
||||
|
@ -110,8 +110,19 @@ V{ } clone hand-buttons set-global
|
|||
hand-loc get-global swap move-hand ;
|
||||
|
||||
: layout-queued ( -- )
|
||||
invalid dup queue-empty?
|
||||
[ drop ] [ deque dup layout repaint layout-queued ] if ;
|
||||
invalid dup queue-empty? [
|
||||
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 -- )
|
||||
f over request-focus* dup remove-notify
|
||||
|
|
|
@ -46,9 +46,6 @@ M: gadget find-world gadget-parent find-world ;
|
|||
|
||||
M: world find-world ;
|
||||
|
||||
: repaint ( gadget -- )
|
||||
find-world [ world-handle [ repaint-handle ] when* ] when* ;
|
||||
|
||||
: focused-ancestors ( world -- seq )
|
||||
world-focus parents reverse-slice ;
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ USING: kernel parser words compiler sequences ;
|
|||
"/library/x11/glx.factor"
|
||||
"/library/x11/constants.factor"
|
||||
"/library/x11/utilities.factor"
|
||||
"/library/x11/ui.factor"
|
||||
} [ run-resource ] each
|
||||
|
||||
{ "x11" } compile-vocabs
|
|
@ -3,8 +3,7 @@ USING: arrays errors freetype gadgets gadgets-launchpad
|
|||
gadgets-layouts gadgets-listener hashtables kernel
|
||||
kernel-internals math namespaces opengl sequences x11 ;
|
||||
|
||||
M: world handle-expose-event ( event world -- )
|
||||
nip draw-world ;
|
||||
M: world handle-expose-event ( event world -- ) nip draw-world ;
|
||||
|
||||
M: world handle-resize-event ( event world -- )
|
||||
>r
|
||||
|
@ -19,14 +18,13 @@ M: world handle-resize-event ( event world -- )
|
|||
|
||||
IN: gadgets
|
||||
|
||||
: repaint-handle ( handle -- )
|
||||
drop ; ! windows get hash draw-glx-world ;
|
||||
: draw-handle ( handle -- ) first windows get hash draw-world ;
|
||||
|
||||
: in-window ( gadget status dim title -- )
|
||||
>r <world> r> drop gadget-window ;
|
||||
|
||||
: select-gl-context ( handle -- )
|
||||
second >r dpy get swap r> glXMakeCurrent
|
||||
dpy get swap first2 glXMakeCurrent
|
||||
[ "Failed to set current GLX context" throw ] unless ;
|
||||
|
||||
: flush-gl-context ( handle -- )
|
||||
|
|
|
@ -66,11 +66,8 @@ SYMBOL: root
|
|||
dpy get "XEvent" <c-object> dup >r XNextEvent drop r> ;
|
||||
|
||||
: wait-event ( -- event )
|
||||
QueuedAfterFlush events-queued 0 > [
|
||||
next-event
|
||||
] [
|
||||
do-timers layout-queued 10 sleep wait-event
|
||||
] if ;
|
||||
QueuedAfterFlush events-queued 0 >
|
||||
[ next-event ] [ ui-step wait-event ] if ;
|
||||
|
||||
GENERIC: handle-expose-event ( event window -- )
|
||||
|
||||
|
|
Loading…
Reference in New Issue