     hWnd window-focus send-gesture drop ;
 
 :: set-window-active ( hwnd uMsg wParam lParam ? -- n )
-    ? hwnd window set-world-active?
+    ? hwnd window (>>active?)
     hwnd uMsg wParam lParam DefWindowProc ;
 
 : handle-wm-syscommand ( hWnd uMsg wParam lParam -- n )

    } cond ;

: cleanup-window ( handle -- )
    dup win-title [ free ] when*
    dup win-hRC wglDeleteContext win32-error=0/f
    dup win-hWnd swap win-hDC ReleaseDC win32-error=0/f ;

M: windows-ui-backend (close-window)
    dup win-hWnd unregister-window
    dup cleanup-window
    win-hWnd DestroyWindow win32-error=0/f ;

: handle-wm-close ( hWnd uMsg wParam lParam -- )
    3drop window ungraft ;

M: windows-ui-backend (open-window) ( world -- )
    [ create-window dup setup-gl ] keep
    [ f <win> ] keep
    [ swap hWnd>> register-window ] 2keep
    dupd (>>handle)
    hWnd>> show-window ;

M: windows-ui-backend select-gl-context ( handle -- )
    [ hDC>> ] keep hRC>> wglMakeCurrent win32-error=0/f ;

M: windows-ui-backend flush-gl-context ( handle -- )
    hDC>> SwapBuffers win32-error=0/f ;

! Move window to front
M: windows-ui-backend raise-window* ( world -- )
    handle>> [
        hWnd>> SetFocus drop
    ] when* ;

M: windows-ui-backend set-title ( string world -- )
    handle>>
    dup title>> [ free ] when*
    >r utf16n malloc-string r>
    2dup (>>title)
    hWnd>> WM_SETTEXT 0 roll alien-address SendMessage drop ;

M: windows-ui-backend ui
    [
