ui.backend.gtk: fix bugs;

db4
Anton Gorenko 2010-11-15 21:48:58 +06:00
parent 0f954c9fa9
commit 8baa7d3578
1 changed files with 10 additions and 33 deletions

View File

@ -1,15 +1,14 @@
! Copyright (C) 2010 Anton Gorenko, Philipp Brüschweiler. ! Copyright (C) 2010 Anton Gorenko, Philipp Brüschweiler.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.accessors alien.c-types alien.data USING: accessors alien.accessors alien.c-types alien.data
alien.strings alien.syntax arrays assocs classes.struct command-line alien.strings arrays assocs classes.struct command-line destructors
destructors gdk.ffi gdk.gl.ffi glib.ffi gdk.ffi gdk.gl.ffi glib.ffi gobject-introspection.standard-types
gobject-introspection.standard-types gobject.ffi gtk.ffi gtk.gl.ffi gobject.ffi gtk.ffi gtk.gl.ffi io.backend io.backend.unix.multiplexers
io.backend io.backend.unix.multiplexers io.encodings.utf8 io.thread io.encodings.utf8 io.thread kernel libc literals locals math
kernel libc literals locals math math.bitwise math.order math.vectors math.bitwise math.order math.vectors namespaces sequences strings
namespaces sequences strings system threads ui ui.backend system threads ui ui.backend ui.clipboards ui.event-loop ui.gadgets
ui.clipboards ui.event-loop ui.gadgets ui.gadgets.editors ui.gadgets.editors ui.gadgets.private ui.gadgets.worlds ui.gestures
ui.gadgets.private ui.gadgets.worlds ui.gestures ui.pixel-formats ui.pixel-formats ui.pixel-formats.private ui.private ;
ui.pixel-formats.private ui.private ;
IN: ui.backend.gtk IN: ui.backend.gtk
SINGLETON: gtk-ui-backend SINGLETON: gtk-ui-backend
@ -285,7 +284,6 @@ CONSTANT: action-key-codes
GENERIC: support-input-methods? ( gadget -- ? ) GENERIC: support-input-methods? ( gadget -- ? )
GENERIC: get-cursor-surrounding ( gadget -- text cursor-pos ) GENERIC: get-cursor-surrounding ( gadget -- text cursor-pos )
GENERIC: delete-cursor-surrounding ( offset count gadget -- ) GENERIC: delete-cursor-surrounding ( offset count gadget -- )
GENERIC: set-preedit-string ( str cursor-pos gadget -- )
GENERIC: get-cursor-loc&dim ( gadget -- loc dim ) GENERIC: get-cursor-loc&dim ( gadget -- loc dim )
M: gadget support-input-methods? drop f ; M: gadget support-input-methods? drop f ;
@ -298,9 +296,6 @@ M: editor get-cursor-surrounding
M: editor delete-cursor-surrounding M: editor delete-cursor-surrounding
3drop ; 3drop ;
M: editor set-preedit-string
3drop ;
M: editor get-cursor-loc&dim M: editor get-cursor-loc&dim
[ caret-loc ] [ caret-dim ] bi ; [ caret-loc ] [ caret-dim ] bi ;
@ -314,29 +309,13 @@ M: editor get-cursor-loc&dim
window world-focus dup support-input-methods? window world-focus dup support-input-methods?
[ delete-cursor-surrounding t ] [ 3drop f ] if nip ; [ delete-cursor-surrounding t ] [ 3drop f ] if nip ;
: get-preedit-string ( im-context -- str cursor-pos )
{ pointer: gchar gint } [ f swap gtk_im_context_get_preedit_string ]
with-out-parameters
[ [ utf8 alien>string ] [ g_free ] bi ] dip ;
: on-preedit-changed ( im-context win -- )
window world-focus dup support-input-methods? [
[ get-preedit-string ] dip set-preedit-string
] [ 2drop ] if ;
: on-commit ( im-context str win -- ) : on-commit ( im-context str win -- )
[ drop ] [ utf8 alien>string ] [ window ] tri* user-input ; [ drop ] [ utf8 alien>string ] [ window ] tri* user-input ;
: gadget-location ( gadget -- loc )
[ loc>> ] [ parent>> [ gadget-location v+ ] when* ] bi ;
: gadget-cursor-location ( gadget -- rectangle ) : gadget-cursor-location ( gadget -- rectangle )
[ gadget-location ] [ get-cursor-loc&dim ] bi [ v+ ] dip [ screen-loc ] [ get-cursor-loc&dim ] bi [ v+ ] dip
[ first2 ] bi@ [ first2 [ >fixnum ] bi@ ] bi@
! <workaround
cairo_rectangle_int_t <struct-boa> ; cairo_rectangle_int_t <struct-boa> ;
! workaround>
! GdkRectangle <struct-boa> ;
: update-cursor-location ( im-context gadget -- ) : update-cursor-location ( im-context gadget -- )
gadget-cursor-location gtk_im_context_set_cursor_location ; gadget-cursor-location gtk_im_context_set_cursor_location ;
@ -373,8 +352,6 @@ M: editor get-cursor-loc&dim
GtkIMContext:retrieve-surrounding win connect-signal-with-data GtkIMContext:retrieve-surrounding win connect-signal-with-data
im "delete-surrounding" [ on-delete-surrounding yield ] im "delete-surrounding" [ on-delete-surrounding yield ]
GtkIMContext:delete-surrounding win connect-signal-with-data GtkIMContext:delete-surrounding win connect-signal-with-data
im "preedit-changed" [ on-preedit-changed yield ]
GtkIMContext:preedit-changed win connect-signal-with-data
win "key-press-event" [ im-on-key-event yield ] win "key-press-event" [ im-on-key-event yield ]
GtkWidget:key-press-event im connect-signal-with-data GtkWidget:key-press-event im connect-signal-with-data