hyprpaper/src/Hyprpaper.hpp

70 lines
2.4 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
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
2023-01-29 15:00:08 +01:00
wl_display* m_sDisplay; // assured
wl_compositor* m_sCompositor; // assured
wl_shm* m_sSHM; // assured
zwlr_layer_shell_v1* m_sLayerShell = nullptr; // expected
wp_fractional_scale_manager_v1* m_sFractionalScale = nullptr; // will remain null if not bound
wp_viewporter* m_sViewporter = nullptr; // expected
2022-07-01 23:05:58 +02:00
// 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-28 05:29:33 +02:00
std::string m_szExplicitConfigPath;
2023-01-29 17:38:48 +01:00
bool m_bNoFractionalScale = false;
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-11-18 21:35:33 +01:00
void createSeat(wl_seat*);
2022-07-02 18:26:59 +02:00
std::mutex m_mtTickMutex;
2022-11-18 21:35:33 +01:00
SMonitor* m_pLastMonitor = nullptr;
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;