tick hyprctl separately

This commit is contained in:
vaxerski 2022-07-31 00:27:32 +02:00
parent 4610b3d864
commit edac94bed1
5 changed files with 24 additions and 13 deletions

View file

@ -1,6 +1,7 @@
#include "Compositor.hpp" #include "Compositor.hpp"
#include "helpers/Splashes.hpp" #include "helpers/Splashes.hpp"
#include <random> #include <random>
#include "debug/HyprCtl.hpp"
int handleCritSignal(int signo, void* data) { int handleCritSignal(int signo, void* data) {
Debug::log(LOG, "Hyprland received signal %d", signo); Debug::log(LOG, "Hyprland received signal %d", signo);
@ -1477,4 +1478,21 @@ CWindow* CCompositor::getWindowByRegex(const std::string& regexp) {
} }
return nullptr; return nullptr;
}
wl_event_source* hyprCtlTickSource = nullptr;
int hyprCtlTick(void* data) {
HyprCtl::tickHyprCtl(); // so that we dont get that race condition multithread bullshit
wl_event_source_timer_update(hyprCtlTickSource, 16); // tick it 60/s, should be enough.
}
void CCompositor::startHyprCtlTick() {
if (hyprCtlTickSource)
return;
hyprCtlTickSource = wl_event_loop_add_timer(m_sWLEventLoop, hyprCtlTick, nullptr);
wl_event_source_timer_update(hyprCtlTickSource, 16);
} }

View file

@ -154,9 +154,11 @@ public:
std::string explicitConfigPath; std::string explicitConfigPath;
void startHyprCtlTick();
private: private:
void initAllSignals(); void initAllSignals();
void setRandomSplash(); void setRandomSplash();
}; };

View file

@ -592,16 +592,7 @@ void HyprCtl::tickHyprCtl() {
} }
std::string getRequestFromThread(std::string rq) { std::string getRequestFromThread(std::string rq) {
// we need to do something to wake hyprland up if VFR is enabled
static auto *const PNOVFR = &g_pConfigManager->getConfigValuePtr("misc:no_vfr")->intValue;
// TODO: is this safe...?
// this might be a race condition
// tested with 2 instances of `watch -n 0.1 hyprctl splash` and seems to not crash so I'll take that as a yes
if (!*PNOVFR)
g_pCompositor->scheduleFrameForMonitor(g_pCompositor->m_vMonitors.front().get());
while (HyprCtl::request != "" || HyprCtl::requestMade || HyprCtl::requestReady) { while (HyprCtl::request != "" || HyprCtl::requestMade || HyprCtl::requestReady) {
std::this_thread::sleep_for(std::chrono::milliseconds(5)); std::this_thread::sleep_for(std::chrono::milliseconds(5));
} }

View file

@ -120,8 +120,6 @@ void Events::listener_monitorFrame(void* owner, void* data) {
g_pCompositor->sanityCheckWorkspaces(); g_pCompositor->sanityCheckWorkspaces();
g_pAnimationManager->tick(); g_pAnimationManager->tick();
HyprCtl::tickHyprCtl(); // so that we dont get that race condition multithread bullshit
g_pConfigManager->dispatchExecOnce(); // We exec-once when at least one monitor starts refreshing, meaning stuff has init'd g_pConfigManager->dispatchExecOnce(); // We exec-once when at least one monitor starts refreshing, meaning stuff has init'd
if (g_pConfigManager->m_bWantsMonitorReload) if (g_pConfigManager->m_bWantsMonitorReload)

View file

@ -19,6 +19,8 @@ CThreadManager::CThreadManager() {
HyprCtl::startHyprCtlSocket(); HyprCtl::startHyprCtlSocket();
g_pCompositor->startHyprCtlTick();
m_esConfigTimer = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, handleTimer, this); m_esConfigTimer = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, handleTimer, this);
wl_event_source_timer_update(m_esConfigTimer, 1000); wl_event_source_timer_update(m_esConfigTimer, 1000);