hyprpaper/src/Hyprpaper.hpp

52 lines
1.7 KiB
C++
Raw Normal View History

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
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-02 18:26:59 +02:00
void tick();
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;
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
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-02 18:26:59 +02:00
std::mutex m_mtTickMutex;
2022-07-02 19:10:50 +02:00
private:
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;