diff --git a/src/Compositor.cpp b/src/Compositor.cpp index ee1a0a1cd..50ce621ac 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -402,6 +402,11 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) { return; } + if (pWindow->m_bNoFocus) { + Debug::log(LOG, "Ignoring focus to nofocus window!"); + return; + } + if (!pWindow || !windowValidMapped(pWindow)) { wlr_seat_keyboard_notify_clear_focus(m_sSeat.seat); return; diff --git a/src/Window.hpp b/src/Window.hpp index 115801381..7dcbb8509 100644 --- a/src/Window.hpp +++ b/src/Window.hpp @@ -63,6 +63,9 @@ public: DYNLISTENER(configureX11); // + // For nofocus + bool m_bNoFocus = false; + SSurfaceTreeNode* m_pSurfaceTree = nullptr; // Animated border diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 1083db445..6716de5d6 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -341,6 +341,7 @@ void CConfigManager::handleWindowRule(const std::string& command, const std::str && RULE.find("size") != 0 && RULE.find("pseudo") != 0 && RULE.find("monitor") != 0 + && RULE.find("nofocus") != 0 && RULE.find("workspace") != 0) { Debug::log(ERR, "Invalid rule found: %s", RULE.c_str()); parseError = "Invalid rule found: " + RULE; diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 88c1d8974..926d1685a 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -87,6 +87,8 @@ void Events::listener_mapWindow(void* owner, void* data) { PWINDOW->m_bIsFloating = false; } else if (r.szRule.find("pseudo") == 0) { PWINDOW->m_bIsPseudotiled = true; + } else if (r.szRule.find("nofocus") == 0) { + PWINDOW->m_bNoFocus = true; } else if (r.szRule.find("opacity") == 0) { try { PWINDOW->m_sSpecialRenderData.alpha = std::stof(r.szRule.substr(r.szRule.find_first_of(' ') + 1)); @@ -147,7 +149,8 @@ void Events::listener_mapWindow(void* owner, void* data) { PWINDOW->m_vPseudoSize = PWINDOW->m_vRealSize.goalv() - Vector2D(10,10); } - g_pCompositor->focusWindow(PWINDOW); + if (!PWINDOW->m_bNoFocus) + g_pCompositor->focusWindow(PWINDOW); PWINDOW->m_pSurfaceTree = SubsurfaceTree::createTreeRoot(g_pXWaylandManager->getWindowSurface(PWINDOW), addViewCoords, PWINDOW);