From d73b3bf92bc42fc5245e1f037b075fdde0ab00e5 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 28 Nov 2021 16:14:12 +0100 Subject: [PATCH] made all kinds of notifications and dialogs floating by default --- src/events/events.cpp | 8 ++++++++ src/events/events.hpp | 3 +++ src/window.cpp | 2 +- src/windowManager.cpp | 37 ++++++++++++++++++++++++++++++++++--- 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/src/events/events.cpp b/src/events/events.cpp index cbe535e..41000ad 100644 --- a/src/events/events.cpp +++ b/src/events/events.cpp @@ -80,6 +80,8 @@ void Events::eventDestroy(xcb_generic_event_t* event) { xcb_kill_client(g_pWindowManager->DisplayConnection, E->window); g_pWindowManager->closeWindowAllChecks(E->window); + + // Can someone tell me why the fuck some dialogs do not report they are closed and still respond to XCB even after they disappear??? } CWindow* Events::remapFloatingWindow(int windowID, int forcemonitor) { @@ -114,6 +116,12 @@ CWindow* Events::remapFloatingWindow(int windowID, int forcemonitor) { window.setDefaultSize(Vector2D(g_pWindowManager->Screen->width_in_pixels / 2.f, g_pWindowManager->Screen->height_in_pixels / 2.f)); } + if (nextWindowCentered) { + nextWindowCentered = false; + + window.setDefaultPosition(g_pWindowManager->monitors[CURRENTSCREEN].vecSize / 2.f - window.getDefaultSize() / 2.f); + } + // // Dock Checks // diff --git a/src/events/events.hpp b/src/events/events.hpp index 08c35f5..1c26ef5 100644 --- a/src/events/events.hpp +++ b/src/events/events.hpp @@ -24,4 +24,7 @@ namespace Events { void setThread(); inline timer_t timerid; + + // For docks etc + inline bool nextWindowCentered = false; }; \ No newline at end of file diff --git a/src/window.cpp b/src/window.cpp index 2c61a1b..96e9fc3 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1,7 +1,7 @@ #include "window.hpp" #include "windowManager.hpp" -CWindow::CWindow() { this->setImmovable(false); this->setDirty(true); this->setFullscreen(false); this->setIsFloating(false); this->setParentNodeID(0); this->setChildNodeAID(0); this->setChildNodeBID(0); this->setName(""); } +CWindow::CWindow() { 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() { } void CWindow::generateNodeID() { diff --git a/src/windowManager.cpp b/src/windowManager.cpp index 45a58bb..ebb2223 100644 --- a/src/windowManager.cpp +++ b/src/windowManager.cpp @@ -491,6 +491,32 @@ void CWindowManager::sanityCheckOnWorkspace(int workspaceID) { closeWindowAllChecks(w.getDrawable()); continue; } + + // Type 2: is hidden. + const auto window = w.getDrawable(); + PROP(wm_type_cookie, HYPRATOMS["_NET_WM_WINDOW_TYPE"], UINT32_MAX); + + if (wm_type_cookiereply == NULL || xcb_get_property_value_length(wm_type_cookiereply) < 1) { + Debug::log(LOG, "No preferred type found."); + } else { + const auto ATOMS = (xcb_atom_t*)xcb_get_property_value(wm_type_cookiereply); + if (!ATOMS) { + Debug::log(ERR, "Atoms not found in preferred type!"); + } else { + if (xcbContainsAtom(wm_type_cookiereply, HYPRATOMS["_NET_WM_STATE_HIDDEN"])) { + // delete it + // NOTE: this is NOT the cause of windows in tray not being able + // to open. + free(wm_type_cookiereply); + + Debug::log(LOG, "Found a dead window, ID: " + std::to_string(w.getDrawable()) + ", removing it."); + + closeWindowAllChecks(w.getDrawable()); + continue; + } + } + } + free(wm_type_cookiereply); } } } @@ -1244,10 +1270,16 @@ bool CWindowManager::shouldBeFloatedOnInit(int64_t window) { if (!ATOMS) { Debug::log(ERR, "Atoms not found in preferred type!"); } else { - if (xcbContainsAtom(wm_type_cookiereply, HYPRATOMS["_NET_WM_WINDOW_TYPE_NOTIFICATION"])) { + if (xcbContainsAtom(wm_type_cookiereply, HYPRATOMS["_NET_WM_WINDOW_TYPE_DOCK"])) { free(wm_type_cookiereply); return true; - } else if (xcbContainsAtom(wm_type_cookiereply, HYPRATOMS["_NET_WM_WINDOW_TYPE_DOCK"])) { + } else if (xcbContainsAtom(wm_type_cookiereply, HYPRATOMS["_NET_WM_WINDOW_TYPE_DIALOG"]) + || xcbContainsAtom(wm_type_cookiereply, HYPRATOMS["_NET_WM_WINDOW_TYPE_TOOLBAR"]) + || xcbContainsAtom(wm_type_cookiereply, HYPRATOMS["_NET_WM_WINDOW_TYPE_UTILITY"]) + || xcbContainsAtom(wm_type_cookiereply, HYPRATOMS["_NET_WM_STATE_MODAL"]) + || xcbContainsAtom(wm_type_cookiereply, HYPRATOMS["_NET_WM_WINDOW_TYPE_SPLASH"])) { + + Events::nextWindowCentered = true; free(wm_type_cookiereply); return true; } @@ -1281,7 +1313,6 @@ void CWindowManager::doPostCreationChecks(CWindow* pWindow) { const auto window = pWindow->getDrawable(); PROP(wm_type_cookie, HYPRATOMS["_NET_WM_WINDOW_TYPE"], UINT32_MAX); - xcb_atom_t TYPEATOM = NULL; if (wm_type_cookiereply == NULL || xcb_get_property_value_length(wm_type_cookiereply) < 1) { Debug::log(LOG, "No preferred type found.");