diff --git a/extra/ui/gadgets/worlds/worlds.factor b/extra/ui/gadgets/worlds/worlds.factor index 324dd7ddce..8000b90bd4 100644 --- a/extra/ui/gadgets/worlds/worlds.factor +++ b/extra/ui/gadgets/worlds/worlds.factor @@ -63,9 +63,9 @@ M: world focusable-child* gadget-child ; M: world children-on nip gadget-children ; -: (draw-world) ( rect world -- ) +: (draw-world) ( world -- ) dup world-handle [ - [ init-gl ] keep draw-gadget + [ dup init-gl ] keep draw-gadget ] with-gl-context ; : draw-world? ( world -- ? ) @@ -87,7 +87,7 @@ SYMBOL: ui-error-hook [ rethrow ] ui-error-hook set-global -: draw-world ( rect world -- ) +: draw-world ( world -- ) dup draw-world? [ dup world [ [ @@ -99,7 +99,7 @@ SYMBOL: ui-error-hook ] recover ] with-variable ] [ - 2drop + drop ] if ; world H{ diff --git a/extra/ui/ui.factor b/extra/ui/ui.factor index e93496c071..18886ef348 100644 --- a/extra/ui/ui.factor +++ b/extra/ui/ui.factor @@ -55,7 +55,7 @@ SYMBOL: windows : open-world-window ( world -- ) dup pref-dim over set-gadget-dim dup (open-world-window) - dup draw-world ; + draw-world ; : open-window ( gadget title -- ) >r [ 1 track, ] { 0 1 } make-track r> @@ -77,19 +77,12 @@ SYMBOL: windows dup hand-world get-global eq? [ hand-loc get-global swap move-hand ] [ drop ] if ; -: post-layout ( hash gadget -- ) - dup find-world dup [ - rot [ - >r screen-rect r> [ rect-union ] when* - ] change-at - ] [ - 3drop - ] if ; - -: layout-queued ( -- hash ) - H{ } clone invalid [ - dup layout dupd post-layout - ] queue-each ; +: layout-queued ( -- seq ) + [ + invalid [ + dup layout find-world [ , ] when* + ] queue-each + ] { } make ; SYMBOL: ui-hook @@ -105,11 +98,8 @@ SYMBOL: ui-hook init-ui ui-hook get call ] if ; -: redraw-worlds ( hash -- ) - [ - swap dup update-hand - dup world-handle [ draw-world ] [ 2drop ] if - ] assoc-each ; +: redraw-worlds ( seq -- ) + [ dup update-hand draw-world ] each ; : ui-step ( -- ) [ diff --git a/extra/ui/windows/windows.factor b/extra/ui/windows/windows.factor index a320c7ccd0..5f08c5afe1 100644 --- a/extra/ui/windows/windows.factor +++ b/extra/ui/windows/windows.factor @@ -65,7 +65,7 @@ M: pasteboard set-clipboard-contents drop copy ; selection set-global ; ! world-handle is a -TUPLE: win hWnd hDC hRC swap-hint? world title ; +TUPLE: win hWnd hDC hRC world title ; C: win SYMBOL: msg-obj @@ -413,11 +413,8 @@ SYMBOL: hWnd dup wglCreateContext dup win32-error=0/f [ wglMakeCurrent win32-error=0/f ] keep ; -: setup-gl ( hwnd -- hDC hRC swap-hint? ) - get-dc - dup setup-pixel-format - dup get-rc - swap-hint-supported? ; +: setup-gl ( hwnd -- hDC hRC ) + get-dc dup setup-pixel-format get-rc ; M: windows-ui-backend (open-world-window) ( world -- ) [ rect-dim first2 create-window dup setup-gl ] keep @@ -430,10 +427,6 @@ M: windows-ui-backend select-gl-context ( handle -- ) [ win-hDC ] keep win-hRC wglMakeCurrent win32-error=0/f ; M: windows-ui-backend flush-gl-context ( handle -- ) - dup win-swap-hint? [ - clip get flip-rect fix-coordinates - glAddSwapHintRectWIN - ] when win-hDC SwapBuffers win32-error=0/f ; ! Move window to front diff --git a/extra/ui/x11/x11.factor b/extra/ui/x11/x11.factor index c9b23e10e3..fe0f1fa9eb 100644 --- a/extra/ui/x11/x11.factor +++ b/extra/ui/x11/x11.factor @@ -12,7 +12,7 @@ TUPLE: x11-ui-backend ; : XA_NET_WM_NAME "_NET_WM_NAME" x-atom ; -TUPLE: x11-handle window glx xic copy-sub-buffer? ; +TUPLE: x11-handle window glx xic ; C: x11-handle @@ -173,8 +173,7 @@ M: world client-event : gadget-window ( world -- ) dup world-loc over rect-dim glx-window - over "Factor" create-xic - copy-sub-buffer-supported? + over "Factor" create-xic 2dup x11-handle-window register-window swap set-world-handle ; @@ -238,49 +237,8 @@ M: x11-ui-backend select-gl-context ( handle -- ) dup x11-handle-window swap x11-handle-glx glXMakeCurrent [ "Failed to set current GLX context" throw ] unless ; -: swap-buffers-mesa ( handle -- ) - dpy get swap x11-handle-window - clip get flip-rect fix-coordinates - glXCopySubBufferMESA ; - -: swap-buffers-full ( handle -- ) - dpy get swap x11-handle-window glXSwapBuffers ; - -: gl-raster-pos ( loc -- ) - first2 [ >fixnum ] 2apply glRasterPos2i ; - -: gl-copy-pixels ( loc dim buffer -- ) - >r fix-coordinates r> glCopyPixels ; - -: swap-buffers-slow ( -- ) - GL_BACK glReadBuffer - GL_FRONT glDrawBuffer - GL_SCISSOR_TEST glDisable - GL_ONE GL_ZERO glBlendFunc - clip get rect-bounds { 0 1 } v* v+ gl-raster-pos - clip get flip-rect GL_COLOR gl-copy-pixels - GL_BACK glDrawBuffer - glFlush ; - -: swap-buffer-strategy - "swap-buffer-strategy" get "slow" or ; - -: can-swap-full? ( -- ? ) - clip get world get delegates [ rect? ] find nip = ; - -: swap-buffers ( handle strategy -- ) - { - { "mesa" [ swap-buffers-mesa ] } - { "full" [ swap-buffers-full ] } - { "slow" [ - can-swap-full? - [ swap-buffers-full ] - [ drop swap-buffers-slow ] if - ] } - } case ; - M: x11-ui-backend flush-gl-context ( handle -- ) - swap-buffer-strategy swap-buffers ; + dpy get swap x11-handle-window glXSwapBuffers ; M: x11-ui-backend ui ( -- ) [ diff --git a/extra/windows/opengl32/opengl32.factor b/extra/windows/opengl32/opengl32.factor index 93473a4fd3..2d58d34083 100644 --- a/extra/windows/opengl32/opengl32.factor +++ b/extra/windows/opengl32/opengl32.factor @@ -101,10 +101,3 @@ FUNCTION: HGLRC wglCreateContext ( HDC hDC ) ; FUNCTION: BOOL wglDeleteContext ( HGLRC hRC ) ; FUNCTION: BOOL wglMakeCurrent ( HDC hDC, HGLRC hglrc ) ; FUNCTION: void* wglGetProcAddress ( char* name ) ; - -: glAddSwapHintRectWIN ( x y width height -- ) - "glAddSwapHintRectWIN" wglGetProcAddress check-ptr - "void" { "int" "int" "int" "int" } "stdcall" alien-indirect ; - -: swap-hint-supported? ( -- ? ) - "GL_WIN_swap_hint" GL_EXTENSIONS glGetString subseq? ; diff --git a/extra/x11/glx/glx.factor b/extra/x11/glx/glx.factor index 5402575c02..1a898c50a9 100644 --- a/extra/x11/glx/glx.factor +++ b/extra/x11/glx/glx.factor @@ -99,13 +99,4 @@ FUNCTION: void* glXGetProcAddress ( char* procname ) ; [ "Failed to create GLX context" throw ] unless* ; : destroy-glx ( GLXContext -- ) - dpy get swap glXDestroyContext ; - -: copy-sub-buffer-supported? ( -- ? ) - "GLX_MESA_copy_sub_buffer" - dpy get scr get glXQueryExtensionsString subseq? ; - -: glXCopySubBufferMESA ( dpy drawable x y width height -- ) - "glXCopySubBufferMESA" glXGetProcAddress - "void" { "Display*" "GLXDrawable" "int" "int" "int" "int" } - "cdecl" alien-indirect ; \ No newline at end of file + dpy get swap glXDestroyContext ; \ No newline at end of file