diff --git a/src/events/events.cpp b/src/events/events.cpp index cf67931..fe767b5 100644 --- a/src/events/events.cpp +++ b/src/events/events.cpp @@ -175,11 +175,6 @@ CWindow* Events::remapFloatingWindow(int windowID, int forcemonitor) { return nullptr; } - if (PWINDOWINARR->getClassName() == "") { - Debug::log(WARN, "remapFloatingWindow with Error, not managing."); - return nullptr; - } - PWINDOWINARR->setIsFloating(true); PWINDOWINARR->setDirty(true); @@ -421,12 +416,6 @@ CWindow* Events::remapWindow(int windowID, bool wasfloating, int forcemonitor) { return nullptr; } - if (PWINDOWINARR->getClassName() == "Error") { - Debug::log(LOG, "Class error -> we wont manage this."); - return nullptr; - } - - PWINDOWINARR->setIsFloating(false); PWINDOWINARR->setDirty(true); @@ -635,8 +624,8 @@ void Events::eventMapWindow(xcb_generic_event_t* event) { } } - if (!pNewWindow || pNewWindow->getClassName() == "") { - Debug::log(LOG, "Removing, NULL."); + if (!pNewWindow) { + Debug::log(LOG, "Removing, NULLPTR."); g_pWindowManager->removeWindowFromVectorSafe(E->window); return; } diff --git a/src/window.cpp b/src/window.cpp index 928ae26..038553a 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1,7 +1,8 @@ #include "window.hpp" #include "windowManager.hpp" -CWindow::CWindow() { this->setRealBorderColor(0); this->setEffectiveBorderColor(0); this->setFirstOpen(true); this->setConstructed(false); this->setTransient(false); this->setLastUpdatePosition(Vector2D(0,0)); this->setLastUpdateSize(Vector2D(0,0)); this->setDock(false); this->setUnderFullscreen(false); this->setIsSleeping(true); this->setFirstAnimFrame(true); this->setIsAnimated(false); this->setDead(false); this->setMasterChildIndex(0); this->setMaster(false); this->setCanKill(false); this->setImmovable(false); this->setNoInterventions(false); this->setDirty(true); this->setFullscreen(false); this->setIsFloating(false); this->setParentNodeID(0); this->setChildNodeAID(0); this->setChildNodeBID(0); this->setName(""); } +CWindow::CWindow() { this->setRealBorderColor(0); this->setEffectiveBorderColor(0); this->setFirstOpen(true); this->setConstructed(false); this->setTransient(false); this->setLastUpdatePosition(Vector2D(0,0)); this->setLastUpdateSize(Vector2D(0,0)); this->setDock(false); this->setUnderFullscreen(false); this->setIsSleeping(true); this->setFirstAnimFrame(true); this->setIsAnimated(false); this->setDead(false); this->setMasterChildIndex(0); this->setMaster(false); this->setCanKill(false); this->setImmovable(false); this->setNoInterventions(false); this->setDirty(true); this->setFullscreen(false); this->setIsFloating(false); this->setParentNodeID(0); this->setChildNodeAID(0); this->setChildNodeBID(0); this->setName(""); + this->m_tOpenTimestamp = std::chrono::high_resolution_clock::now(); } CWindow::~CWindow() { } void CWindow::generateNodeID() { diff --git a/src/window.hpp b/src/window.hpp index 805493a..8f008cb 100644 --- a/src/window.hpp +++ b/src/window.hpp @@ -3,6 +3,7 @@ #include "defines.hpp" #include "utilities/Workspace.hpp" #include "utilities/Util.hpp" +#include class CWindow { public: @@ -38,6 +39,7 @@ public: EXPOSED_MEMBER(RoleName, std::string, sz); EXPOSED_MEMBER(Constructed, bool, b); EXPOSED_MEMBER(FirstOpen, bool, b); + EXPOSED_MEMBER(OpenTimestamp, std::chrono::high_resolution_clock::time_point, t); // Tells the window manager to reload the window's params EXPOSED_MEMBER(Dirty, bool, b); diff --git a/src/windowManager.cpp b/src/windowManager.cpp index 4cb64fd..fdfc895 100644 --- a/src/windowManager.cpp +++ b/src/windowManager.cpp @@ -2277,3 +2277,23 @@ void CWindowManager::dispatchQueuedWarp() { warpCursorTo(QueuedPointerWarp); QueuedPointerWarp = Vector2D(-1,-1); } + +void CWindowManager::unmanageUnnamedWindows() { + std::deque toRemove; + + for (auto& w : windows) { + + if (w.getClassName() == "Error" || w.getClassName() == "") { + const auto DELTA = std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - w.getOpenTimestamp()).count(); + + if (DELTA > 500) { + Debug::log(LOG, "Class error after 500ms -> we wont manage this."); + toRemove.push_back(w.getDrawable()); + } + } + } + + for (auto& wid : toRemove) { + closeWindowAllChecks(wid); + } +} \ No newline at end of file diff --git a/src/windowManager.hpp b/src/windowManager.hpp index 7afb3db..1210fd1 100644 --- a/src/windowManager.hpp +++ b/src/windowManager.hpp @@ -164,6 +164,7 @@ private: void focusOnWorkspace(const int&); void dispatchQueuedWarp(); CWindow* getMasterForWorkspace(const int&); + void unmanageUnnamedWindows(); }; inline std::unique_ptr g_pWindowManager = std::make_unique();