From 0ee0f3ff78bc560a047b951f790abb9b98aacbcd Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 24 Dec 2021 20:20:50 +0100 Subject: [PATCH] Fixed #25 --- src/events/events.cpp | 8 ++++++++ src/events/events.hpp | 3 +++ src/windowManager.cpp | 26 ++++++++++++++++++++++---- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/events/events.cpp b/src/events/events.cpp index 65eeec9..b4a1525 100644 --- a/src/events/events.cpp +++ b/src/events/events.cpp @@ -56,6 +56,11 @@ void Events::eventEnter(xcb_generic_event_t* event) { RETURNIFBAR; + if (E->mode != XCB_NOTIFY_MODE_NORMAL) + return; + + if (E->detail == XCB_NOTIFY_DETAIL_INFERIOR) + return; const auto PENTERWINDOW = g_pWindowManager->getWindowFromDrawable(E->event); @@ -551,6 +556,9 @@ CWindow* Events::remapWindow(int windowID, bool wasfloating, int forcemonitor) { void Events::eventMapWindow(xcb_generic_event_t* event) { const auto E = reinterpret_cast(event); + // Ignore sequence + ignoredEvents.push_back(E->sequence); + // let bar check if it wasnt a tray item if (g_pWindowManager->statusBar) g_pWindowManager->statusBar->ensureTrayClientHidden(E->window, false); diff --git a/src/events/events.hpp b/src/events/events.hpp index bf83aa8..99fc598 100644 --- a/src/events/events.hpp +++ b/src/events/events.hpp @@ -31,4 +31,7 @@ namespace Events { // For docks etc inline bool nextWindowCentered = false; + + // Fix focus on open + inline std::deque ignoredEvents; }; \ No newline at end of file diff --git a/src/windowManager.cpp b/src/windowManager.cpp index 95c3273..0bbf90e 100644 --- a/src/windowManager.cpp +++ b/src/windowManager.cpp @@ -243,6 +243,17 @@ void CWindowManager::recieveEvent() { ; // wait for it to finish } + for (auto& e : Events::ignoredEvents) { + if (e == ev->sequence) { + Debug::log(LOG, "Ignoring event type " + std::to_string(ev->response_type & ~0x80) + "."); + free(ev); + return; + } + } + + if (Events::ignoredEvents.size() > 20) + Events::ignoredEvents.pop_front(); + // Set thread state, halt animations until done. mainThreadBusy = true; @@ -434,8 +445,10 @@ void CWindowManager::refreshDirtyWindows() { Values[0] = (int)window.getRealPosition().x - ConfigManager::getInt("border_size"); Values[1] = (int)window.getRealPosition().y - ConfigManager::getInt("border_size"); if (VECTORDELTANONZERO(window.getLastUpdatePosition(), Vector2D(Values[0], Values[1]))) { - xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, Values); + const auto COOKIE = xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, Values); window.setLastUpdatePosition(Vector2D(Values[0], Values[1])); + + Events::ignoredEvents.push_back(COOKIE.sequence); } Values[0] = (int)ConfigManager::getInt("border_size"); @@ -450,8 +463,10 @@ void CWindowManager::refreshDirtyWindows() { Values[0] = (int)window.getRealSize().x; Values[1] = (int)window.getRealSize().y; if (VECTORDELTANONZERO(window.getLastUpdateSize(), Vector2D(Values[0], Values[1]))) { - xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, Values); + const auto COOKIE = xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, Values); window.setLastUpdateSize(Vector2D(Values[0], Values[1])); + + Events::ignoredEvents.push_back(COOKIE.sequence); } window.setFirstAnimFrame(true); } @@ -463,8 +478,10 @@ void CWindowManager::refreshDirtyWindows() { Values[0] = (int)window.getEffectiveSize().x; Values[1] = (int)window.getEffectiveSize().y; if (VECTORDELTANONZERO(window.getLastUpdateSize(), Vector2D(Values[0], Values[1]))) { - xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, Values); + const auto COOKIE = xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, Values); window.setLastUpdateSize(Vector2D(Values[0], Values[1])); + + Events::ignoredEvents.push_back(COOKIE.sequence); } } } @@ -1661,7 +1678,8 @@ void CWindowManager::setAllFloatingWindowsTop() { void CWindowManager::setAWindowTop(xcb_window_t window) { Values[0] = XCB_STACK_MODE_ABOVE; - xcb_configure_window(g_pWindowManager->DisplayConnection, window, XCB_CONFIG_WINDOW_STACK_MODE, Values); + const auto COOKIE = xcb_configure_window(g_pWindowManager->DisplayConnection, window, XCB_CONFIG_WINDOW_STACK_MODE, Values); + Events::ignoredEvents.push_back(COOKIE.sequence); } bool CWindowManager::shouldBeFloatedOnInit(int64_t window) {