diff --git a/src/events/events.cpp b/src/events/events.cpp index 2751d10..b3eb18c 100644 --- a/src/events/events.cpp +++ b/src/events/events.cpp @@ -4,18 +4,18 @@ gpointer handle(gpointer data) { int lazyUpdateCounter = 0; while (1) { + // update animations. They should be thread-safe. + AnimationUtil::move(); + // + // wait for the main thread to be idle while (g_pWindowManager->mainThreadBusy) { - ; + std::this_thread::sleep_for(std::chrono::microseconds(1)); } // set state to let the main thread know to wait. g_pWindowManager->animationUtilBusy = true; - // update animations. - AnimationUtil::move(); - // - // Don't spam these if (lazyUpdateCounter > 10){ // Update the active window name diff --git a/src/windowManager.cpp b/src/windowManager.cpp index 2412b04..fe8a332 100644 --- a/src/windowManager.cpp +++ b/src/windowManager.cpp @@ -432,15 +432,15 @@ void CWindowManager::setFocusedWindow(xcb_drawable_t window) { } float values[1]; - if (g_pWindowManager->getWindowFromDrawable(window)) { - if (g_pWindowManager->getWindowFromDrawable(window)->getIsFloating()) { + if (const auto PWINDOW = g_pWindowManager->getWindowFromDrawable(window); PWINDOW) { + if (PWINDOW->getIsFloating()) { values[0] = XCB_STACK_MODE_ABOVE; xcb_configure_window(g_pWindowManager->DisplayConnection, window, XCB_CONFIG_WINDOW_STACK_MODE, values); } // Apply rounded corners, does all the checks inside. // The border changed so let's not make it rectangular maybe - applyShapeToWindow(g_pWindowManager->getWindowFromDrawable(window)); + applyShapeToWindow(PWINDOW); } LastWindow = window; @@ -1478,17 +1478,13 @@ void CWindowManager::updateBarInfo() { for (auto& c : winname) { // Remove illegal chars - if (c == '=') - c = ' '; - else if (c == '\t') + if (c == '=' || c == '\t') c = ' '; } for (auto& c : winclassname) { // Remove illegal chars - if (c == '=') - c = ' '; - else if (c == '\t') + if (c == '=' || c == '\t') c = ' '; } diff --git a/src/windowManager.hpp b/src/windowManager.hpp index f21d300..7c1045a 100644 --- a/src/windowManager.hpp +++ b/src/windowManager.hpp @@ -56,8 +56,8 @@ public: std::vector trayclients; - std::atomic mainThreadBusy = false; - std::atomic animationUtilBusy = false; + bool mainThreadBusy = false; + bool animationUtilBusy = false; xcb_cursor_t pointerCursor; xcb_cursor_context_t* pointerContext;