From 43ea3674d44845474e9f6c602b0b40ce6b7020ac Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 19 Dec 2021 12:33:36 +0100 Subject: [PATCH] seems like I fixed the docks --- src/events/events.cpp | 45 ++++++++++++++++++++++++++++++++++++++++-- src/utilities/Util.hpp | 7 +++++++ src/window.hpp | 3 ++- src/windowManager.cpp | 13 ++++++++++-- 4 files changed, 63 insertions(+), 5 deletions(-) diff --git a/src/events/events.cpp b/src/events/events.cpp index 5699714..a7a49c6 100644 --- a/src/events/events.cpp +++ b/src/events/events.cpp @@ -205,8 +205,49 @@ CWindow* Events::remapFloatingWindow(int windowID, int forcemonitor) { window.setDefaultPosition(Vector2D(GEOMETRY->x, GEOMETRY->y)); window.setDefaultSize(Vector2D(GEOMETRY->width, GEOMETRY->height)); - Debug::log(LOG, "New dock created, setting default XYWH to: " + std::to_string(GEOMETRY->x) + ", " + std::to_string(GEOMETRY->y) - + ", " + std::to_string(GEOMETRY->width) + ", " + std::to_string(GEOMETRY->height)); + window.setDockAlign(DOCK_TOP); + + // Check reserved + const auto STRUTREPLY = xcb_get_property_reply(g_pWindowManager->DisplayConnection, xcb_get_property(g_pWindowManager->DisplayConnection, false, windowID, HYPRATOMS["_NET_WM_STRUT_PARTIAL"], XCB_GET_PROPERTY_TYPE_ANY, 0, (4294967295U)), NULL); + + if (!STRUTREPLY || xcb_get_property_value_length(STRUTREPLY) == 0) { + Debug::log(ERR, "Couldn't get strut for dock."); + } else { + const uint32_t* STRUT = (uint32_t*)xcb_get_property_value(STRUTREPLY); + + if (!STRUT) { + Debug::log(ERR, "Couldn't get strut for dock. (2)"); + } else { + // Set the dock's align + // LEFT RIGHT TOP BOTTOM + // 0 1 2 3 + if (STRUT[2] > 0 && STRUT[3] == 0) { + // top + window.setDockAlign(DOCK_TOP); + } else if (STRUT[2] == 0 && STRUT[3] > 0) { + // bottom + window.setDockAlign(DOCK_BOTTOM); + } + + // little todo: support left/right docks + } + } + + free(STRUTREPLY); + + switch (window.getDockAlign()) { + case DOCK_TOP: + window.setDefaultPosition(Vector2D(g_pWindowManager->monitors[CURRENTSCREEN].vecPosition.x, g_pWindowManager->monitors[CURRENTSCREEN].vecPosition.y)); + break; + case DOCK_BOTTOM: + window.setDefaultPosition(Vector2D(g_pWindowManager->monitors[CURRENTSCREEN].vecPosition.x, g_pWindowManager->monitors[CURRENTSCREEN].vecPosition.y + g_pWindowManager->monitors[CURRENTSCREEN].vecSize.y - window.getDefaultSize().y)); + break; + default: + break; + } + + Debug::log(LOG, "New dock created, setting default XYWH to: " + std::to_string(window.getDefaultPosition().x) + ", " + std::to_string(window.getDefaultPosition().y) + + ", " + std::to_string(window.getDefaultSize().x) + ", " + std::to_string(window.getDefaultSize().y)); window.setDock(true); } diff --git a/src/utilities/Util.hpp b/src/utilities/Util.hpp index 8181ce6..d51a49a 100644 --- a/src/utilities/Util.hpp +++ b/src/utilities/Util.hpp @@ -36,6 +36,13 @@ public: } }; +enum EDockAlign { + DOCK_LEFT = 0, + DOCK_RIGHT, + DOCK_TOP, + DOCK_BOTTOM +}; + std::string exec(const char* cmd); void clearLogs(); void emptyEvent(xcb_drawable_t window = 0); diff --git a/src/window.hpp b/src/window.hpp index 5d77d08..9594271 100644 --- a/src/window.hpp +++ b/src/window.hpp @@ -93,7 +93,8 @@ public: // Docks EXPOSED_MEMBER(Dock, bool, b); - + EXPOSED_MEMBER(DockAlign, EDockAlign, e); + // Rounding EXPOSED_MEMBER(Rounded, bool, b); diff --git a/src/windowManager.cpp b/src/windowManager.cpp index a8c95cd..5fbbe55 100644 --- a/src/windowManager.cpp +++ b/src/windowManager.cpp @@ -337,7 +337,7 @@ void CWindowManager::refreshDirtyWindows() { window.setDirty(false); // Check if the window isn't a node or has the noInterventions prop - if (window.getChildNodeAID() != 0 || window.getNoInterventions()) + if (window.getChildNodeAID() != 0 || window.getNoInterventions() || window.getDock()) continue; setEffectiveSizePosUsingConfig(&window); @@ -941,7 +941,7 @@ void CWindowManager::calculateNewFloatingWindow(CWindow* pWindow) { if (!pWindow) return; - if (!pWindow->getNoInterventions()) { + if (!pWindow->getNoInterventions() && !pWindow->getDock()) { pWindow->setPosition(pWindow->getEffectivePosition() + Vector2D(3,3)); pWindow->setSize(pWindow->getEffectiveSize() - Vector2D(6, 6)); @@ -1877,5 +1877,14 @@ void CWindowManager::recalcAllDocks() { MONITOR->vecReservedBottomRight = Vector2D(0, w.getSize().y); } } + + // Move it + Values[0] = w.getDefaultPosition().x; + Values[1] = w.getDefaultPosition().y; + xcb_configure_window(DisplayConnection, w.getDrawable(), XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, Values); + + Values[0] = w.getDefaultSize().x; + Values[1] = w.getDefaultSize().y; + xcb_configure_window(DisplayConnection, w.getDrawable(), XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, Values); } } \ No newline at end of file