Repository navigation
Conversation
Draft integration of the Vulkan renderer into ruisapp, including the Xorg and Wayland glue and the vulkan-xorg / vulkan-wayland test app variants. This is a work-in-progress draft and is not final.
The 1x1 shared context window (used for the resource loader's Vulkan surface) was mapped without _NET_WM_STATE_SKIP_TASKBAR, causing a second entry in the taskbar. Added taskbar flag handling to vulkan_window.hxx and set taskbar=false for the shared context window.
Vulkan has no 'current context' concept — GPU resources are inherently shared via the VkDevice. The resource loader's context no longer needs a Vulkan surface, so the 1x1 shared context window no longer creates a surface from itself. The window itself is kept only because the base render::context class requires a native_window reference, but it is invisible (taskbar=false, never mapped for Vulkan purposes).
Same fix as Xorg path — Vulkan has no 'current context', so the resource loader's context doesn't need a surface. Eliminates the unnecessary vkCreateWaylandSurfaceKHR call on the 1x1 dummy window.
Adds a 'new window' button in the text input window that creates a new native window with a text field, a button, and a close button. Ported from ruis/tests/app1.
The Vulkan present_func captured a shared_ref to the app_window, creating a cycle (app_window -> native_window -> present_func -> app_window) that prevented destruction. Use a raw pointer instead. Also move the 'new window' button to its own row.
XDestroyWindow adds a request to the X11 connection buffer but does not flush it to the X server. Without XFlush, the destroy request may not reach the server until another X11 operation happens, causing windows to not close until another window is closed.
Root cause: the ruis GUI processes a button event during window construction (before the window is registered in the glue's window map). This caused the close button's click_handler to fire during creation, calling destroy_window on a window that wasn't in the map yet. The button state got corrupted, preventing subsequent clicks. Fix: - Add std::atomic<bool> ready flag to ruisapp::window, set to true after the window is registered in the map - Guard close_button click_handler with the ready flag - Set native_window close_handler AFTER window is in the map - Make destroy_window idempotent (return early if window not found) - Send send_mouse_move before send_mouse_button in X11 event handler so the GUI always knows the pointer position - Cascade new windows to reduce overlap
The close button click handler in new_native_window.cpp captured &win (a reference parameter) which becomes dangling after the caller's scope ends. The close_handler in text_input_window.cpp captured &nw (a local reference) which also becomes dangling. Fix: capture raw pointers instead of references. Remove the redundant close_handler from text_input_window.cpp since make_window already sets one correctly. Also fix unused win_ptr warning in non-Vulkan builds by moving it inside the #ifdef RUISAPP_RENDER_VULKAN block.
The native_window destructor was never called because the ruis::context (and its chain: renderer -> render::context -> shared_ref<native_window>) was kept alive by references from the widget tree. The X11 window remained visible on screen after the app_window was destroyed. Fix: add destroy_x11_window() method to both Vulkan and OpenGL native_window classes, and call it from ~app_window() to ensure the X11 window is always destroyed.
The destroy_x11_window() method was destroying the X11 window while the GLX context was still bound to the current thread. This caused a crash when the main loop tried to render after the window was destroyed. Fix: unbind and destroy the GLX context (or EGL context) before destroying the X11 window. Add x11_window_destroyed guard to prevent double-destroy.
…tion
- Remove ~app_window() destructor from glue.cxx that called
destroy_x11_window(). The native_window destructors already handle
X11 window destruction:
- Vulkan: ~native_window() calls destroy_x11_window()
- OpenGL: ~xorg_window_wrapper() calls XDestroyWindow + XFlush
- Fix destroy_x11_window() in window.hxx:
- OpenGL: only unbind GLX context (glXMakeCurrent with GLX_NONE),
do NOT call glXDestroyContext since all windows share the same
GLX context
- EGL: only unbind EGL surface/context, do NOT destroy them since
they are shared
Verified: window destruction works correctly for both Vulkan Xorg
and OpenGL Xorg (open 2 windows, close first, second remains).
- Remove close_handler assignment from the Xorg glue's make_window(); the glue only calls close_handler if the application has set it - Remove the 'ready' flag machinery (close_handler is not called during window creation) - Set the new window's close_handler in the test app code (text_input_window.cpp), same as the main window (main.cpp) Verified: in-app X button close and WM title bar close (WM_DELETE_WINDOW ClientMessage) both work correctly for Vulkan and OpenGL apps, on Xorg and Wayland. The X11 window is destroyed in all cases.
- xorg: initialize VkSurfaceKHR, NOLINT the renderer downcast, replace the cascade magic numbers with named constants and a cascade_offset() helper (also fixes the unsigned-to-int narrowing) - wayland: rename the underscore-prefixed locals, initialize the surface handle, NOLINT the renderer downcast - format the wayland glue headers with clang-format
- vulkan_window.hxx: fix the license year to match the repo LICENSE template (2016-2025), the license check was failing on all make-test jobs (lint, sanitizers, macosx, msys2) - CMake: build the vulkan variants only when the ruis-render-vulkan package is available (monorepo target or findable package). Until ruis-render-vulkan is published to the package repositories the ruisapp vcpkg port cannot depend on it, so the vcpkg-linux job failed configuring the ruisapp package. - CMake: export ruisapp-vulkan-wayland too (was missing)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Integrates the Vulkan renderer (cppfw/ruis-render-vulkan) into ruisapp for Linux Xorg and Wayland.
Key changes:
present_func, fix X11 window destruction (XFlushafterXDestroyWindow), fix OpenGL shared-context destruction.close_handleris the application's responsibility.Tested on Linux Xorg (Xwayland) and Wayland, with 99%+ pixel match vs the OpenGL renderer on Xorg.