mirror of
https://github.com/hyprwm/hyprpaper.git
synced 2024-11-16 22:25:59 +01:00
performance fixes + disabling ipc
This commit is contained in:
parent
f75fcf01d1
commit
c3eba7ea3c
5 changed files with 39 additions and 24 deletions
|
@ -19,41 +19,49 @@ void CHyprpaper::init() {
|
|||
|
||||
preloadAllWallpapersFromConfig();
|
||||
|
||||
g_pIPCSocket->initialize();
|
||||
if (m_bIPCEnabled)
|
||||
g_pIPCSocket->initialize();
|
||||
|
||||
// run
|
||||
wl_registry *registry = wl_display_get_registry(m_sDisplay);
|
||||
wl_registry_add_listener(registry, &Events::registryListener, nullptr);
|
||||
|
||||
std::thread([&]() { // we dispatch wl events cuz we have to
|
||||
if (m_bIPCEnabled) {
|
||||
std::thread([&]() { // we dispatch wl events cuz we have to
|
||||
while (wl_display_dispatch(m_sDisplay) != -1) {
|
||||
tick();
|
||||
}
|
||||
|
||||
m_bShouldExit = true;
|
||||
}).detach();
|
||||
|
||||
while (1) { // we also tick every 1ms for socket and other shit's updates
|
||||
tick();
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
|
||||
if (m_bShouldExit)
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
while (wl_display_dispatch(m_sDisplay) != -1) {
|
||||
tick();
|
||||
}
|
||||
|
||||
m_bShouldExit = true;
|
||||
}).detach();
|
||||
|
||||
while (1) { // we also tick every 1ms for socket and other shit's updates
|
||||
tick();
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
|
||||
if (m_bShouldExit)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CHyprpaper::tick() {
|
||||
m_mtTickMutex.lock();
|
||||
std::lock_guard<std::mutex> lg(m_mtTickMutex);
|
||||
|
||||
bool reload = g_pIPCSocket->mainThreadParseRequest();
|
||||
|
||||
if (!reload)
|
||||
return;
|
||||
|
||||
preloadAllWallpapersFromConfig();
|
||||
ensurePoolBuffersPresent();
|
||||
|
||||
recheckAllMonitors();
|
||||
|
||||
g_pIPCSocket->mainThreadParseRequest();
|
||||
|
||||
m_mtTickMutex.unlock();
|
||||
}
|
||||
|
||||
bool CHyprpaper::isPreloaded(const std::string& path) {
|
||||
|
|
|
@ -28,6 +28,8 @@ public:
|
|||
std::vector<std::unique_ptr<SPoolBuffer>> m_vBuffers;
|
||||
std::vector<std::unique_ptr<SMonitor>> m_vMonitors;
|
||||
|
||||
bool m_bIPCEnabled = true;
|
||||
|
||||
void removeOldHyprpaperImages();
|
||||
void preloadAllWallpapersFromConfig();
|
||||
void recheckAllMonitors();
|
||||
|
@ -48,6 +50,7 @@ public:
|
|||
|
||||
std::mutex m_mtTickMutex;
|
||||
private:
|
||||
|
||||
bool m_bShouldExit = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -95,6 +95,8 @@ void CConfigManager::parseKeyword(const std::string& COMMAND, const std::string&
|
|||
handlePreload(COMMAND, VALUE);
|
||||
else if (COMMAND == "unload")
|
||||
handleUnload(COMMAND, VALUE);
|
||||
else if (COMMAND == "ipc")
|
||||
g_pHyprpaper->m_bIPCEnabled = VALUE == "1" || VALUE == "yes" || VALUE == "on" || VALUE == "true";
|
||||
else
|
||||
parseError = "unknown keyword " + COMMAND;
|
||||
}
|
||||
|
|
|
@ -84,17 +84,17 @@ void CIPCSocket::initialize() {
|
|||
}).detach();
|
||||
}
|
||||
|
||||
void CIPCSocket::mainThreadParseRequest() {
|
||||
bool CIPCSocket::mainThreadParseRequest() {
|
||||
|
||||
if (!m_bRequestReady)
|
||||
return;
|
||||
return false;
|
||||
|
||||
std::string copy = m_szRequest;
|
||||
|
||||
// now we can work on the copy
|
||||
|
||||
if (copy == "")
|
||||
return;
|
||||
return false;
|
||||
|
||||
Debug::log(LOG, "Received a request: %s", copy.c_str());
|
||||
|
||||
|
@ -108,17 +108,19 @@ void CIPCSocket::mainThreadParseRequest() {
|
|||
m_szReply = g_pConfigManager->parseError;
|
||||
m_bReplyReady = true;
|
||||
m_bRequestReady = false;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_szReply = "invalid command";
|
||||
m_bReplyReady = true;
|
||||
m_bRequestReady = false;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_szReply = "ok";
|
||||
m_bReplyReady = true;
|
||||
m_bRequestReady = false;
|
||||
|
||||
return true;
|
||||
}
|
|
@ -7,7 +7,7 @@ class CIPCSocket {
|
|||
public:
|
||||
void initialize();
|
||||
|
||||
void mainThreadParseRequest();
|
||||
bool mainThreadParseRequest();
|
||||
|
||||
private:
|
||||
|
||||
|
|
Loading…
Reference in a new issue