From 844c33c9801177adf65ea7ed163a8a6df36a9a37 Mon Sep 17 00:00:00 2001 From: Darksome Date: Thu, 18 Aug 2022 22:23:28 +0300 Subject: [PATCH] Add mapwindow, unmapwindow and movewindow IPC events --- src/events/Windows.cpp | 3 +++ src/layout/IHyprLayout.cpp | 10 +++++++++- src/managers/KeybindManager.cpp | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 660b08a2..ba2a5942 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -295,6 +295,8 @@ void Events::listener_mapWindow(void* owner, void* data) { const auto TIMER = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, setAnimToMove, PWINDOW); wl_event_source_timer_update(TIMER, PWINDOW->m_vRealPosition.getDurationLeftMs() + 5); + g_pEventManager->postEvent(SHyprIPCEvent{"mapwindow", getFormat("%x,%s,%s,%s", PWINDOW, PWORKSPACE->m_szName.c_str(), g_pXWaylandManager->getAppIDClass(PWINDOW).c_str(), PWINDOW->m_szTitle.c_str())}); + if (workspaceSilent) { // move the window if (g_pCompositor->m_pLastWindow == PWINDOW) { @@ -335,6 +337,7 @@ void Events::listener_unmapWindow(void* owner, void* data) { CWindow* PWINDOW = (CWindow*)owner; Debug::log(LOG, "Window %x unmapped (class %s)", PWINDOW, g_pXWaylandManager->getAppIDClass(PWINDOW).c_str()); + g_pEventManager->postEvent(SHyprIPCEvent{"unmapwindow", getFormat("%x", PWINDOW)}); if (!PWINDOW->m_bIsX11) { Debug::log(LOG, "Unregistered late callbacks XDG"); diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index 4a3f1800..173668bc 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -206,8 +206,16 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) { if (PMONITOR) { DRAGGINGWINDOW->m_iMonitorID = PMONITOR->ID; - DRAGGINGWINDOW->m_iWorkspaceID = PMONITOR->activeWorkspace; + + if (DRAGGINGWINDOW->m_iWorkspaceID != PMONITOR->activeWorkspace) { + DRAGGINGWINDOW->m_iWorkspaceID = PMONITOR->activeWorkspace; + auto PWORKSPACE = g_pCompositor->getWorkspaceByID(DRAGGINGWINDOW->m_iWorkspaceID); + if (PWORKSPACE) { + g_pEventManager->postEvent(SHyprIPCEvent{"movewindow", getFormat("%x,%s", DRAGGINGWINDOW, PWORKSPACE->m_szName.c_str())}); + } + } + DRAGGINGWINDOW->updateToplevel(); } diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 9939993a..c17886ff 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -670,6 +670,8 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) { g_pInputManager->refocus(); PWINDOW->updateToplevel(); + + g_pEventManager->postEvent(SHyprIPCEvent{"movewindow", getFormat("%x,%s", PWINDOW, PWORKSPACE->m_szName.c_str())}); } void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {