respect docs take 2

This commit is contained in:
vaxerski 2021-12-17 20:58:32 +01:00
parent 090048410f
commit cd3a229fa2
5 changed files with 76 additions and 5 deletions

View file

@ -209,6 +209,8 @@ CWindow* Events::remapFloatingWindow(int windowID, int forcemonitor) {
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.setDock(true);
}
}
}
@ -239,6 +241,10 @@ CWindow* Events::remapFloatingWindow(int windowID, int forcemonitor) {
// Make all floating windows above
g_pWindowManager->setAllFloatingWindowsTop();
// Fix docks
if (window.getDock())
g_pWindowManager->recalcAllDocks();
return g_pWindowManager->getWindowFromDrawable(windowID);
}

View file

@ -12,4 +12,7 @@ struct SMonitor {
int ID = -1;
std::string szName = "";
Vector2D vecReservedTopLeft = Vector2D(0,0);
Vector2D vecReservedBottomRight = Vector2D(0,0);
};

View file

@ -88,6 +88,9 @@ public:
// Animate borders
EXPOSED_MEMBER(RealBorderColor, CFloatingColor, c);
EXPOSED_MEMBER(EffectiveBorderColor, CFloatingColor, c);
// Docks
EXPOSED_MEMBER(Dock, bool, b);
private:

View file

@ -133,7 +133,7 @@ void CWindowManager::setupRandrMonitors() {
xcb_flush(DisplayConnection);
if (monitors.size() == 0) {
if (monitors.size() == 0 || ISDEBUG) {
// RandR failed!
Debug::log(WARN, "RandR failed!");
monitors.clear();
@ -537,11 +537,18 @@ CWindow* CWindowManager::getWindowFromDrawable(int64_t window) {
if (!window)
return nullptr;
for(auto& w : windows) {
for (auto& w : windows) {
if (w.getDrawable() == window) {
return &w;
}
}
for (auto& w : unmappedWindows) {
if (w.getDrawable() == window) {
return &w;
}
}
return nullptr;
}
@ -672,6 +679,7 @@ void CWindowManager::setEffectiveSizePosUsingConfig(CWindow* pWindow) {
const auto MONITOR = getMonitorFromWindow(pWindow);
const auto BARHEIGHT = ConfigManager::getInt("bar:enabled") == 1 ? ConfigManager::getInt("bar:height") : ConfigManager::parseError == "" ? 0 : ConfigManager::getInt("bar:height");
// set some flags.
const bool DISPLAYLEFT = STICKS(pWindow->getPosition().x, MONITOR->vecPosition.x);
const bool DISPLAYRIGHT = STICKS(pWindow->getPosition().x + pWindow->getSize().x, MONITOR->vecPosition.x + MONITOR->vecSize.x);
@ -681,12 +689,18 @@ void CWindowManager::setEffectiveSizePosUsingConfig(CWindow* pWindow) {
pWindow->setEffectivePosition(pWindow->getPosition() + Vector2D(ConfigManager::getInt("border_size"), ConfigManager::getInt("border_size")));
pWindow->setEffectiveSize(pWindow->getSize() - (Vector2D(ConfigManager::getInt("border_size"), ConfigManager::getInt("border_size")) * 2));
const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? ConfigManager::getInt("gaps_out") + MONITOR->vecReservedTopLeft.x : ConfigManager::getInt("gaps_in"),
DISPLAYTOP ? ConfigManager::getInt("gaps_out") + MONITOR->vecReservedTopLeft.y + BARHEIGHT : ConfigManager::getInt("gaps_in"));
const auto OFFSETBOTTOMRIGHT = Vector2D( DISPLAYRIGHT ? ConfigManager::getInt("gaps_out") + MONITOR->vecReservedBottomRight.x : ConfigManager::getInt("gaps_in"),
DISPLAYBOTTOM ? ConfigManager::getInt("gaps_out") + MONITOR->vecReservedBottomRight.y : ConfigManager::getInt("gaps_in"));
// do gaps, set top left
pWindow->setEffectivePosition(pWindow->getEffectivePosition() + Vector2D(DISPLAYLEFT ? ConfigManager::getInt("gaps_out") : ConfigManager::getInt("gaps_in"), DISPLAYTOP ? ConfigManager::getInt("gaps_out") + (MONITOR->ID == ConfigManager::getInt("bar:monitor") ? BARHEIGHT : 0) : ConfigManager::getInt("gaps_in")));
pWindow->setEffectivePosition(pWindow->getEffectivePosition() + OFFSETTOPLEFT);
// fix to old size bottom right
pWindow->setEffectiveSize(pWindow->getEffectiveSize() - Vector2D(DISPLAYLEFT ? ConfigManager::getInt("gaps_out") : ConfigManager::getInt("gaps_in"), DISPLAYTOP ? ConfigManager::getInt("gaps_out") + (MONITOR->ID == ConfigManager::getInt("bar:monitor") ? BARHEIGHT : 0) : ConfigManager::getInt("gaps_in")));
pWindow->setEffectiveSize(pWindow->getEffectiveSize() - OFFSETTOPLEFT);
// set bottom right
pWindow->setEffectiveSize(pWindow->getEffectiveSize() - Vector2D(DISPLAYRIGHT ? ConfigManager::getInt("gaps_out") : ConfigManager::getInt("gaps_in"), DISPLAYBOTTOM ? ConfigManager::getInt("gaps_out") : ConfigManager::getInt("gaps_in")));
pWindow->setEffectiveSize(pWindow->getEffectiveSize() - OFFSETBOTTOMRIGHT);
}
CWindow* CWindowManager::findWindowAtCursor() {
@ -1008,14 +1022,22 @@ void CWindowManager::closeWindowAllChecks(int64_t id) {
if (!CLOSEDWINDOW)
return; // It's not in the vec, ignore. (weird)
CLOSEDWINDOW->setDead(true);
if (const auto WORKSPACE = getWorkspaceByID(CLOSEDWINDOW->getWorkspaceID()); WORKSPACE && CLOSEDWINDOW->getFullscreen())
WORKSPACE->setHasFullscreenWindow(false);
if (!CLOSEDWINDOW->getIsFloating())
g_pWindowManager->fixWindowOnClose(CLOSEDWINDOW);
const bool WASDOCK = CLOSEDWINDOW->getDock();
// delete off of the arr
g_pWindowManager->removeWindowFromVectorSafe(id);
// Fix docks
if (WASDOCK)
g_pWindowManager->recalcAllDocks();
}
void CWindowManager::fixMasterWorkspaceOnClosed(CWindow* pWindow) {
@ -1774,4 +1796,40 @@ void CWindowManager::handleClientMessage(xcb_client_message_event_t* E) {
Debug::log(LOG, "Message recieved to set active for " + std::to_string(PWINDOW->getDrawable()));
}
}
void CWindowManager::recalcAllDocks() {
for (auto& mon : monitors) {
mon.vecReservedTopLeft = {0, 0};
mon.vecReservedBottomRight = {0, 0};
setAllWorkspaceWindowsDirtyByID(activeWorkspaces[mon.ID]);
}
for (auto& w : windows) {
if (!w.getDock() || w.getDead() || !w.getIsFloating())
continue;
const auto MONITOR = &monitors[w.getMonitor()];
const auto VERTICAL = w.getSize().x / w.getSize().y < 1;
if (VERTICAL) {
if (w.getPosition().x < MONITOR->vecSize.x / 2.f + MONITOR->vecPosition.x) {
// Left
MONITOR->vecReservedTopLeft = Vector2D(w.getSize().x, 0);
} else {
// Right
MONITOR->vecReservedBottomRight = Vector2D(w.getSize().x, 0);
}
} else {
if (w.getPosition().y < MONITOR->vecSize.y / 2.f + MONITOR->vecPosition.y) {
// Top
MONITOR->vecReservedTopLeft = Vector2D(0, w.getSize().y);
} else {
// Bottom
MONITOR->vecReservedBottomRight = Vector2D(0, w.getSize().y);
}
}
}
}

View file

@ -83,6 +83,7 @@ public:
void moveActiveWindowToWorkspace(int);
void warpCursorTo(Vector2D);
void toggleWindowFullscrenn(const int&);
void recalcAllDocks();
void changeWorkspaceByID(int);
void setAllWorkspaceWindowsDirtyByID(int);