move ignore to eventmanager and fix double focus in changeworkspace

This commit is contained in:
vaxerski 2022-06-21 22:17:30 +02:00
parent ff49f22440
commit 4a3f9ccba2
4 changed files with 12 additions and 12 deletions

View file

@ -105,6 +105,12 @@ void CEventManager::startThread() {
} }
void CEventManager::postEvent(const SHyprIPCEvent event) { void CEventManager::postEvent(const SHyprIPCEvent event) {
if (m_bIgnoreEvents) {
Debug::log(WARN, "Suppressed (ignoreevents true) event of type %s, content: %s");
return;
}
std::thread([&](const SHyprIPCEvent ev) { std::thread([&](const SHyprIPCEvent ev) {
eventQueueMutex.lock(); eventQueueMutex.lock();
m_dQueuedEvents.push_back(ev); m_dQueuedEvents.push_back(ev);

View file

@ -19,6 +19,8 @@ public:
void startThread(); void startThread();
bool m_bIgnoreEvents = false;
private: private:
std::mutex eventQueueMutex; std::mutex eventQueueMutex;

View file

@ -280,8 +280,6 @@ void CKeybindManager::changeworkspace(std::string args) {
// start anim on new workspace // start anim on new workspace
PWORKSPACETOCHANGETO->startAnim(true, ANIMTOLEFT); PWORKSPACETOCHANGETO->startAnim(true, ANIMTOLEFT);
// Event ONLY if workspace is actually "changed" and we arent just focusing
if (!m_bSuppressWorkspaceChangeEvents)
g_pEventManager->postEvent(SHyprIPCEvent("workspace", PWORKSPACETOCHANGETO->m_szName)); g_pEventManager->postEvent(SHyprIPCEvent("workspace", PWORKSPACETOCHANGETO->m_szName));
} }
@ -291,9 +289,6 @@ void CKeybindManager::changeworkspace(std::string args) {
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, middle.x, middle.y); wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, middle.x, middle.y);
} }
// focus the first window
g_pCompositor->focusWindow(g_pCompositor->getFirstWindowOnWorkspace(workspaceToChangeTo));
// set active and deactivate all other in wlr // set active and deactivate all other in wlr
g_pCompositor->deactivateAllWLRWorkspaces(PWORKSPACETOCHANGETO->m_pWlrHandle); g_pCompositor->deactivateAllWLRWorkspaces(PWORKSPACETOCHANGETO->m_pWlrHandle);
PWORKSPACETOCHANGETO->setActive(true); PWORKSPACETOCHANGETO->setActive(true);
@ -360,7 +355,6 @@ void CKeybindManager::changeworkspace(std::string args) {
g_pInputManager->refocus(); g_pInputManager->refocus();
// Event // Event
if (!m_bSuppressWorkspaceChangeEvents)
g_pEventManager->postEvent(SHyprIPCEvent("workspace", PWORKSPACE->m_szName)); g_pEventManager->postEvent(SHyprIPCEvent("workspace", PWORKSPACE->m_szName));
Debug::log(LOG, "Changed to workspace %i", workspaceToChangeTo); Debug::log(LOG, "Changed to workspace %i", workspaceToChangeTo);
@ -491,7 +485,7 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
const auto POLDWORKSPACEONMON = g_pCompositor->getWorkspaceByID(OLDWORKSPACEIDONMONITOR); const auto POLDWORKSPACEONMON = g_pCompositor->getWorkspaceByID(OLDWORKSPACEIDONMONITOR);
const auto POLDWORKSPACEIDRETURN = g_pCompositor->getWorkspaceByID(OLDWORKSPACEIDRETURN); const auto POLDWORKSPACEIDRETURN = g_pCompositor->getWorkspaceByID(OLDWORKSPACEIDRETURN);
m_bSuppressWorkspaceChangeEvents = true; g_pEventManager->m_bIgnoreEvents = true;
moveActiveToWorkspace(args); moveActiveToWorkspace(args);
@ -510,7 +504,7 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
POLDWORKSPACEONMON->m_vRenderOffset.setValueAndWarp(Vector2D(0, 0)); POLDWORKSPACEONMON->m_vRenderOffset.setValueAndWarp(Vector2D(0, 0));
POLDWORKSPACEONMON->m_fAlpha.setValueAndWarp(255.f); POLDWORKSPACEONMON->m_fAlpha.setValueAndWarp(255.f);
m_bSuppressWorkspaceChangeEvents = false; g_pEventManager->m_bIgnoreEvents = false;
g_pInputManager->refocus(); g_pInputManager->refocus();
} }

View file

@ -30,8 +30,6 @@ private:
bool handleInternalKeybinds(xkb_keysym_t); bool handleInternalKeybinds(xkb_keysym_t);
inline static bool m_bSuppressWorkspaceChangeEvents = false;
// -------------- Dispatchers -------------- // // -------------- Dispatchers -------------- //
static void killActive(std::string); static void killActive(std::string);
static void spawn(std::string); static void spawn(std::string);