Skip to content

Commit

Permalink
ipc: togglegroup, moveintogroup and moveoutofgroup events implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
VPavliashvili committed May 5, 2024
1 parent cddeec4 commit 104b700
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/desktop/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,8 @@ void CWindow::createGroup() {
g_pCompositor->updateWorkspaceSpecialRenderData(workspaceID());
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_iMonitorID);
g_pCompositor->updateAllWindowsAnimatedDecorationValues();

g_pEventManager->postEvent(SHyprIPCEvent{"togglegroup", std::format("1,{:x}", (uintptr_t)this)});
}
}

Expand All @@ -852,9 +854,12 @@ void CWindow::destroyGroup() {
g_pCompositor->updateWorkspaceSpecialRenderData(workspaceID());
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_iMonitorID);
g_pCompositor->updateAllWindowsAnimatedDecorationValues();

g_pEventManager->postEvent(SHyprIPCEvent{"togglegroup", std::format("0,{:x}", (uintptr_t)this)});
return;
}

std::string addresses;
PHLWINDOW curr = m_pSelf.lock();
std::vector<PHLWINDOW> members;
do {
Expand All @@ -863,6 +868,8 @@ void CWindow::destroyGroup() {
PLASTWIN->m_sGroupData.pNextWindow.reset();
curr->setHidden(false);
members.push_back(curr);

addresses += std::format("{:x},", (uintptr_t)curr.get());
} while (curr.get() != this);

for (auto& w : members) {
Expand All @@ -883,6 +890,10 @@ void CWindow::destroyGroup() {
g_pCompositor->updateWorkspaceSpecialRenderData(workspaceID());
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_iMonitorID);
g_pCompositor->updateAllWindowsAnimatedDecorationValues();

if (!addresses.empty())
addresses.pop_back();
g_pEventManager->postEvent(SHyprIPCEvent{"togglegroup", std::format("0,{}", addresses)});
}

PHLWINDOW CWindow::getGroupHead() {
Expand Down
4 changes: 4 additions & 0 deletions src/managers/KeybindManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2238,6 +2238,8 @@ void CKeybindManager::moveWindowIntoGroup(PHLWINDOW pWindow, PHLWINDOW pWindowIn

if (!pWindow->getDecorationByType(DECORATION_GROUPBAR))
pWindow->addWindowDeco(std::make_unique<CHyprGroupBarDecoration>(pWindow));

g_pEventManager->postEvent(SHyprIPCEvent{"moveintogroup", std::format("{:x}", (uintptr_t)pWindow.get())});
}

void CKeybindManager::moveWindowOutOfGroup(PHLWINDOW pWindow, const std::string& dir) {
Expand Down Expand Up @@ -2275,6 +2277,8 @@ void CKeybindManager::moveWindowOutOfGroup(PHLWINDOW pWindow, const std::string&
g_pCompositor->focusWindow(PWINDOWPREV);
g_pCompositor->warpCursorTo(PWINDOWPREV->middle());
}

g_pEventManager->postEvent(SHyprIPCEvent{"moveoutofgroup", std::format("{:x}", (uintptr_t)pWindow.get())});
}

void CKeybindManager::moveIntoGroup(std::string args) {
Expand Down

0 comments on commit 104b700

Please sign in to comment.