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();
g_pConfigManager = std::make_unique<CConfigManager>();
g_pIPCSocket = std::make_unique<CIPCSocket>();
g_pConfigManager->parse();
m_sDisplay = (wl_display*)wl_display_connect(nullptr);
if (!m_sDisplay) {
@ -27,25 +22,36 @@ void CHyprpaper::init() {
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();
if (std::any_cast<Hyprlang::INT>(g_pConfigManager->config->getConfigValue("ipc")))
g_pIPCSocket->initialize();
// run
wl_registry* registry = wl_display_get_registry(m_sDisplay);
wl_registry_add_listener(registry, &Events::registryListener, nullptr);
while (wl_display_dispatch(m_sDisplay) != -1) {
do {
std::lock_guard<std::mutex> lg(m_mtTickMutex);
tick(true);
}
} while (wl_display_dispatch(m_sDisplay) != -1);
unlockSingleInstance();
}
void CHyprpaper::tick(bool force) {
bool reload = g_pIPCSocket->mainThreadParseRequest();
bool reload = g_pIPCSocket && g_pIPCSocket->mainThreadParseRequest();
if (!reload && !force)
return;
@ -453,6 +459,10 @@ SPoolBuffer* CHyprpaper::getPoolBuffer(SMonitor* pMonitor, CWallpaperTarget* pWa
void CHyprpaper::renderWallpaperForMonitor(SMonitor* pMonitor) {
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());
if (!m_mMonitorActiveWallpaperTargets[pMonitor])
recheckMonitor(pMonitor);
const auto PWALLPAPERTARGET = m_mMonitorActiveWallpaperTargets[pMonitor];
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_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;
}

View file

@ -17,6 +17,7 @@ void Events::done(void *data, wl_output *wl_output) {
PMONITOR->readyForLS = true;
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);
}
@ -157,4 +158,3 @@ void Events::handlePreferredScale(void *data, wp_fractional_scale_v1* fractional
g_pHyprpaper->tick(true);
}
}

View file

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