mirror of
https://github.com/hyprwm/Hypr.git
synced 2024-11-22 13:35:57 +01:00
sanity checks
This commit is contained in:
parent
7d6a8e8ee7
commit
1074d411eb
2 changed files with 37 additions and 0 deletions
|
@ -213,6 +213,35 @@ bool CWindowManager::handleEvent() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: add an empty space check
|
||||||
|
void CWindowManager::performSanityCheckForWorkspace(int WorkspaceID) {
|
||||||
|
for (auto& windowA : windows) {
|
||||||
|
if (windowA.getWorkspaceID() != WorkspaceID)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (auto& windowB : windows) {
|
||||||
|
if (windowB.getWorkspaceID() != WorkspaceID)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (windowB.getDrawable() == windowA.getDrawable())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Check if A and B overlap, if don't, continue
|
||||||
|
if ((windowA.getPosition().x >= (windowB.getPosition() + windowB.getSize()).x || windowB.getPosition().x >= (windowA.getPosition() + windowA.getSize()).x
|
||||||
|
|| windowA.getPosition().y >= (windowB.getPosition() + windowB.getSize()).y || windowB.getPosition().y >= (windowA.getPosition() + windowA.getSize()).y)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Overlap detected! Fix window B
|
||||||
|
if (windowB.getIsFloating()) {
|
||||||
|
calculateNewTileSetOldTile(&windowB);
|
||||||
|
} else {
|
||||||
|
calculateNewFloatingWindow(&windowB);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CWindowManager::cleanupUnusedWorkspaces() {
|
void CWindowManager::cleanupUnusedWorkspaces() {
|
||||||
std::vector<CWorkspace> temp = workspaces;
|
std::vector<CWorkspace> temp = workspaces;
|
||||||
|
|
||||||
|
@ -678,6 +707,10 @@ void CWindowManager::changeWorkspaceByID(int ID) {
|
||||||
if (workspace.getID() == ID) {
|
if (workspace.getID() == ID) {
|
||||||
activeWorkspaces[workspace.getMonitor()] = workspace.getID();
|
activeWorkspaces[workspace.getMonitor()] = workspace.getID();
|
||||||
LastWindow = -1;
|
LastWindow = -1;
|
||||||
|
|
||||||
|
// Perform a sanity check for the new workspace
|
||||||
|
performSanityCheckForWorkspace(ID);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -689,6 +722,9 @@ void CWindowManager::changeWorkspaceByID(int ID) {
|
||||||
workspaces.push_back(newWorkspace);
|
workspaces.push_back(newWorkspace);
|
||||||
activeWorkspaces[MONITOR->ID] = workspaces[workspaces.size() - 1].getID();
|
activeWorkspaces[MONITOR->ID] = workspaces[workspaces.size() - 1].getID();
|
||||||
LastWindow = -1;
|
LastWindow = -1;
|
||||||
|
|
||||||
|
// Perform a sanity check for the new workspace
|
||||||
|
performSanityCheckForWorkspace(ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWindowManager::setAllWindowsDirty() {
|
void CWindowManager::setAllWindowsDirty() {
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
void setupManager();
|
void setupManager();
|
||||||
bool handleEvent();
|
bool handleEvent();
|
||||||
void refreshDirtyWindows();
|
void refreshDirtyWindows();
|
||||||
|
void performSanityCheckForWorkspace(int);
|
||||||
|
|
||||||
void setFocusedWindow(xcb_drawable_t);
|
void setFocusedWindow(xcb_drawable_t);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue