Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
fix(cua-driver): detect Hyprland input internals instead of pinning 0.56.2 (#6495)
injaneityeedfffecae31
diff --git a/libs/cua-driver/hyprland-plugin/CMakeLists.txt b/libs/cua-driver/hyprland-plugin/CMakeLists.txtindex 96d254e939..836bf5ea36 100644--- a/libs/cua-driver/hyprland-plugin/CMakeLists.txt+++ b/libs/cua-driver/hyprland-plugin/CMakeLists.txt@@ -246,10 +246,19 @@ if(CUA_HYPRLAND_BUILD_PLUGIN)add_library(cua_hyprland_plugin MODULE src/plugin.cpp)if(CUA_HYPRLAND_TEST_INPUT OR CUA_HYPRLAND_INPUT)- if(NOT HYPRLAND_VERSION STREQUAL "0.56.2")- message(FATAL_ERROR "Input is pinned to Hyprland 0.56.2")+ cua_detect_hyprland_window_api(cua_hyprland_window_backend_api+ "${HYPRLAND_INCLUDE_DIRS}" "${HYPRLAND_CFLAGS_OTHER}")+ if(cua_hyprland_window_backend_api STREQUAL "1")+ message(STATUS "Using Hyprland window-backend input API")+ elseif(cua_hyprland_window_backend_api STREQUAL "0")+ message(STATUS "Using Hyprland legacy window input API")+ else()+ message(FATAL_ERROR+ "Hyprland ${HYPRLAND_VERSION} headers expose no supported window input API")endif()target_sources(cua_hyprland_plugin PRIVATE src/input_experiment.cpp)+ target_compile_definitions(cua_hyprland_plugin PRIVATE+ CUA_HYPRLAND_WINDOW_BACKEND_API=${cua_hyprland_window_backend_api})endif()if(CUA_HYPRLAND_INPUT)target_compile_definitions(cua_hyprland_plugin PRIVATE CUA_HYPRLAND_INPUT=1)diff --git a/libs/cua-driver/hyprland-plugin/README.md b/libs/cua-driver/hyprland-plugin/README.mdindex 425519a7bf..76da33c520 100644--- a/libs/cua-driver/hyprland-plugin/README.md+++ b/libs/cua-driver/hyprland-plugin/README.md@@ -92,7 +92,11 @@ For a pinned acceptance build, also setversion). The build refuses a different header version. The status-commandadapter supports both Hyprland `0.56.2`'s `SHyprCtlCommand` API and the newerSocket1 API. CMake compile-checks the installed `PluginAPI.hpp` and selects a-declared tier; an unknown command API fails configuration. The probes use+declared tier; an unknown command API fails configuration. Input builds+likewise compile-check the window and layer-surface internals they read+(the 0.57 window-backend API or the earlier one) instead of pinning a Hyprland+version, and unknown internals fail configuration. The nightly requalification+below proves each new Hyprland build with a headless load and input smoke. The probes useC++26 and repeat on reconfiguration so a header upgrade cannot reuse a cachedtier. Both adapter paths run in the local mock suite. A separate configurationtest checks tier selection, compiler flags, and unsupported headers. Real-headerdiff --git a/libs/cua-driver/hyprland-plugin/cmake/DetectHyprlandAPI.cmake b/libs/cua-driver/hyprland-plugin/cmake/DetectHyprlandAPI.cmakeindex dbf8c7fb3d..d9c8e3b734 100644--- a/libs/cua-driver/hyprland-plugin/cmake/DetectHyprlandAPI.cmake+++ b/libs/cua-driver/hyprland-plugin/cmake/DetectHyprlandAPI.cmake@@ -27,3 +27,33 @@ function(cua_detect_hyprland_api output includes flags)set(${output} unsupported PARENT_SCOPE)endif()endfunction()++# Input reads compositor internals. Select the window and layer API the+# installed headers expose instead of pinning a Hyprland version; unknown+# internals fail configuration.+function(cua_detect_hyprland_window_api output includes flags)+ set(CMAKE_CXX_STANDARD 26)+ set(CMAKE_CXX_STANDARD_REQUIRED ON)+ set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)+ set(CMAKE_REQUIRED_INCLUDES ${includes})+ string(JOIN " " CMAKE_REQUIRED_FLAGS ${flags})+ unset(CUA_HYPRLAND_HAS_WINDOW_BACKEND_API CACHE)+ unset(CUA_HYPRLAND_HAS_LEGACY_WINDOW_API CACHE)+ set(headers "#include <src/Compositor.hpp>\n#include <src/managers/input/InputManager.hpp>\n")+ # 0.57+: identity on the window backend; exclusive keyboard layers (#15899).+ check_cxx_source_compiles(+ "${headers}void probe(const PHLWINDOW& w) { (void)w->mapped(); (void)w->backend().isX11(); (void)w->backend().pid(); (void)g_pInputManager->m_exclusiveKeyboardLSes.empty(); }"+ CUA_HYPRLAND_HAS_WINDOW_BACKEND_API)+ if(CUA_HYPRLAND_HAS_WINDOW_BACKEND_API)+ set(${output} 1 PARENT_SCOPE)+ return()+ endif()+ check_cxx_source_compiles(+ "${headers}void probe(const PHLWINDOW& w) { (void)w->m_isMapped; (void)w->m_isX11; (void)w->getPID(); (void)g_pInputManager->m_exclusiveLSes.empty(); }"+ CUA_HYPRLAND_HAS_LEGACY_WINDOW_API)+ if(CUA_HYPRLAND_HAS_LEGACY_WINDOW_API)+ set(${output} 0 PARENT_SCOPE)+ else()+ set(${output} unsupported PARENT_SCOPE)+ endif()+endfunction()diff --git a/libs/cua-driver/hyprland-plugin/packaging/release/bundle.py b/libs/cua-driver/hyprland-plugin/packaging/release/bundle.pyindex 4d37bab463..24c78bae5a 100644--- a/libs/cua-driver/hyprland-plugin/packaging/release/bundle.py+++ b/libs/cua-driver/hyprland-plugin/packaging/release/bundle.py@@ -43,6 +43,8 @@ src/session.cppsrc/status.cpptests/agent_key_repeat_test.pytests/cmake-api/CMakeLists.txt+tests/cmake-api/include/src/Compositor.hpp+tests/cmake-api/include/src/managers/input/InputManager.hpptests/cmake-api/include/src/plugins/PluginAPI.hpptests/desktop_fault_policy_fixture.cpptests/desktop_fault_policy_test.pydiff --git a/libs/cua-driver/hyprland-plugin/packaging/release/test_release.py b/libs/cua-driver/hyprland-plugin/packaging/release/test_release.pyindex 7042569d3e..62210e1a58 100644--- a/libs/cua-driver/hyprland-plugin/packaging/release/test_release.py+++ b/libs/cua-driver/hyprland-plugin/packaging/release/test_release.py@@ -107,7 +107,7 @@ class ReleaseTest(unittest.TestCase):configure,["cmake", "--build", str(build), "--target", "cua_hyprland_foreground_route_test"],["ctest", "--test-dir", str(build), "--output-on-failure", "--no-tests=error",- "-R", "^cua_hyprland_desktop_fault_policy_test$"],+ "-R", "^cua_hyprland_(desktop_fault_policy|cmake_api)_test$"],):result = subprocess.run(command, capture_output=True, text=True, timeout=120)self.assertEqual(result.returncode, 0, result.stdout + result.stderr)diff --git a/libs/cua-driver/hyprland-plugin/src/input_experiment.cpp b/libs/cua-driver/hyprland-plugin/src/input_experiment.cppindex ea89e6f6a5..1660908c7e 100644--- a/libs/cua-driver/hyprland-plugin/src/input_experiment.cpp+++ b/libs/cua-driver/hyprland-plugin/src/input_experiment.cpp@@ -71,6 +71,41 @@ constexpr bool kProduction = true;constexpr bool kProduction = false;#endif+#ifndef CUA_HYPRLAND_WINDOW_BACKEND_API+#error CUA_HYPRLAND_WINDOW_BACKEND_API must name the detected Hyprland window API+#endif+// Hyprland 0.57 moved window identity onto the window backend and renamed the+// exclusive layer list when pointer focus stopped following it (#15899). The+// input guard still refuses while any exclusive layer surface is present.+bool window_mapped(const PHLWINDOW& window) {+#if CUA_HYPRLAND_WINDOW_BACKEND_API+ return window->mapped();+#else+ return window->m_isMapped;+#endif+}+bool window_is_x11(const PHLWINDOW& window) {+#if CUA_HYPRLAND_WINDOW_BACKEND_API+ return window->backend().isX11();+#else+ return window->m_isX11;+#endif+}+pid_t window_pid(const PHLWINDOW& window) {+#if CUA_HYPRLAND_WINDOW_BACKEND_API+ return window->backend().pid();+#else+ return window->getPID();+#endif+}+const std::vector<PHLLSREF>& exclusive_layer_surfaces() {+#if CUA_HYPRLAND_WINDOW_BACKEND_API+ return g_pInputManager->m_exclusiveKeyboardLSes;+#else+ return g_pInputManager->m_exclusiveLSes;+#endif+}+#ifdef CUA_HYPRLAND_TEST_INPUTstd::uint64_t unix_ms() {return std::chrono::duration_cast<std::chrono::milliseconds>(@@ -524,8 +559,8 @@ struct InputExperiment::Impl {}static std::optional<std::array<double, 6>> target_geometry(const PHLWINDOW& window, const SP<CWLSurfaceResource>& surface) {- if (!window || !surface || !window->m_isMapped || window->isHidden() ||- window->m_isX11 || window->resource() != surface || !surface->m_mapped || !surface->good()) return std::nullopt;+ if (!window || !surface || !window_mapped(window) || window->isHidden() ||+ window_is_x11(window) || window->resource() != surface || !surface->m_mapped || !surface->good()) return std::nullopt;// Match Driver's captured client surface, not the decorated window box// (which includes compositor borders and shifts clicks by their width).const auto box = window->surfaceLogicalBox(); const auto surface_box = box;@@ -845,7 +880,7 @@ struct InputExperiment::Impl {.physical_keys = pressed,.physical_buttons = g_pInputManager->hasHeldButtons(),.grab = bool(g_pSeatManager->m_seatGrab) || bool(g_layoutManager->dragController()->target()) ||- !g_pInputManager->m_exclusiveLSes.empty(),+ !exclusive_layer_surfaces().empty(),.dnd = PROTO::data && PROTO::data->dndActive(),.constraint = g_pInputManager->isConstrained(),.exact_keyboard_focus = root && g_pSeatManager->m_state.keyboardFocus == root &&@@ -1147,8 +1182,8 @@ struct InputExperiment::Impl {const auto pid = number(f[1]); const auto address = number(f[2], 16);PHLWINDOW window;for (const auto& w : Desktop::windowState()->windows())- if (reinterpret_cast<std::uintptr_t>(w.get()) == address && static_cast<std::uint64_t>(w->getPID()) == pid) window = w;- if (!window || window->m_isX11 || !window->m_isMapped || window->isHidden() || !window->resource()) {+ if (reinterpret_cast<std::uintptr_t>(w.get()) == address && static_cast<std::uint64_t>(window_pid(w)) == pid) window = w;+ if (!window || window_is_x11(window) || !window_mapped(window) || window->isHidden() || !window->resource()) {invalidate(c); send(c, refusal("stale_target")); return;}// Retire the old target before rebinding: even if the new target'sdiff --git a/libs/cua-driver/hyprland-plugin/tests/cmake-api/CMakeLists.txt b/libs/cua-driver/hyprland-plugin/tests/cmake-api/CMakeLists.txtindex 3d71084011..322823222c 100644--- a/libs/cua-driver/hyprland-plugin/tests/cmake-api/CMakeLists.txt+++ b/libs/cua-driver/hyprland-plugin/tests/cmake-api/CMakeLists.txt@@ -21,6 +21,21 @@ foreach(tier IN ITEMS socket1 legacy unsupported socket1)endif()endforeach()+foreach(tier IN ITEMS window_backend window_legacy window_unsupported window_backend)+ cua_detect_hyprland_window_api(actual "${CMAKE_CURRENT_SOURCE_DIR}/include"+ "-DCUA_PROBE_${tier}=1;-DCUA_PROBE_FLAG=1")+ if(tier STREQUAL "window_backend")+ set(expected 1)+ elseif(tier STREQUAL "window_legacy")+ set(expected 0)+ else()+ set(expected unsupported)+ endif()+ if(NOT actual STREQUAL expected)+ message(FATAL_ERROR "Expected ${tier} (${expected}), found ${actual}")+ endif()+endforeach()+if(NOT CMAKE_CXX_STANDARD STREQUAL "17" ORNOT CMAKE_REQUIRED_FLAGS STREQUAL "-DCUA_CALLER_SETTING=1" ORDEFINED CMAKE_TRY_COMPILE_TARGET_TYPE)diff --git a/libs/cua-driver/hyprland-plugin/tests/cmake-api/include/src/Compositor.hpp b/libs/cua-driver/hyprland-plugin/tests/cmake-api/include/src/Compositor.hppnew file mode 100644index 0000000000..da58e255ce--- /dev/null+++ b/libs/cua-driver/hyprland-plugin/tests/cmake-api/include/src/Compositor.hpp@@ -0,0 +1,30 @@+#pragma once++#if __cplusplus <= 202302L+#error The window API probe must compile in C++26 mode+#endif+#ifndef CUA_PROBE_FLAG+#error The window API probe must propagate pkg-config flags+#endif++#include <memory>++#if defined(CUA_PROBE_window_backend)+struct IWindowBackend {+ bool isX11() const;+ int pid() const;+};+struct CWindow {+ bool mapped() const;+ const IWindowBackend& backend() const;+};+#elif defined(CUA_PROBE_window_legacy)+struct CWindow {+ bool m_isMapped;+ bool m_isX11;+ int getPID();+};+#else+struct CWindow {};+#endif+using PHLWINDOW = std::shared_ptr<CWindow>;diff --git a/libs/cua-driver/hyprland-plugin/tests/cmake-api/include/src/managers/input/InputManager.hpp b/libs/cua-driver/hyprland-plugin/tests/cmake-api/include/src/managers/input/InputManager.hppnew file mode 100644index 0000000000..9868f88417--- /dev/null+++ b/libs/cua-driver/hyprland-plugin/tests/cmake-api/include/src/managers/input/InputManager.hpp@@ -0,0 +1,13 @@+#pragma once++#include <memory>+#include <vector>++struct CInputManager {+#if defined(CUA_PROBE_window_backend)+ std::vector<int> m_exclusiveKeyboardLSes;+#elif defined(CUA_PROBE_window_legacy)+ std::vector<int> m_exclusiveLSes;+#endif+};+extern std::unique_ptr<CInputManager> g_pInputManager;