 
 M: world focus-in-event
     nip
-    dup handle>> x11-handle-xic XSetICFocus focus-world ;
+    dup handle>> xic>> XSetICFocus focus-world ;
 
 M: world focus-out-event
     nip
-    dup handle>> x11-handle-xic XUnsetICFocus unfocus-world ;
+    dup handle>> xic>> XUnsetICFocus unfocus-world ;
 
 M: world selection-notify-event
-    [ handle>> x11-handle-window selection-from-event ] keep
+    [ handle>> window>> selection-from-event ] keep
     world-focus user-input ;
 
 : supported-type? ( atom -- ? )


M: x11-ui-backend (open-window) ( world -- )
    dup gadget-window
    handle>> x11-handle-window dup set-closable map-window ;

M: x11-ui-backend raise-window* ( world -- )
    handle>> [
        dpy get swap x11-handle-window XRaiseWindow drop
    ] when* ;

M: x11-ui-backend select-gl-context ( handle -- )
    dpy get swap
    dup x11-handle-window swap x11-handle-glx glXMakeCurrent
    [ "Failed to set current GLX context" throw ] unless ;

M: x11-ui-backend flush-gl-context ( handle -- )
    dpy get swap x11-handle-window glXSwapBuffers ;

M: x11-ui-backend ui ( -- )
    [


: x-clipboard@ ( gadget clipboard -- prop win )
    x-clipboard-atom swap
    find-world handle>> window>> ;

M: x-clipboard copy-clipboard
    [ x-clipboard@ own-selection ] keep
    set-x-clipboard-contents ;

M: x-clipboard paste-clipboard
    >r find-world handle>> window>>
    r> x-clipboard-atom convert-selection ;

: init-clipboard ( -- )
