ipc: fix ipc with wildcards

fixes #122
This commit is contained in:
Vaxry 2024-01-03 13:47:49 +01:00
parent 9e2a2670e1
commit c022069390
4 changed files with 62 additions and 36 deletions

View file

@ -15,11 +15,6 @@ void CHyprpaper::init() {
removeOldHyprpaperImages(); removeOldHyprpaperImages();
g_pConfigManager = std::make_unique<CConfigManager>();
g_pIPCSocket = std::make_unique<CIPCSocket>();
g_pConfigManager->parse();
m_sDisplay = (wl_display*)wl_display_connect(nullptr); m_sDisplay = (wl_display*)wl_display_connect(nullptr);
if (!m_sDisplay) { if (!m_sDisplay) {
@ -27,25 +22,36 @@ void CHyprpaper::init() {
exit(1); exit(1);
} }
// run
wl_registry* registry = wl_display_get_registry(m_sDisplay);
wl_registry_add_listener(registry, &Events::registryListener, nullptr);
wl_display_roundtrip(m_sDisplay);
while (m_vMonitors.size() < 1 || m_vMonitors[0]->name.empty()) {
wl_display_dispatch(m_sDisplay);
}
g_pConfigManager = std::make_unique<CConfigManager>();
g_pIPCSocket = std::make_unique<CIPCSocket>();
g_pConfigManager->parse();
preloadAllWallpapersFromConfig(); preloadAllWallpapersFromConfig();
if (std::any_cast<Hyprlang::INT>(g_pConfigManager->config->getConfigValue("ipc"))) if (std::any_cast<Hyprlang::INT>(g_pConfigManager->config->getConfigValue("ipc")))
g_pIPCSocket->initialize(); g_pIPCSocket->initialize();
// run do {
wl_registry* registry = wl_display_get_registry(m_sDisplay);
wl_registry_add_listener(registry, &Events::registryListener, nullptr);
while (wl_display_dispatch(m_sDisplay) != -1) {
std::lock_guard<std::mutex> lg(m_mtTickMutex); std::lock_guard<std::mutex> lg(m_mtTickMutex);
tick(true); tick(true);
} } while (wl_display_dispatch(m_sDisplay) != -1);
unlockSingleInstance(); unlockSingleInstance();
} }
void CHyprpaper::tick(bool force) { void CHyprpaper::tick(bool force) {
bool reload = g_pIPCSocket->mainThreadParseRequest(); bool reload = g_pIPCSocket && g_pIPCSocket->mainThreadParseRequest();
if (!reload && !force) if (!reload && !force)
return; return;
@ -453,6 +459,10 @@ SPoolBuffer* CHyprpaper::getPoolBuffer(SMonitor* pMonitor, CWallpaperTarget* pWa
void CHyprpaper::renderWallpaperForMonitor(SMonitor* pMonitor) { void CHyprpaper::renderWallpaperForMonitor(SMonitor* pMonitor) {
static auto* const PRENDERSPLASH = reinterpret_cast<Hyprlang::INT* const*>(g_pConfigManager->config->getConfigValuePtr("splash")->getDataStaticPtr()); static auto* const PRENDERSPLASH = reinterpret_cast<Hyprlang::INT* const*>(g_pConfigManager->config->getConfigValuePtr("splash")->getDataStaticPtr());
static auto* const PSPLASHOFFSET = reinterpret_cast<Hyprlang::FLOAT* const*>(g_pConfigManager->config->getConfigValuePtr("splash_offset")->getDataStaticPtr()); static auto* const PSPLASHOFFSET = reinterpret_cast<Hyprlang::FLOAT* const*>(g_pConfigManager->config->getConfigValuePtr("splash_offset")->getDataStaticPtr());
if (!m_mMonitorActiveWallpaperTargets[pMonitor])
recheckMonitor(pMonitor);
const auto PWALLPAPERTARGET = m_mMonitorActiveWallpaperTargets[pMonitor]; const auto PWALLPAPERTARGET = m_mMonitorActiveWallpaperTargets[pMonitor];
const auto CONTAIN = m_mMonitorWallpaperRenderData[pMonitor->name].contain; const auto CONTAIN = m_mMonitorWallpaperRenderData[pMonitor->name].contain;

View file

@ -40,6 +40,20 @@ static Hyprlang::CParseResult handleWallpaper(const char* C, const char* V) {
g_pHyprpaper->m_mMonitorActiveWallpapers[MONITOR] = WALLPAPER; g_pHyprpaper->m_mMonitorActiveWallpapers[MONITOR] = WALLPAPER;
g_pHyprpaper->m_mMonitorWallpaperRenderData[MONITOR].contain = contain; g_pHyprpaper->m_mMonitorWallpaperRenderData[MONITOR].contain = contain;
if (MONITOR.empty()) {
for (auto& m : g_pHyprpaper->m_vMonitors) {
if (!m->hasATarget || m->wildcard) {
g_pHyprpaper->clearWallpaperFromMonitor(m->name);
g_pHyprpaper->m_mMonitorActiveWallpapers[m->name] = WALLPAPER;
g_pHyprpaper->m_mMonitorWallpaperRenderData[m->name].contain = contain;
}
}
} else {
const auto PMON = g_pHyprpaper->getMonitorFromName(MONITOR);
if (PMON)
PMON->wildcard = false;
}
return result; return result;
} }

View file

@ -17,6 +17,7 @@ void Events::done(void *data, wl_output *wl_output) {
PMONITOR->readyForLS = true; PMONITOR->readyForLS = true;
std::lock_guard<std::mutex> lg(g_pHyprpaper->m_mtTickMutex); std::lock_guard<std::mutex> lg(g_pHyprpaper->m_mtTickMutex);
if (g_pConfigManager) // don't tick if this is the first roundtrip
g_pHyprpaper->tick(true); g_pHyprpaper->tick(true);
} }
@ -157,4 +158,3 @@ void Events::handlePreferredScale(void *data, wp_fractional_scale_v1* fractional
g_pHyprpaper->tick(true); g_pHyprpaper->tick(true);
} }
} }

View file

@ -1,8 +1,8 @@
#pragma once #pragma once
#include "../defines.hpp" #include "../defines.hpp"
#include "PoolBuffer.hpp"
#include "../render/LayerSurface.hpp" #include "../render/LayerSurface.hpp"
#include "PoolBuffer.hpp"
struct SMonitor { struct SMonitor {
std::string name = ""; std::string name = "";
@ -15,6 +15,8 @@ struct SMonitor {
bool readyForLS = false; bool readyForLS = false;
bool hasATarget = true; bool hasATarget = true;
bool wildcard = true;
uint32_t configureSerial = 0; uint32_t configureSerial = 0;
SPoolBuffer buffer; SPoolBuffer buffer;