mirror of
https://github.com/hyprwm/hyprpaper.git
synced 2024-11-16 22:25:59 +01:00
stop polling in main thread
This commit is contained in:
parent
707ae57d44
commit
1f55dda5e2
2 changed files with 5 additions and 21 deletions
|
@ -25,28 +25,10 @@ void CHyprpaper::init() {
|
||||||
wl_registry *registry = wl_display_get_registry(m_sDisplay);
|
wl_registry *registry = wl_display_get_registry(m_sDisplay);
|
||||||
wl_registry_add_listener(registry, &Events::registryListener, nullptr);
|
wl_registry_add_listener(registry, &Events::registryListener, nullptr);
|
||||||
|
|
||||||
if (m_bIPCEnabled) {
|
|
||||||
std::thread([&]() { // we dispatch wl events cuz we have to
|
|
||||||
while (wl_display_dispatch(m_sDisplay) != -1) {
|
while (wl_display_dispatch(m_sDisplay) != -1) {
|
||||||
tick(true);
|
tick(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bShouldExit = true;
|
|
||||||
}).detach();
|
|
||||||
|
|
||||||
while (true) { // we also tick every 1ms for socket and other shit's updates
|
|
||||||
tick(false);
|
|
||||||
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
|
||||||
|
|
||||||
if (m_bShouldExit)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
while (wl_display_dispatch(m_sDisplay) != -1) {
|
|
||||||
tick(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprpaper::tick(bool force) {
|
void CHyprpaper::tick(bool force) {
|
||||||
|
|
|
@ -65,6 +65,8 @@ void CIPCSocket::initialize() {
|
||||||
m_szRequest = request;
|
m_szRequest = request;
|
||||||
m_bRequestReady = true;
|
m_bRequestReady = true;
|
||||||
|
|
||||||
|
g_pHyprpaper->tick(true);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (m_bReplyReady)
|
if (m_bReplyReady)
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue