mirror of
https://github.com/hyprwm/hyprpaper.git
synced 2024-12-22 20:29:48 +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,12 +19,14 @@ void CHyprpaper::init() {
|
||||||
|
|
||||||
preloadAllWallpapersFromConfig();
|
preloadAllWallpapersFromConfig();
|
||||||
|
|
||||||
|
if (m_bIPCEnabled)
|
||||||
g_pIPCSocket->initialize();
|
g_pIPCSocket->initialize();
|
||||||
|
|
||||||
// run
|
// run
|
||||||
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
|
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();
|
tick();
|
||||||
|
@ -41,19 +43,25 @@ void CHyprpaper::init() {
|
||||||
if (m_bShouldExit)
|
if (m_bShouldExit)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
while (wl_display_dispatch(m_sDisplay) != -1) {
|
||||||
|
tick();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprpaper::tick() {
|
void CHyprpaper::tick() {
|
||||||
m_mtTickMutex.lock();
|
std::lock_guard<std::mutex> lg(m_mtTickMutex);
|
||||||
|
|
||||||
|
bool reload = g_pIPCSocket->mainThreadParseRequest();
|
||||||
|
|
||||||
|
if (!reload)
|
||||||
|
return;
|
||||||
|
|
||||||
preloadAllWallpapersFromConfig();
|
preloadAllWallpapersFromConfig();
|
||||||
ensurePoolBuffersPresent();
|
ensurePoolBuffersPresent();
|
||||||
|
|
||||||
recheckAllMonitors();
|
recheckAllMonitors();
|
||||||
|
|
||||||
g_pIPCSocket->mainThreadParseRequest();
|
|
||||||
|
|
||||||
m_mtTickMutex.unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CHyprpaper::isPreloaded(const std::string& path) {
|
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<SPoolBuffer>> m_vBuffers;
|
||||||
std::vector<std::unique_ptr<SMonitor>> m_vMonitors;
|
std::vector<std::unique_ptr<SMonitor>> m_vMonitors;
|
||||||
|
|
||||||
|
bool m_bIPCEnabled = true;
|
||||||
|
|
||||||
void removeOldHyprpaperImages();
|
void removeOldHyprpaperImages();
|
||||||
void preloadAllWallpapersFromConfig();
|
void preloadAllWallpapersFromConfig();
|
||||||
void recheckAllMonitors();
|
void recheckAllMonitors();
|
||||||
|
@ -48,6 +50,7 @@ public:
|
||||||
|
|
||||||
std::mutex m_mtTickMutex;
|
std::mutex m_mtTickMutex;
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool m_bShouldExit = false;
|
bool m_bShouldExit = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,8 @@ void CConfigManager::parseKeyword(const std::string& COMMAND, const std::string&
|
||||||
handlePreload(COMMAND, VALUE);
|
handlePreload(COMMAND, VALUE);
|
||||||
else if (COMMAND == "unload")
|
else if (COMMAND == "unload")
|
||||||
handleUnload(COMMAND, VALUE);
|
handleUnload(COMMAND, VALUE);
|
||||||
|
else if (COMMAND == "ipc")
|
||||||
|
g_pHyprpaper->m_bIPCEnabled = VALUE == "1" || VALUE == "yes" || VALUE == "on" || VALUE == "true";
|
||||||
else
|
else
|
||||||
parseError = "unknown keyword " + COMMAND;
|
parseError = "unknown keyword " + COMMAND;
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,17 +84,17 @@ void CIPCSocket::initialize() {
|
||||||
}).detach();
|
}).detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIPCSocket::mainThreadParseRequest() {
|
bool CIPCSocket::mainThreadParseRequest() {
|
||||||
|
|
||||||
if (!m_bRequestReady)
|
if (!m_bRequestReady)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
std::string copy = m_szRequest;
|
std::string copy = m_szRequest;
|
||||||
|
|
||||||
// now we can work on the copy
|
// now we can work on the copy
|
||||||
|
|
||||||
if (copy == "")
|
if (copy == "")
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
Debug::log(LOG, "Received a request: %s", copy.c_str());
|
Debug::log(LOG, "Received a request: %s", copy.c_str());
|
||||||
|
|
||||||
|
@ -108,17 +108,19 @@ void CIPCSocket::mainThreadParseRequest() {
|
||||||
m_szReply = g_pConfigManager->parseError;
|
m_szReply = g_pConfigManager->parseError;
|
||||||
m_bReplyReady = true;
|
m_bReplyReady = true;
|
||||||
m_bRequestReady = false;
|
m_bRequestReady = false;
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_szReply = "invalid command";
|
m_szReply = "invalid command";
|
||||||
m_bReplyReady = true;
|
m_bReplyReady = true;
|
||||||
m_bRequestReady = false;
|
m_bRequestReady = false;
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_szReply = "ok";
|
m_szReply = "ok";
|
||||||
m_bReplyReady = true;
|
m_bReplyReady = true;
|
||||||
m_bRequestReady = false;
|
m_bRequestReady = false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
|
@ -7,7 +7,7 @@ class CIPCSocket {
|
||||||
public:
|
public:
|
||||||
void initialize();
|
void initialize();
|
||||||
|
|
||||||
void mainThreadParseRequest();
|
bool mainThreadParseRequest();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue