     win "delete-event" [ on-delete yield ]
     GtkWidget:delete-event connect-signal ;
 
+:: connect-im-signals ( im-context -- )
+    im-context "commit" [ on-commit yield ]
+    GtkIMContext:commit connect-signal ;
+
 CONSTANT: window-controls>decor-flags
     H{
         { close-button 0 }

            gtk_main
        ] with-destructors
    ] ui-running ;

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

    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>> [ gtk_widget_destroy ] [ unregister-window ] bi
    event-loop? [ gtk_main_quit ] unless ;

M: gtk-ui-backend set-title
