     [ dim>> first2 gtk_window_set_default_size ] 2bi
     
     world setup-gl drop
+
+    win configure-im
     
     win connect-signals
     

        ] with-destructors
    ] ui-running ;

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

:: connect-signals ( win -- )
    win events-mask [ enum>number ] [ bitor ] map-reduce

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

: on-key-event-for-im ( sender event user-data -- result )
    swap gtk_im_context_filter_keypress 2drop f ;

: on-focus-out-for-im ( sender event user-data -- result )
    2nip gtk_im_context_reset f ;

: on-destroy-for-im ( sender user-data -- result )
    nip g_object_unref f ;

: on-im-commit ( sender str user_data -- )
    [ drop ] [ utf8 alien>string ] [ window ] tri* user-input ;

:: configure-im ( win -- )
    gtk_im_context_simple_new :> im
    im win gtk_im_context_set_client_window
    
    im "commit" [ on-im-commit yield ]
    GtkIMContext:commit win connect-signal-with-data

    win "key-press-event" [ on-key-event-for-im ]
    GtkWidget:key-press-event im connect-signal-with-data
    win "key-release-event" [ on-key-event-for-im ]
    GtkWidget:key-release-event im connect-signal-with-data
    win "focus-out-event" [ on-focus-out-for-im ]
    GtkWidget:focus-out-event im connect-signal-with-data
    win "destroy" [ on-destroy-for-im ]
    GtkObject:destroy im connect-signal-with-data ;

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