mirror of
https://github.com/hyprwm/Hypr.git
synced 2024-11-26 06:45:58 +01:00
Fixed some ghost window cases. (readme update too)
This commit is contained in:
parent
d284f178de
commit
9f8a71322c
4 changed files with 43 additions and 12 deletions
|
@ -26,9 +26,10 @@ Hypr is a Linux tiling window manager for Xorg. It's written in XCB with modern
|
|||
- [ ] Upgrade the status bar rendering to Cairo
|
||||
- [ ] Better status bar configability
|
||||
- [ ] Rounded corners
|
||||
- [ ] Fix ghost windows once and for all
|
||||
- [x] Fix ghost windows once and for all
|
||||
- [ ] Fix windows minimizing themselves to tray not being able to come back without pkill
|
||||
- [ ] Moving windows between workspaces without floating
|
||||
- [ ] EWMH
|
||||
- [x] EWMH ~ Basic, idk if i'll add more.
|
||||
- [ ] Docks / Fullscreen Apps etc. auto-detection
|
||||
- [ ] Fix animation flicker (if possible)
|
||||
- [ ] Config expansion (rules, default workspaces, etc.)
|
||||
|
|
|
@ -37,14 +37,7 @@ void Events::eventDestroy(xcb_generic_event_t* event) {
|
|||
const auto E = reinterpret_cast<xcb_destroy_notify_event_t*>(event);
|
||||
xcb_kill_client(g_pWindowManager->DisplayConnection, E->window);
|
||||
|
||||
// fix last window if tile
|
||||
const auto CLOSEDWINDOW = g_pWindowManager->getWindowFromDrawable(E->window);
|
||||
if (CLOSEDWINDOW && !CLOSEDWINDOW->getIsFloating()) {
|
||||
g_pWindowManager->fixWindowOnClose(CLOSEDWINDOW);
|
||||
|
||||
// delete off of the arr
|
||||
g_pWindowManager->removeWindowFromVectorSafe(E->window);
|
||||
}
|
||||
g_pWindowManager->closeWindowAllChecks(E->window);
|
||||
}
|
||||
|
||||
CWindow* Events::remapFloatingWindow(int windowID) {
|
||||
|
|
|
@ -373,6 +373,7 @@ void CWindowManager::setFocusedWindow(xcb_drawable_t window) {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: make this executed less. It's too often imo.
|
||||
void CWindowManager::sanityCheckOnWorkspace(int workspaceID) {
|
||||
for (auto& w : windows) {
|
||||
if (w.getWorkspaceID() == workspaceID) {
|
||||
|
@ -388,8 +389,11 @@ void CWindowManager::sanityCheckOnWorkspace(int workspaceID) {
|
|||
|
||||
const auto PCHILD = getWindowFromDrawable(CHILDA);
|
||||
|
||||
if (!PCHILD)
|
||||
continue; // Should be cleaned later.
|
||||
if (!PCHILD){
|
||||
// Means both children are 0 (dead)
|
||||
removeWindowFromVectorSafe(w.getDrawable());
|
||||
continue;
|
||||
}
|
||||
|
||||
PCHILD->setPosition(w.getPosition());
|
||||
PCHILD->setSize(w.getSize());
|
||||
|
@ -430,22 +434,43 @@ void CWindowManager::sanityCheckOnWorkspace(int workspaceID) {
|
|||
if (CHILDA->getIsFloating()) {
|
||||
g_pWindowManager->fixWindowOnClose(CHILDA);
|
||||
g_pWindowManager->calculateNewWindowParams(CHILDA);
|
||||
|
||||
Debug::log(LOG, "Found an invalid tiled window, ID: " + std::to_string(CHILDA->getDrawable()) + ", untiling it.");
|
||||
}
|
||||
|
||||
if (CHILDB->getIsFloating()) {
|
||||
g_pWindowManager->fixWindowOnClose(CHILDB);
|
||||
g_pWindowManager->calculateNewWindowParams(CHILDB);
|
||||
|
||||
Debug::log(LOG, "Found an invalid tiled window, ID: " + std::to_string(CHILDB->getDrawable()) + ", untiling it.");
|
||||
}
|
||||
|
||||
} else {
|
||||
Debug::log(ERR, "Malformed node ID " + std::to_string(w.getDrawable()) + " with 2 children but one or both are nullptr.");
|
||||
}
|
||||
}
|
||||
|
||||
// Check #3: Check if the window exists with xcb
|
||||
// Some windows do not report they are dead for w/e reason
|
||||
if (w.getDrawable() > 0) {
|
||||
const auto GEOMETRYCOOKIE = xcb_get_geometry(g_pWindowManager->DisplayConnection, w.getDrawable());
|
||||
const auto GEOMETRY = xcb_get_geometry_reply(g_pWindowManager->DisplayConnection, GEOMETRYCOOKIE, 0);
|
||||
|
||||
if (!GEOMETRY || (GEOMETRY->width < 1 || GEOMETRY->height < 1)) {
|
||||
Debug::log(LOG, "Found a dead window, ID: " + std::to_string(w.getDrawable()) + ", removing it.");
|
||||
|
||||
closeWindowAllChecks(w.getDrawable());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CWindow* CWindowManager::getWindowFromDrawable(int64_t window) {
|
||||
if (!window)
|
||||
return nullptr;
|
||||
|
||||
for(auto& w : windows) {
|
||||
if (w.getDrawable() == window) {
|
||||
return &w;
|
||||
|
@ -685,6 +710,17 @@ void CWindowManager::eatWindow(CWindow* a, CWindow* toEat) {
|
|||
a->setSize(Vector2D(std::max(OPPCORNERA.x, OPPCORNERB.x), std::max(OPPCORNERA.y, OPPCORNERB.y)) - a->getPosition());
|
||||
}
|
||||
|
||||
void CWindowManager::closeWindowAllChecks(int64_t id) {
|
||||
// fix last window if tile
|
||||
const auto CLOSEDWINDOW = g_pWindowManager->getWindowFromDrawable(id);
|
||||
if (CLOSEDWINDOW && !CLOSEDWINDOW->getIsFloating()) {
|
||||
g_pWindowManager->fixWindowOnClose(CLOSEDWINDOW);
|
||||
|
||||
// delete off of the arr
|
||||
g_pWindowManager->removeWindowFromVectorSafe(id);
|
||||
}
|
||||
}
|
||||
|
||||
void CWindowManager::fixWindowOnClose(CWindow* pClosedWindow) {
|
||||
if (!pClosedWindow)
|
||||
return;
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
|
||||
void calculateNewWindowParams(CWindow*);
|
||||
void fixWindowOnClose(CWindow*);
|
||||
void closeWindowAllChecks(int64_t);
|
||||
|
||||
void moveActiveWindowTo(char);
|
||||
void warpCursorTo(Vector2D);
|
||||
|
|
Loading…
Reference in a new issue