From 44914a7cf4108a31aab86fb96efde9dbcd50c889 Mon Sep 17 00:00:00 2001 From: Trey Moen <50057480+greatgitsby@users.noreply.github.com> Date: Sat, 12 Sep 2026 22:45:32 -0700 Subject: [PATCH] cabana: remove custom focus-loss handling (#38884) * cabana: fix focus handling across docked and floating windows * cabana: remove custom focus-loss handling --- openpilot/tools/cabana/ui/app.cc | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/openpilot/tools/cabana/ui/app.cc b/openpilot/tools/cabana/ui/app.cc index e45eaac6fb..beb693b1e3 100644 --- a/openpilot/tools/cabana/ui/app.cc +++ b/openpilot/tools/cabana/ui/app.cc @@ -28,36 +28,6 @@ void keyCallback(GLFWwindow *window, int key, int scancode, int action, int mods ImGui_ImplGlfw_KeyCallback(window, key, scancode, action, mods); if (action == GLFW_PRESS) g_key_events.push_back({key, mods}); } -// imgui releases every mouse button when the window loses focus, which aborts a panel tear-off drag and -// docks the panel back. X11 keeps delivering the drag through the implicit grab, so hold a focus loss back -// while a button is down and deliver it after the release (see deliverPendingFocusLoss). -GLFWwindow *g_focus_lost_window = nullptr; -// macOS drops the button on its own when the focus moves, and holding the loss back there swallowed the -// first click in a popup: the click makes the popup's window key, the main window's loss lands on the -// release and imgui clears its mouse state before it sees that release -void windowFocusCallback(GLFWwindow *w, int f) { -#ifdef __APPLE__ - ImGui_ImplGlfw_WindowFocusCallback(w, f); -#else - if (f) { - g_focus_lost_window = nullptr; - ImGui_ImplGlfw_WindowFocusCallback(w, f); - } else { - g_focus_lost_window = w; - } -#endif -} -bool anyMouseButtonDown(GLFWwindow *w) { - for (int b = GLFW_MOUSE_BUTTON_1; b <= GLFW_MOUSE_BUTTON_LAST; ++b) { - if (glfwGetMouseButton(w, b) == GLFW_PRESS) return true; - } - return false; -} -void deliverPendingFocusLoss() { - if (g_focus_lost_window == nullptr || anyMouseButtonDown(g_focus_lost_window)) return; - ImGui_ImplGlfw_WindowFocusCallback(g_focus_lost_window, GLFW_FALSE); - g_focus_lost_window = nullptr; -} void hookViewportCallbacks() { for (ImGuiViewport *viewport : ImGui::GetPlatformIO().Viewports) { @@ -89,7 +59,6 @@ void paceFrame() { void renderFrame(GLFWwindow *window, MainWindow *win) { glfwPollEvents(); - deliverPendingFocusLoss(); utils::drainMainThreadQueue(); int fb_w = 0, fb_h = 0; @@ -175,7 +144,6 @@ public: throw std::runtime_error("ImGui_ImplGlfw_InitForOpenGL failed"); } glfwSetKeyCallback(window, keyCallback); - glfwSetWindowFocusCallback(window, windowFocusCallback); if (!ImGui_ImplOpenGL3_Init("#version 330")) { ImGui_ImplGlfw_Shutdown(); ImPlot::DestroyContext();