2022-07-01 23:05:58 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "config/ConfigManager.hpp"
|
2023-12-31 01:37:50 +01:00
|
|
|
#include "defines.hpp"
|
2023-04-09 19:26:11 +02:00
|
|
|
#include "helpers/MiscFunctions.hpp"
|
2023-12-31 01:37:50 +01:00
|
|
|
#include "helpers/Monitor.hpp"
|
|
|
|
#include "helpers/PoolBuffer.hpp"
|
2022-07-02 18:26:59 +02:00
|
|
|
#include "ipc/Socket.hpp"
|
2023-12-31 01:37:50 +01:00
|
|
|
#include "render/WallpaperTarget.hpp"
|
2022-07-02 18:26:59 +02:00
|
|
|
#include <mutex>
|
2022-07-01 23:05:58 +02:00
|
|
|
|
2024-07-17 16:25:07 +02:00
|
|
|
#include "protocols/cursor-shape-v1.hpp"
|
|
|
|
#include "protocols/fractional-scale-v1.hpp"
|
|
|
|
#include "protocols/linux-dmabuf-v1.hpp"
|
|
|
|
#include "protocols/viewporter.hpp"
|
|
|
|
#include "protocols/wayland.hpp"
|
|
|
|
#include "protocols/wlr-layer-shell-unstable-v1.hpp"
|
|
|
|
|
2022-08-03 18:06:33 +02:00
|
|
|
struct SWallpaperRenderData {
|
|
|
|
bool contain = false;
|
2024-10-25 13:29:16 +02:00
|
|
|
bool tile = false;
|
2022-08-03 18:06:33 +02:00
|
|
|
};
|
|
|
|
|
2022-07-01 23:05:58 +02:00
|
|
|
class CHyprpaper {
|
2024-07-17 16:25:07 +02:00
|
|
|
public:
|
2022-07-01 23:05:58 +02:00
|
|
|
// important
|
2024-07-17 16:25:07 +02:00
|
|
|
wl_display* m_sDisplay = nullptr;
|
|
|
|
SP<CCWlCompositor> m_pCompositor;
|
|
|
|
SP<CCWlShm> m_pSHM;
|
|
|
|
SP<CCZwlrLayerShellV1> m_pLayerShell;
|
|
|
|
SP<CCWpFractionalScaleManagerV1> m_pFractionalScale;
|
|
|
|
SP<CCWpViewporter> m_pViewporter;
|
|
|
|
SP<CCWlSeat> m_pSeat;
|
|
|
|
SP<CCWlPointer> m_pSeatPointer;
|
|
|
|
SP<CCWpCursorShapeDeviceV1> m_pSeatCursorShapeDevice;
|
|
|
|
SP<CCWpCursorShapeManagerV1> m_pCursorShape;
|
2022-07-01 23:05:58 +02:00
|
|
|
|
|
|
|
// init the utility
|
|
|
|
CHyprpaper();
|
2024-07-17 16:25:07 +02:00
|
|
|
void init();
|
|
|
|
void tick(bool force);
|
2022-07-01 23:05:58 +02:00
|
|
|
|
2024-07-17 16:25:07 +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;
|
2024-07-17 16:25:07 +02:00
|
|
|
std::unordered_map<SMonitor*, CWallpaperTarget*> m_mMonitorActiveWallpaperTargets;
|
|
|
|
std::vector<std::unique_ptr<SPoolBuffer>> m_vBuffers;
|
|
|
|
std::vector<std::unique_ptr<SMonitor>> m_vMonitors;
|
2022-07-01 23:05:58 +02:00
|
|
|
|
2024-07-17 16:25:07 +02:00
|
|
|
std::string m_szExplicitConfigPath;
|
|
|
|
bool m_bNoFractionalScale = false;
|
2022-07-31 17:28:37 +02:00
|
|
|
|
2024-07-17 16:25:07 +02:00
|
|
|
void removeOldHyprpaperImages();
|
|
|
|
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&);
|
|
|
|
void clearWallpaperFromMonitor(const std::string&);
|
|
|
|
SMonitor* getMonitorFromName(const std::string&);
|
|
|
|
bool isPreloaded(const std::string&);
|
|
|
|
void recheckMonitor(SMonitor*);
|
|
|
|
void ensurePoolBuffersPresent();
|
|
|
|
SPoolBuffer* getPoolBuffer(SMonitor*, CWallpaperTarget*);
|
|
|
|
void unloadWallpaper(const std::string&);
|
|
|
|
void createSeat(SP<CCWlSeat>);
|
|
|
|
bool lockSingleInstance(); // fails on multi-instance
|
|
|
|
void unlockSingleInstance();
|
2023-12-31 01:37:50 +01:00
|
|
|
|
2024-07-17 16:25:07 +02:00
|
|
|
std::mutex m_mtTickMutex;
|
2022-07-02 18:26:59 +02:00
|
|
|
|
2024-07-17 16:25:07 +02:00
|
|
|
SMonitor* m_pLastMonitor = nullptr;
|
2022-11-18 21:35:33 +01:00
|
|
|
|
2024-07-17 16:25:07 +02:00
|
|
|
private:
|
2023-12-31 01:37:50 +01:00
|
|
|
bool m_bShouldExit = false;
|
2022-07-01 23:05:58 +02:00
|
|
|
};
|
|
|
|
|
2022-09-30 12:18:26 +02:00
|
|
|
inline std::unique_ptr<CHyprpaper> g_pHyprpaper;
|