     world setup-gl drop
     
     win connect-signals
+    im-context connect-im-signals
     
     win gtk_widget_realize
     win world window-controls>> configure-window-controls
-    
+
     win gtk_widget_show_all ;
 
 M: gtk-ui-backend (close-window) ( handle -- )
-    window>> [ unregister-window ] [ gtk_widget_destroy ] bi
+    window>> [ gtk_widget_destroy ] [ unregister-window ] bi
     event-loop? [ gtk_main_quit ] unless ;
 
 M: gtk-ui-backend set-title

    win "delete-event" [ on-delete yield ]
    GtkWidget:delete-event connect-signal ;

CONSTANT: window-controls>decor-flags
    H{
        { close-button 0 }

            gtk_main
        ] with-destructors
    ] ui-running ;

: im-context>window ( im-context -- world )
    ui:windows get-global
    [ second handle>> im-context>> = ] with find nip second ;

:: on-commit ( im-context string' user-data -- )
    im-context im-context>window :> world
    string' utf8 alien>string :> string
    f string f <key-down> :> gesture
    gesture world propagate-key-gesture
    string world user-input ;

: connect-signal ( object signal-name callback -- )
    [ utf8 string>alien ] dip f f 0 g_signal_connect_data drop ;
