seems like I fixed the docks

This commit is contained in:
vaxerski 2021-12-19 12:33:36 +01:00
parent 2effe5902e
commit 43ea3674d4
4 changed files with 63 additions and 5 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -93,7 +93,8 @@ public:
// Docks
EXPOSED_MEMBER(Dock, bool, b);
EXPOSED_MEMBER(DockAlign, EDockAlign, e);
// Rounding
EXPOSED_MEMBER(Rounded, bool, b);

View File

@ -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);
}
}