     window world-focus dup support-input-methods?
     [ 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 -- )
     [ 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-location ] [ get-cursor-loc&dim ] bi [ v+ ] dip
-    [ first2 ] bi@
-    ! <workaround
+    [ screen-loc ] [ get-cursor-loc&dim ] bi [ v+ ] dip
+    [ first2 [ >fixnum ] bi@ ] bi@
     cairo_rectangle_int_t <struct-boa> ;
-    ! workaround>
-    ! GdkRectangle <struct-boa> ;
 
 : update-cursor-location ( im-context gadget -- )
     gadget-cursor-location gtk_im_context_set_cursor_location ;

    GtkIMContext:retrieve-surrounding win connect-signal-with-data
    im "delete-surrounding" [ on-delete-surrounding yield ]
    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 ]
    GtkWidget:key-press-event im connect-signal-with-data

GENERIC: support-input-methods? ( gadget -- ? )
GENERIC: get-cursor-surrounding ( gadget -- text cursor-pos )
GENERIC: delete-cursor-surrounding ( offset count gadget -- )
GENERIC: get-cursor-loc&dim ( gadget -- loc dim )

M: gadget support-input-methods? drop f ;
