2022-07-01 23:05:58 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "defines.hpp"
|
|
|
|
#include "config/ConfigManager.hpp"
|
|
|
|
#include "render/WallpaperTarget.hpp"
|
|
|
|
#include "helpers/Monitor.hpp"
|
|
|
|
#include "events/Events.hpp"
|
|
|
|
#include "helpers/PoolBuffer.hpp"
|
2022-07-02 18:26:59 +02:00
|
|
|
#include "ipc/Socket.hpp"
|
|
|
|
#include <mutex>
|
2022-07-01 23:05:58 +02:00
|
|
|
|
2022-08-03 18:06:33 +02:00
|
|
|
struct SWallpaperRenderData {
|
|
|
|
bool contain = false;
|
|
|
|
};
|
|
|
|
|
2022-07-01 23:05:58 +02:00
|
|
|
class CHyprpaper {
|
|
|
|
public:
|
|
|
|
// important
|
|
|
|
wl_display* m_sDisplay;
|
|
|
|
wl_compositor* m_sCompositor;
|
|
|
|
wl_shm* m_sSHM;
|
|
|
|
zwlr_layer_shell_v1* m_sLayerShell;
|
|
|
|
|
|
|
|
// init the utility
|
|
|
|
CHyprpaper();
|
|
|
|
void init();
|
2022-07-31 17:30:14 +02:00
|
|
|
void tick(bool force);
|
2022-07-01 23:05:58 +02:00
|
|
|
|
|
|
|
std::unordered_map<std::string, CWallpaperTarget> m_mWallpaperTargets;
|
|
|
|
std::unordered_map<std::string, std::string> m_mMonitorActiveWallpapers;
|
2022-08-03 18:06:33 +02:00
|
|
|
std::unordered_map<std::string, SWallpaperRenderData> m_mMonitorWallpaperRenderData;
|
2022-07-01 23:05:58 +02:00
|
|
|
std::unordered_map<SMonitor*, CWallpaperTarget*> m_mMonitorActiveWallpaperTargets;
|
2022-07-02 19:10:50 +02:00
|
|
|
std::vector<std::unique_ptr<SPoolBuffer>> m_vBuffers;
|
2022-07-02 18:26:59 +02:00
|
|
|
std::vector<std::unique_ptr<SMonitor>> m_vMonitors;
|
2022-07-01 23:05:58 +02:00
|
|
|
|
2022-07-31 17:28:37 +02:00
|
|
|
bool m_bIPCEnabled = true;
|
2022-09-27 02:31:25 +02:00
|
|
|
std::string explicitConfigPath;
|
2022-07-31 17:28:37 +02:00
|
|
|
|
2022-07-17 13:59:43 +02:00
|
|
|
void removeOldHyprpaperImages();
|
2022-07-01 23:05:58 +02:00
|
|
|
void preloadAllWallpapersFromConfig();
|
|
|
|
void recheckAllMonitors();
|
|
|
|
void ensureMonitorHasActiveWallpaper(SMonitor*);
|
|
|
|
void createLSForMonitor(SMonitor*);
|
|
|
|
void renderWallpaperForMonitor(SMonitor*);
|
|
|
|
void createBuffer(SPoolBuffer*, int32_t, int32_t, uint32_t);
|
|
|
|
void destroyBuffer(SPoolBuffer*);
|
|
|
|
int createPoolFile(size_t, std::string&);
|
|
|
|
bool setCloexec(const int&);
|
2022-07-02 18:26:59 +02:00
|
|
|
void clearWallpaperFromMonitor(const std::string&);
|
|
|
|
SMonitor* getMonitorFromName(const std::string&);
|
|
|
|
bool isPreloaded(const std::string&);
|
|
|
|
void recheckMonitor(SMonitor*);
|
2022-07-02 19:10:50 +02:00
|
|
|
void ensurePoolBuffersPresent();
|
|
|
|
SPoolBuffer* getPoolBuffer(SMonitor*, CWallpaperTarget*);
|
2022-07-17 14:17:54 +02:00
|
|
|
void unloadWallpaper(const std::string&);
|
2022-07-02 18:26:59 +02:00
|
|
|
|
|
|
|
std::mutex m_mtTickMutex;
|
2022-07-02 19:10:50 +02:00
|
|
|
private:
|
2022-07-31 17:28:37 +02:00
|
|
|
|
2022-07-02 18:26:59 +02:00
|
|
|
bool m_bShouldExit = false;
|
2022-07-01 23:05:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
inline std::unique_ptr<CHyprpaper> g_pHyprpaper;
|