#pragma once #include #include #include #include #include #include #include #include #include "ApplicationState.h" #include "WallpaperEngine/Data/JSON.h" #include "../Render/TextureProvider.h" #include "WallpaperEngine/Render/WallpaperState.h" #include "WallpaperEngine/VideoPlayback/VideoSegment.h" #include "WallpaperEngine/Data/Model/Project.h" namespace WallpaperEngine::Application { using namespace WallpaperEngine::Data::Assets; class ApplicationContext { public: ApplicationContext (int argc, char* argv[]); void loadSettingsFromArgv (); [[nodiscard]] std::optional resolveObjectVisibility (int id, const std::string& name) const; [[nodiscard]] std::optional resolveEffectVisibility (int id, const std::string& name) const; [[nodiscard]] std::optional resolveAudioSensitivity (int id, const std::string& name) const; [[nodiscard]] std::optional resolveSoundVolume (int id, const std::string& name) const; enum WINDOW_MODE { NORMAL_WINDOW = 0, DESKTOP_BACKGROUND = 1, EXPLICIT_WINDOW = 2, }; enum WAYLAND_LAYER { WAYLAND_LAYER_BACKGROUND = 0, WAYLAND_LAYER_BOTTOM = 1, WAYLAND_LAYER_TOP = 2, WAYLAND_LAYER_OVERLAY = 3, }; enum HRTF_MODE { HRTF_AUTO = 0, HRTF_ON = 1, HRTF_OFF = 2, }; [[nodiscard]] static std::optional parseHrtfMode (const std::string& value); struct PlaylistSettings { uint32_t delayMinutes = 60; std::string mode = "timer"; std::string order = "sequential"; bool updateOnPause = false; bool videoSequence = false; bool beginFirst = false; bool playIntro = false; [[nodiscard]] bool hasIntro () const { return this->mode == "timer" && this->beginFirst && this->playIntro; } }; struct PlaylistDefinition { std::string name; std::vector items; PlaylistSettings settings; }; struct SpanGroup { std::vector screens; std::filesystem::path background; WallpaperEngine::Render::WallpaperState::TextureUVsScaling scaling = WallpaperEngine::Render::WallpaperState::TextureUVsScaling::DefaultUVs; TextureFlags clamp = TextureFlags_ClampUVsBorder; float zoom = 1.0f; glm::vec2 offset = { 0.0f, 0.0f }; WallpaperEngine::Render::WallpaperState::Alignment alignment = {}; glm::vec4 cornerColor = { 0.0f, 0.0f, 0.0f, 1.0f }; WallpaperEngine::Data::Model::ImageAdjustments imageAdjustments = {}; }; struct SplitScreen { enum Layout { LAYOUT_ASPECT = 0, LAYOUT_EQUAL = 1, LAYOUT_CENTER = 2, }; std::string screen; std::vector slots; Layout layout = LAYOUT_ASPECT; }; [[nodiscard]] const SplitScreen* findSplitScreen (const std::string& screenOrSlot) const; [[nodiscard]] bool isScreenRequested (const std::string& name) const; [[nodiscard]] std::vector describeRequestedScreens () const; struct { struct { bool onlyListProperties = false; bool onlyListObjects = false; bool onlyListAudioObjects = false; bool onlyListEffects = false; bool onlyListFonts = false; bool dumpStructure = false; bool noShaderCache = false; bool disableParticles = false; bool expandCanvas = false; bool repairAssets = false; bool postProcessingDisabled = false; bool ultraPostProcessing = false; bool displayHDR = false; int volumetricsQuality = 2; int shadowQuality = 2; int msaaSamples = 0; int supersampling = 1; std::vector disabledObjects; std::vector enabledObjects; std::vector disabledEffects; std::vector enabledEffects; std::map audioSensitivity; std::map soundVolume; std::filesystem::path assets; std::filesystem::path defaultBackground; std::map screenBackgrounds; std::map properties; std::map screenScalings; std::map screenClamps; std::map screenZooms; std::map screenRenderScales; std::map screenOffsets; std::map screenAlignments; std::map screenCornerColors; std::map screenImageAdjustments; std::map screenVideoSegments; std::map screenPlaylists; std::optional defaultPlaylist; std::vector spanGroups; std::vector splitScreens; bool webHost = false; std::string webHostShm; std::string webHostFrames; int webHostSocket = -1; uint32_t webHostWidth = 0; uint32_t webHostHeight = 0; std::optional controlFile; } general; struct { WINDOW_MODE mode; int maximumFPS; float playbackSpeed; WallpaperEngine::VideoPlayback::VideoSegments videoSegments; std::string hwdec; std::string webFrames; std::string frameLimiter; std::string transition; int transitionMs; bool freezeAnimations; bool pauseOnFullscreen; // only fullscreen toplevels that are also activated count (scrollable tiling compositors) bool pauseOnFullscreenOnlyWhenActive; bool pauseOnFocus; /** wlroots: maximized toplevels pause their outputs too (KDE and GNOME always do, like WE) */ bool pauseOnMaximized; std::vector fullscreenPauseIgnoreAppIds; std::optional batteryFPS; int idlePauseMinutes; bool pauseOnLock; bool hdr; struct { bool baseOnly; bool noSolidFinal; bool passLog; bool brightnessLog; bool noPuppetAnimation; std::optional objectFilter; std::vector skipObjects; std::vector skipEffects; } debug; struct { glm::ivec4 geometry; TextureFlags clamp; WallpaperEngine::Render::WallpaperState::TextureUVsScaling scalingMode; float zoom; glm::vec2 offset; WallpaperEngine::Render::WallpaperState::Alignment alignment; glm::vec4 cornerColor; WallpaperEngine::Data::Model::ImageAdjustments imageAdjustments; bool asBackground; bool regular; } window; struct { WAYLAND_LAYER layer; bool layerAuto; } wayland; } render; struct { bool enabled; /** 0-128 */ int volume; bool automute; bool audioprocessing; std::optional audioScreen; std::optional ambientVolume; HRTF_MODE hrtf; } audio; struct { bool enabled; std::string host; uint16_t port; bool boost; /** WE's brightnessfactor, 1 = as is */ float brightness; bool reduceFps; } leds; struct { bool enabled; bool disableparallax; bool clampParallaxToImageSize; std::filesystem::path inputFile; } mouse; struct { bool take; /** In frames, not seconds */ uint32_t delay; std::filesystem::path path; } screenshot; } settings = { .general = { .onlyListProperties = false, .onlyListObjects = false, .onlyListAudioObjects = false, .onlyListEffects = false, .onlyListFonts = false, .dumpStructure = false, .noShaderCache = false, .disabledObjects = {}, .enabledObjects = {}, .disabledEffects = {}, .enabledEffects = {}, .audioSensitivity = {}, .soundVolume = {}, .assets = "", .defaultBackground = "", .screenBackgrounds = {}, .properties = {}, .screenScalings = {}, .screenClamps = {}, .screenZooms = {}, .screenRenderScales = {}, .screenOffsets = {}, .screenAlignments = {}, .screenCornerColors = {}, .screenImageAdjustments = {}, .screenVideoSegments = {}, .screenPlaylists = {}, .defaultPlaylist = std::nullopt, .spanGroups = {}, .splitScreens = {}, .webHost = false, .webHostShm = "", .webHostFrames = "shm", .webHostSocket = -1, .webHostWidth = 0, .webHostHeight = 0, .controlFile = std::nullopt, }, .render = { .mode = NORMAL_WINDOW, .maximumFPS = 60, .playbackSpeed = 1.0f, .videoSegments = {}, .hwdec = "auto", .webFrames = "auto", .frameLimiter = "budget", .transition = "none", .transitionMs = 600, .freezeAnimations = false, .pauseOnFullscreen = true, .pauseOnFullscreenOnlyWhenActive = false, .pauseOnFocus = false, .pauseOnMaximized = false, .fullscreenPauseIgnoreAppIds = {}, .batteryFPS = std::nullopt, .idlePauseMinutes = 0, .pauseOnLock = true, .hdr = false, .debug = { .baseOnly = false, .noSolidFinal = false, .passLog = false, .brightnessLog = false, .noPuppetAnimation = false, .objectFilter = std::nullopt, .skipObjects = {}, .skipEffects = {}, }, .window = { .geometry = {}, .clamp = TextureFlags_ClampUVsBorder, .scalingMode = WallpaperEngine::Render::WallpaperState::TextureUVsScaling::DefaultUVs, .zoom = 1.0f, .offset = { 0.0f, 0.0f }, .alignment = {}, .cornerColor = { 0.0f, 0.0f, 0.0f, 1.0f }, .imageAdjustments = {}, .asBackground = false, .regular = false, }, .wayland = { .layer = WAYLAND_LAYER_BOTTOM, .layerAuto = true, }, }, .audio = { .enabled = true, .volume = 15, .automute = false, .audioprocessing = true, .audioScreen = std::nullopt, .ambientVolume = std::nullopt, .hrtf = HRTF_AUTO, }, .leds = { .enabled = false, .host = "127.0.0.1", .port = 6742, .boost = true, .brightness = 1.0f, .reduceFps = false, }, .mouse = { .enabled = true, .disableparallax = false, .clampParallaxToImageSize = true, }, .screenshot = { .take = false, .delay = 5, .path = "", }, }; ApplicationState state; [[nodiscard]] int getArgc () const; [[nodiscard]] char** getArgv () const; private: int m_argc; char** m_argv; void validateAssets (); void validateScreenshot () const; static std::filesystem::path translateBackground (const std::string& bgIdOrPath); void loadPlaylistsFromConfig (); std::filesystem::path resolvePlaylistItemPath (const std::string& raw) const; std::filesystem::path configFilePath () const; std::optional parseConfigJson (const std::filesystem::path& path) const; PlaylistSettings parsePlaylistSettings (const WallpaperEngine::Data::JSON::JSON& playlistJson) const; std::vector collectPlaylistItems (const WallpaperEngine::Data::JSON::JSON& playlistJson, const std::string& name) const; std::optional buildPlaylistDefinition ( const WallpaperEngine::Data::JSON::JSON& playlistJson, const std::string& fallbackName ) const; void registerPlaylist (PlaylistDefinition&& definition); [[nodiscard]] const PlaylistDefinition& getPlaylistFromConfig (const std::string& name); std::map m_configPlaylists; bool m_loadedConfigPlaylists = false; }; }