mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-23 05:09:49 +01:00
socket2: added "activespecial" IPC event (#3163)
This commit is contained in:
parent
32f75ebb70
commit
6a0e2bbff3
2 changed files with 19 additions and 31 deletions
|
@ -572,8 +572,10 @@ void CMonitor::setSpecialWorkspace(CWorkspace* const pWorkspace) {
|
||||||
|
|
||||||
if (!pWorkspace) {
|
if (!pWorkspace) {
|
||||||
// remove special if exists
|
// remove special if exists
|
||||||
if (const auto EXISTINGSPECIAL = g_pCompositor->getWorkspaceByID(specialWorkspaceID); EXISTINGSPECIAL)
|
if (const auto EXISTINGSPECIAL = g_pCompositor->getWorkspaceByID(specialWorkspaceID); EXISTINGSPECIAL) {
|
||||||
EXISTINGSPECIAL->startAnim(false, false);
|
EXISTINGSPECIAL->startAnim(false, false);
|
||||||
|
g_pEventManager->postEvent(SHyprIPCEvent{"activespecial", "," + szName});
|
||||||
|
}
|
||||||
specialWorkspaceID = 0;
|
specialWorkspaceID = 0;
|
||||||
|
|
||||||
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID);
|
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID);
|
||||||
|
@ -592,10 +594,21 @@ void CMonitor::setSpecialWorkspace(CWorkspace* const pWorkspace) {
|
||||||
EXISTINGSPECIAL->startAnim(false, false);
|
EXISTINGSPECIAL->startAnim(false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool animate = true;
|
||||||
|
//close if open elsewhere
|
||||||
|
const auto PMONITORWORKSPACEOWNER = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID);
|
||||||
|
if (PMONITORWORKSPACEOWNER->specialWorkspaceID == pWorkspace->m_iID) {
|
||||||
|
PMONITORWORKSPACEOWNER->specialWorkspaceID = 0;
|
||||||
|
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITORWORKSPACEOWNER->ID);
|
||||||
|
g_pEventManager->postEvent(SHyprIPCEvent{"activespecial", "," + PMONITORWORKSPACEOWNER->szName});
|
||||||
|
animate = false;
|
||||||
|
}
|
||||||
|
|
||||||
// open special
|
// open special
|
||||||
pWorkspace->m_iMonitorID = ID;
|
pWorkspace->m_iMonitorID = ID;
|
||||||
specialWorkspaceID = pWorkspace->m_iID;
|
specialWorkspaceID = pWorkspace->m_iID;
|
||||||
pWorkspace->startAnim(true, true);
|
if (animate)
|
||||||
|
pWorkspace->startAnim(true, true);
|
||||||
|
|
||||||
for (auto& w : g_pCompositor->m_vWindows) {
|
for (auto& w : g_pCompositor->m_vWindows) {
|
||||||
if (w->m_iWorkspaceID == pWorkspace->m_iID) {
|
if (w->m_iWorkspaceID == pWorkspace->m_iID) {
|
||||||
|
@ -610,6 +623,8 @@ void CMonitor::setSpecialWorkspace(CWorkspace* const pWorkspace) {
|
||||||
g_pCompositor->focusWindow(PLAST);
|
g_pCompositor->focusWindow(PLAST);
|
||||||
else
|
else
|
||||||
g_pInputManager->refocus();
|
g_pInputManager->refocus();
|
||||||
|
|
||||||
|
g_pEventManager->postEvent(SHyprIPCEvent{"activespecial", pWorkspace->m_szName + "," + szName});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMonitor::setSpecialWorkspace(const int& id) {
|
void CMonitor::setSpecialWorkspace(const int& id) {
|
||||||
|
|
|
@ -1515,39 +1515,12 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requestedWorkspaceIsAlreadyOpen && specialOpenOnMonitor == workspaceID)
|
|
||||||
Debug::log(LOG, "Toggling special workspace %d to closed", workspaceID);
|
|
||||||
else
|
|
||||||
Debug::log(LOG, "Toggling special workspace %d to open", workspaceID);
|
|
||||||
|
|
||||||
if (requestedWorkspaceIsAlreadyOpen && specialOpenOnMonitor == workspaceID) {
|
if (requestedWorkspaceIsAlreadyOpen && specialOpenOnMonitor == workspaceID) {
|
||||||
// already open on this monitor
|
// already open on this monitor
|
||||||
|
Debug::log(LOG, "Toggling special workspace %d to closed", workspaceID);
|
||||||
PMONITOR->setSpecialWorkspace(nullptr);
|
PMONITOR->setSpecialWorkspace(nullptr);
|
||||||
} else if (requestedWorkspaceIsAlreadyOpen) {
|
|
||||||
// already open on another monitor
|
|
||||||
|
|
||||||
if (specialOpenOnMonitor) {
|
|
||||||
g_pCompositor->getWorkspaceByID(PMONITOR->specialWorkspaceID)->startAnim(false, false);
|
|
||||||
PMONITOR->specialWorkspaceID = 0;
|
|
||||||
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITOR->ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
// move to current
|
|
||||||
const auto PSPECIALWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceID);
|
|
||||||
const auto POLDMON = g_pCompositor->getMonitorFromID(PSPECIALWORKSPACE->m_iMonitorID);
|
|
||||||
|
|
||||||
POLDMON->specialWorkspaceID = 0;
|
|
||||||
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(POLDMON->ID);
|
|
||||||
PMONITOR->specialWorkspaceID = workspaceID;
|
|
||||||
PSPECIALWORKSPACE->m_iMonitorID = PMONITOR->ID;
|
|
||||||
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITOR->ID);
|
|
||||||
|
|
||||||
if (const auto PWINDOW = PSPECIALWORKSPACE->getLastFocusedWindow(); PWINDOW)
|
|
||||||
g_pCompositor->focusWindow(PWINDOW);
|
|
||||||
else
|
|
||||||
g_pInputManager->refocus();
|
|
||||||
} else {
|
} else {
|
||||||
// not open anywhere
|
Debug::log(LOG, "Toggling special workspace %d to open", workspaceID);
|
||||||
auto PSPECIALWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceID);
|
auto PSPECIALWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceID);
|
||||||
|
|
||||||
if (!PSPECIALWORKSPACE)
|
if (!PSPECIALWORKSPACE)
|
||||||
|
|
Loading…
Reference in a new issue