mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-24 08:05:59 +01:00
Added m_pSwallowedBy symmetric reference to avoid dangling m_pSwallowed pointer
This commit is contained in:
parent
d48468d59c
commit
5a520914ac
3 changed files with 17 additions and 7 deletions
|
@ -342,6 +342,7 @@ class CWindow {
|
|||
// swallowing
|
||||
CWindow* m_pSwallowed = nullptr;
|
||||
CWindow* m_pPreviouslySwallowed = nullptr;
|
||||
CWindow* m_pSwallowedBy = nullptr;
|
||||
|
||||
// focus stuff
|
||||
bool m_bStayFocused = false;
|
||||
|
|
|
@ -584,6 +584,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
|||
if (valid) {
|
||||
// swallow
|
||||
PWINDOW->m_pSwallowed = finalFound;
|
||||
finalFound->m_pSwallowedBy = PWINDOW;
|
||||
|
||||
g_pLayoutManager->getCurrentLayout()->onWindowRemoved(finalFound);
|
||||
|
||||
|
@ -687,11 +688,17 @@ void Events::listener_unmapWindow(void* owner, void* data) {
|
|||
g_pHyprOpenGL->makeWindowSnapshot(PWINDOW);
|
||||
|
||||
// swallowing
|
||||
if (PWINDOW->m_pSwallowed && g_pCompositor->windowExists(PWINDOW->m_pSwallowed)) {
|
||||
if (PWINDOW->m_pSwallowed) {
|
||||
PWINDOW->m_pSwallowed->setHidden(false);
|
||||
g_pLayoutManager->getCurrentLayout()->onWindowCreated(PWINDOW->m_pSwallowed);
|
||||
PWINDOW->m_pSwallowed->m_pSwallowedBy = nullptr;
|
||||
PWINDOW->m_pSwallowed = nullptr;
|
||||
}
|
||||
// swallowed
|
||||
if (PWINDOW->m_pSwallowedBy) {
|
||||
PWINDOW->m_pSwallowedBy->m_pSwallowed = nullptr;
|
||||
PWINDOW->m_pSwallowedBy = nullptr;
|
||||
}
|
||||
|
||||
bool wasLastWindow = false;
|
||||
|
||||
|
|
|
@ -1823,17 +1823,19 @@ void CKeybindManager::focusWindow(std::string regexp) {
|
|||
|
||||
void CKeybindManager::toggleSwallow(std::string args) {
|
||||
CWindow* pWindow = g_pCompositor->m_pLastWindow;
|
||||
if (pWindow->m_pSwallowed && g_pCompositor->windowExists(pWindow->m_pSwallowed)) {
|
||||
if (pWindow->m_pSwallowed) {
|
||||
pWindow->m_pPreviouslySwallowed = pWindow->m_pSwallowed;
|
||||
|
||||
pWindow->m_pSwallowed->setHidden(false);
|
||||
|
||||
g_pLayoutManager->getCurrentLayout()->onWindowCreated(pWindow->m_pSwallowed);
|
||||
|
||||
pWindow->m_pSwallowed->m_pSwallowedBy = nullptr;
|
||||
pWindow->m_pSwallowed = nullptr;
|
||||
|
||||
} else if (pWindow->m_pPreviouslySwallowed && g_pCompositor->windowExists(pWindow->m_pPreviouslySwallowed)) {
|
||||
} else if (pWindow->m_pPreviouslySwallowed) {
|
||||
pWindow->m_pSwallowed = pWindow->m_pPreviouslySwallowed;
|
||||
pWindow->m_pSwallowed->m_pSwallowedBy = pWindow;
|
||||
|
||||
g_pLayoutManager->getCurrentLayout()->onWindowRemoved(pWindow->m_pPreviouslySwallowed);
|
||||
|
||||
|
|
Loading…
Reference in a new issue