summaryrefslogtreecommitdiff
path: root/src/desktop/Window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/desktop/Window.cpp')
-rw-r--r--src/desktop/Window.cpp64
1 files changed, 36 insertions, 28 deletions
diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp
index 891fd652..34ae857f 100644
--- a/src/desktop/Window.cpp
+++ b/src/desktop/Window.cpp
@@ -4,6 +4,7 @@
#include "../render/decorations/CHyprGroupBarDecoration.hpp"
#include "../render/decorations/CHyprBorderDecoration.hpp"
#include "../config/ConfigValue.hpp"
+#include <any>
CWindow::CWindow() {
m_vRealPosition.create(g_pConfigManager->getAnimationPropertyConfig("windowsIn"), this, AVARDAMAGE_ENTIRE);
@@ -377,43 +378,37 @@ void CWindow::updateSurfaceScaleTransformDetails() {
this);
}
-void CWindow::moveToWorkspace(int workspaceID) {
- if (m_iWorkspaceID == workspaceID)
+void CWindow::moveToWorkspace(PHLWORKSPACE pWorkspace) {
+ if (m_pWorkspace == pWorkspace)
return;
static auto PCLOSEONLASTSPECIAL = CConfigValue<Hyprlang::INT>("misc:close_special_on_empty");
- const int OLDWORKSPACE = m_iWorkspaceID;
+ const auto OLDWORKSPACE = m_pWorkspace;
- m_iWorkspaceID = workspaceID;
-
- const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_iWorkspaceID);
+ m_pWorkspace = pWorkspace;
setAnimationsToMove();
updateSpecialRenderData();
- if (PWORKSPACE) {
- g_pEventManager->postEvent(SHyprIPCEvent{"movewindow", std::format("{:x},{}", (uintptr_t)this, PWORKSPACE->m_szName)});
- g_pEventManager->postEvent(SHyprIPCEvent{"movewindowv2", std::format("{:x},{},{}", (uintptr_t)this, PWORKSPACE->m_iID, PWORKSPACE->m_szName)});
- EMIT_HOOK_EVENT("moveWindow", (std::vector<void*>{this, PWORKSPACE}));
+ if (valid(pWorkspace)) {
+ g_pEventManager->postEvent(SHyprIPCEvent{"movewindow", std::format("{:x},{}", (uintptr_t)this, pWorkspace->m_szName)});
+ g_pEventManager->postEvent(SHyprIPCEvent{"movewindowv2", std::format("{:x},{},{}", (uintptr_t)this, pWorkspace->m_iID, pWorkspace->m_szName)});
+ EMIT_HOOK_EVENT("moveWindow", (std::vector<std::any>{this, pWorkspace}));
}
if (m_pSwallowed) {
- m_pSwallowed->moveToWorkspace(workspaceID);
+ m_pSwallowed->moveToWorkspace(pWorkspace);
m_pSwallowed->m_iMonitorID = m_iMonitorID;
}
// update xwayland coords
g_pXWaylandManager->setWindowSize(this, m_vRealSize.value());
- if (g_pCompositor->isWorkspaceSpecial(OLDWORKSPACE) && g_pCompositor->getWindowsOnWorkspace(OLDWORKSPACE) == 0 && *PCLOSEONLASTSPECIAL) {
- const auto PWS = g_pCompositor->getWorkspaceByID(OLDWORKSPACE);
-
- if (PWS) {
- if (const auto PMONITOR = g_pCompositor->getMonitorFromID(PWS->m_iMonitorID); PMONITOR)
- PMONITOR->setSpecialWorkspace(nullptr);
- }
+ if (OLDWORKSPACE && g_pCompositor->isWorkspaceSpecial(OLDWORKSPACE->m_iID) && g_pCompositor->getWindowsOnWorkspace(OLDWORKSPACE->m_iID) == 0 && *PCLOSEONLASTSPECIAL) {
+ if (const auto PMONITOR = g_pCompositor->getMonitorFromID(OLDWORKSPACE->m_iMonitorID); PMONITOR)
+ PMONITOR->setSpecialWorkspace(nullptr);
}
}
@@ -455,6 +450,8 @@ void CWindow::onUnmap() {
if (g_pCompositor->m_pLastWindow == this)
g_pCompositor->m_pLastWindow = nullptr;
+ m_iLastWorkspace = onSpecialWorkspace();
+
m_vRealPosition.setCallbackOnEnd(unregisterVar);
m_vRealSize.setCallbackOnEnd(unregisterVar);
m_fBorderFadeAnimationProgress.setCallbackOnEnd(unregisterVar);
@@ -470,9 +467,9 @@ void CWindow::onUnmap() {
hyprListener_unmapWindow.removeCallback();
- if (*PCLOSEONLASTSPECIAL && g_pCompositor->getWindowsOnWorkspace(m_iWorkspaceID) == 0 && g_pCompositor->isWorkspaceSpecial(m_iWorkspaceID)) {
+ if (*PCLOSEONLASTSPECIAL && g_pCompositor->getWindowsOnWorkspace(workspaceID()) == 0 && onSpecialWorkspace()) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
- if (PMONITOR && PMONITOR->specialWorkspaceID == m_iWorkspaceID)
+ if (PMONITOR && PMONITOR->activeSpecialWorkspace && PMONITOR->activeSpecialWorkspace == m_pWorkspace)
PMONITOR->setSpecialWorkspace(nullptr);
}
@@ -481,13 +478,14 @@ void CWindow::onUnmap() {
if (PMONITOR && PMONITOR->solitaryClient == this)
PMONITOR->solitaryClient = nullptr;
- g_pCompositor->updateWorkspaceWindows(m_iWorkspaceID);
+ g_pCompositor->updateWorkspaceWindows(workspaceID());
if (m_bIsX11)
return;
m_pSubsurfaceHead.reset();
m_pPopupHead.reset();
+ m_pWorkspace.reset();
}
void CWindow::onMap() {
@@ -943,7 +941,7 @@ void CWindow::setGroupCurrent(CWindow* pWindow) {
const auto PCURRENT = getGroupCurrent();
const bool FULLSCREEN = PCURRENT->m_bIsFullscreen;
- const auto WORKSPACE = g_pCompositor->getWorkspaceByID(PCURRENT->m_iWorkspaceID);
+ const auto WORKSPACE = PCURRENT->m_pWorkspace;
const auto PWINDOWSIZE = PCURRENT->m_vRealSize.goal();
const auto PWINDOWPOS = PCURRENT->m_vRealPosition.goal();
@@ -1034,11 +1032,13 @@ void CWindow::updateGroupOutputs() {
if (!m_sGroupData.pNextWindow)
return;
- CWindow* curr = m_sGroupData.pNextWindow;
+ CWindow* curr = m_sGroupData.pNextWindow;
+
+ const auto WS = m_pWorkspace;
while (curr != this) {
curr->m_iMonitorID = m_iMonitorID;
- curr->moveToWorkspace(m_iWorkspaceID);
+ curr->moveToWorkspace(WS);
curr->m_vRealPosition = m_vRealPosition.goal();
curr->m_vRealSize = m_vRealSize.goal();
@@ -1058,7 +1058,7 @@ bool CWindow::opaque() {
if (m_vRealSize.goal().floor() != m_vReportedSize)
return false;
- const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_iWorkspaceID);
+ const auto PWORKSPACE = m_pWorkspace;
if (m_pWLSurface.small() && !m_pWLSurface.m_bFillIgnoreSmall)
return false;
@@ -1088,7 +1088,7 @@ float CWindow::rounding() {
}
void CWindow::updateSpecialRenderData() {
- const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_iWorkspaceID);
+ const auto PWORKSPACE = m_pWorkspace;
const auto WORKSPACERULES = PWORKSPACE ? g_pConfigManager->getWorkspaceRulesFor(PWORKSPACE) : std::vector<SWorkspaceRule>{};
bool border = true;
@@ -1137,7 +1137,7 @@ bool CWindow::canBeTorn() {
}
bool CWindow::shouldSendFullscreenState() {
- const auto MODE = g_pCompositor->getWorkspaceByID(m_iWorkspaceID)->m_efFullscreenMode;
+ const auto MODE = m_pWorkspace->m_efFullscreenMode;
return m_bDontSendFullscreen ? false : (m_bFakeFullscreenState || (m_bIsFullscreen && (MODE == FULLSCREEN_FULL)));
}
@@ -1173,7 +1173,7 @@ void CWindow::onWorkspaceAnimUpdate() {
}
Vector2D offset;
- const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_iWorkspaceID);
+ const auto PWORKSPACE = m_pWorkspace;
if (!PWORKSPACE)
return;
@@ -1212,3 +1212,11 @@ int CWindow::popupsCount() {
m_uSurface.xdg, [](wlr_surface* s, int x, int y, void* data) { *(int*)data += 1; }, &no);
return no;
}
+
+int CWindow::workspaceID() {
+ return m_pWorkspace ? m_pWorkspace->m_iID : m_iLastWorkspace;
+}
+
+bool CWindow::onSpecialWorkspace() {
+ return m_pWorkspace ? m_pWorkspace->m_bIsSpecialWorkspace : g_pCompositor->isWorkspaceSpecial(m_iLastWorkspace);
+}