mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-08 20:46:00 +01:00
sanity check on last window
This commit is contained in:
parent
1d4d2f4793
commit
bb90ff0461
3 changed files with 13 additions and 4 deletions
|
@ -119,4 +119,11 @@ void CWorkspace::moveToMonitor(const int& id) {
|
||||||
wlr_ext_workspace_handle_v1_set_urgent(m_pWlrHandle, false);
|
wlr_ext_workspace_handle_v1_set_urgent(m_pWlrHandle, false);
|
||||||
|
|
||||||
wlr_ext_workspace_handle_v1_set_name(m_pWlrHandle, m_szName.c_str());
|
wlr_ext_workspace_handle_v1_set_name(m_pWlrHandle, m_szName.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CWindow* CWorkspace::getLastFocusedWindow() {
|
||||||
|
if (!g_pCompositor->windowValidMapped(m_pLastFocusedWindow) || m_pLastFocusedWindow->m_iWorkspaceID != m_iID)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
return m_pLastFocusedWindow;
|
||||||
|
}
|
||||||
|
|
|
@ -49,4 +49,6 @@ public:
|
||||||
void setActive(bool on);
|
void setActive(bool on);
|
||||||
|
|
||||||
void moveToMonitor(const int&);
|
void moveToMonitor(const int&);
|
||||||
|
|
||||||
|
CWindow* getLastFocusedWindow();
|
||||||
};
|
};
|
|
@ -652,7 +652,7 @@ void CKeybindManager::changeworkspace(std::string args) {
|
||||||
Debug::log(LOG, "Changed to workspace %i", workspaceToChangeTo);
|
Debug::log(LOG, "Changed to workspace %i", workspaceToChangeTo);
|
||||||
|
|
||||||
// focus
|
// focus
|
||||||
if (const auto PWINDOW = PWORKSPACETOCHANGETO->m_pLastFocusedWindow; g_pCompositor->windowValidMapped(PWINDOW)) {
|
if (const auto PWINDOW = PWORKSPACETOCHANGETO->getLastFocusedWindow(); PWINDOW) {
|
||||||
// warp and focus
|
// warp and focus
|
||||||
if (anotherMonitor)
|
if (anotherMonitor)
|
||||||
g_pCompositor->warpCursorTo(PWINDOW->m_vRealPosition.vec() + PWINDOW->m_vRealSize.vec() / 2.f);
|
g_pCompositor->warpCursorTo(PWINDOW->m_vRealPosition.vec() + PWINDOW->m_vRealSize.vec() / 2.f);
|
||||||
|
@ -1242,7 +1242,7 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const auto PWINDOW = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace)->m_pLastFocusedWindow; g_pCompositor->windowValidMapped(PWINDOW) && PWINDOW->m_iMonitorID == monID)
|
if (const auto PWINDOW = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace)->getLastFocusedWindow(); g_pCompositor->windowValidMapped(PWINDOW))
|
||||||
g_pCompositor->focusWindow(PWINDOW);
|
g_pCompositor->focusWindow(PWINDOW);
|
||||||
else
|
else
|
||||||
g_pInputManager->refocus();
|
g_pInputManager->refocus();
|
||||||
|
@ -1260,7 +1260,7 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) {
|
||||||
PSPECIALWORKSPACE->startAnim(true, true);
|
PSPECIALWORKSPACE->startAnim(true, true);
|
||||||
PSPECIALWORKSPACE->m_iMonitorID = g_pCompositor->m_pLastMonitor->ID;
|
PSPECIALWORKSPACE->m_iMonitorID = g_pCompositor->m_pLastMonitor->ID;
|
||||||
|
|
||||||
if (const auto PWINDOW = PSPECIALWORKSPACE->m_pLastFocusedWindow; g_pCompositor->windowValidMapped(PWINDOW))
|
if (const auto PWINDOW = PSPECIALWORKSPACE->getLastFocusedWindow(); g_pCompositor->windowValidMapped(PWINDOW))
|
||||||
g_pCompositor->focusWindow(PWINDOW);
|
g_pCompositor->focusWindow(PWINDOW);
|
||||||
else
|
else
|
||||||
g_pInputManager->refocus();
|
g_pInputManager->refocus();
|
||||||
|
|
Loading…
Reference in a new issue