Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package hyprpaper for openSUSE:Factory checked in at 2024-04-02 16:43:08 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/hyprpaper (Old) and /work/SRC/openSUSE:Factory/.hyprpaper.new.1905 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "hyprpaper" Tue Apr 2 16:43:08 2024 rev:3 rq:1163929 version:0.6.0 Changes: -------- --- /work/SRC/openSUSE:Factory/hyprpaper/hyprpaper.changes 2023-10-13 23:16:41.443417845 +0200 +++ /work/SRC/openSUSE:Factory/.hyprpaper.new.1905/hyprpaper.changes 2024-04-02 16:45:00.438711731 +0200 @@ -1,0 +2,40 @@ +Mon Apr 1 07:54:24 UTC 2024 - ming li <m...@suse.com> + +- Update to version 0.6.0: + Notes for packagers + * new dependency: hyprlang + Changes + * hyprpaper now uses hyprlang for config parsing + * A config file is no longer required + * Webp is now supported + * Big-endian systems are now supported + MRs + * doc(README): Write about required dependencies by @arijit79 in #111 + * Fix nix build, update flake.lock by @AtaraxiaSjel in #112 + * Add webp support by @tobiichi3227 in #113 + * missing libwebp-devel for fedora by @condor0010 in #114 + * fix: check path is empty by @tobiichi3227 in #116 + * fix: build failed in big-endian system by @tobiichi3227 in #117 + * Nix: add hyprlang by @fufexan in #121 + + update to version 0.5.0: + Changes + * fix: Read absolute path of symlinks + * internal: fix duplicate include of math + * feat: add splash_offset + * readme: update opensuse deps + * render: always draw a black background first + * ipc: allow multiple read from IPC + * fix: respect PREFIX in Makefile + * surface: set fully opaque + MRs + * fix: Read absolute path of symlinks by @slowsage in #90 + * dupliacate include of math by @LamprosPitsillos in #95 + * add "splash_offset" by @MightyPlaza in #98 + * Update README.md by @uncomfyhalomacro in #99 + * Always draw a black background behind the wallpaper by + @FakeMichau in #100 + * Allow multiple read from IPC + some refactor by @cylian914 in #102 + * fix: respect PREFIX in Makefile by @czadowanie in #106 + +------------------------------------------------------------------- Old: ---- hyprpaper-0.4.0.tar.gz New: ---- hyprpaper-0.6.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ hyprpaper.spec ++++++ --- /var/tmp/diff_new_pack.kKZAlz/_old 2024-04-02 16:45:00.974730865 +0200 +++ /var/tmp/diff_new_pack.kKZAlz/_new 2024-04-02 16:45:00.978731007 +0200 @@ -1,7 +1,7 @@ # # spec file for package hyprpaper # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %global __builder ninja Name: hyprpaper Summary: Wayland wallpaper utility with IPC controls -Version: 0.4.0 +Version: 0.6.0 Release: 0 License: BSD-3-Clause URL: https://github.com/hyprwm/hyprpaper @@ -30,14 +30,16 @@ BuildRequires: ninja BuildRequires: pkgconfig(gtk-layer-shell-0) BuildRequires: pkgconfig(hyprland-protocols) +BuildRequires: pkgconfig(hyprlang) >= 0.2.0 BuildRequires: pkgconfig(libglvnd) BuildRequires: pkgconfig(libjpeg) BuildRequires: pkgconfig(libmagic) +BuildRequires: pkgconfig(libwebp) BuildRequires: pkgconfig(pango) BuildRequires: pkgconfig(pangocairo) BuildRequires: pkgconfig(wayland-protocols) >= 1.24 BuildRequires: pkgconfig(wayland-server) >= 1.20.0 -BuildRequires: pkgconfig(wlroots) >= 0.15.0 +BuildRequires: pkgconfig(wlroots) >= 0.16.0 BuildRequires: pkgconfig(xwaylandproto) %description ++++++ hyprpaper-0.4.0.tar.gz -> hyprpaper-0.6.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hyprpaper-0.4.0/CMakeLists.txt new/hyprpaper-0.6.0/CMakeLists.txt --- old/hyprpaper-0.4.0/CMakeLists.txt 2023-08-03 13:00:55.000000000 +0200 +++ new/hyprpaper-0.6.0/CMakeLists.txt 2024-01-02 22:22:34.000000000 +0100 @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.4) -project(hyprpaper +project(hyprpaper DESCRIPTION "A blazing fast wayland wallpaper utility" ) @@ -41,7 +41,7 @@ find_package(Threads REQUIRED) find_package(PkgConfig REQUIRED) -pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols cairo pango pangocairo libjpeg) +pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols cairo pango pangocairo libjpeg libwebp hyprlang>=0.2.0) file(GLOB_RECURSE SRCFILES "src/*.cpp") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hyprpaper-0.4.0/Makefile new/hyprpaper-0.6.0/Makefile --- old/hyprpaper-0.4.0/Makefile 2023-08-03 13:00:55.000000000 +0200 +++ new/hyprpaper-0.6.0/Makefile 2024-01-02 22:22:34.000000000 +0100 @@ -1,4 +1,4 @@ -PREFIX = /usr/local +PREFIX ?= /usr CFLAGS ?= -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare -Wno-unused-function -Wno-unused-variable -Wno-unused-result -Wdeclaration-after-statement CFLAGS += -I. -DWLR_USE_UNSTABLE -std=c99 @@ -71,4 +71,4 @@ install: make all - cp ./build/hyprpaper /usr/bin -f \ No newline at end of file + cp ./build/hyprpaper $(PREFIX)/bin -f diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hyprpaper-0.4.0/README.md new/hyprpaper-0.6.0/README.md --- old/hyprpaper-0.4.0/README.md 2023-08-03 13:00:55.000000000 +0200 +++ new/hyprpaper-0.6.0/README.md 2024-01-02 22:22:34.000000000 +0100 @@ -13,20 +13,50 @@ [Arch Linux](https://archlinux.org/packages/community/x86_64/hyprpaper/): `pacman -S hyprpaper` -### Manual: +## Manual: + +### Dependencies +The development files of these packages need to be installed on the system for `hyprpaper` to build correctly. +(Development packages are usually suffixed with `-dev` or `-devel` in most distros' repos). +- wayland +- wayland-protocols +- pango +- cairo +- file +- libglvnd +- libglvnd-core +- libjpeg-turbo +- libwebp +- hyprlang + +Please note hyprpaper > 0.5.0 depends on [hyprlang](https://github.com/hyprwm/hyprlang) which is new +and might not be packaged for your distro yet. If that's the case, build and install it from source. + +To install all of these in Fedora, run this command: ``` -git clone https://github.com/hyprwm/hyprpaper -cd hyprpaper -make all +sudo dnf install wayland-devel wayland-protocols-devel pango-devel cairo-devel file-devel libglvnd-devel libglvnd-core-devel libjpeg-turbo-devel libwebp-devel gcc-c++ +``` + +On Arch: +``` +sudo pacman -S ninja gcc wayland-protocols libjpeg-turbo libwebp pango cairo pkgconf cmake libglvnd wayland ``` -*the output binary will be in `./build/`, copy it to your PATH, e.g. `/usr/bin`* -#### Dependencies On OpenSUSE: ``` -sudo zypper install ninja gcc-c++ wayland-protocols-devel Mesa-libGLESv3-devel +sudo zypper install ninja gcc-c++ wayland-protocols-devel Mesa-libGLESv3-devel file-devel ``` +### Building + +``` +git clone https://github.com/hyprwm/hyprpaper +cd hyprpaper +make all +``` + +*the output binary will be in `./build/`, copy it to your PATH, e.g. `/usr/bin`* + # Usage Hyprpaper is controlled by the config, like this: @@ -45,7 +75,7 @@ # .. more monitors ``` -Preload will tell Hyprland to load a particular image (supported formats: png, jpg, jpeg). Wallpaper will apply the wallpaper to the selected output (`monitor` is the monitor's name, easily can be retrieved with `hyprctl monitors`. You can leave it empty for a wildcard (aka fallback). You can also use `desc:` followed by the monitor's description without the (PORT) at the end) +Preload will tell Hyprland to load a particular image (supported formats: png, jpg, jpeg, webp). Wallpaper will apply the wallpaper to the selected output (`monitor` is the monitor's name, easily can be retrieved with `hyprctl monitors`. You can leave it empty for a wildcard (aka fallback). You can also use `desc:` followed by the monitor's description without the (PORT) at the end) You may add `contain:` before the file path in `wallpaper=` to set the mode to contain instead of cover: @@ -84,9 +114,9 @@ *~/.config/hypr/hyprland.conf* ``` -$w1 = hyprctl hyprpaper wallpaper "DP-1,~/Pictures/myepicpng.png" -$w2 = hyprctl hyprpaper wallpaper "DP-1,~/Pictures/myepicpngToo.png" -$w3 = hyprctl hyprpaper wallpaper "DP-1,~/Pictures/myepicpngAlso.png" +$w1 = hyprctl hyprpaper wallpaper "DP-1,~/Pictures/myepicpng.png" +$w2 = hyprctl hyprpaper wallpaper "DP-1,~/Pictures/myepicpngToo.png" +$w3 = hyprctl hyprpaper wallpaper "DP-1,~/Pictures/myepicpngAlso.png" #yes use quotes around desired monitor and wallpaper #... continued with desired amount ``` @@ -105,7 +135,7 @@ bind=SUPER,3,workspace,3 #Superkey + 3 switches to workspace 3 bind=SUPER,3,exec,$w3 #SuperKey + 3 switches to wallpaper $w3 on DP-1 as defined in the variable -#... and so on +#... and so on ``` Because the default behavior in Hyprland is to also switch the workspace whenever movetoworkspace is used to move a window to another workspace you may want to include the following: @@ -124,6 +154,8 @@ # Misc You can set `splash = true` to enable the splash rendering over the wallpaper. +The value for `splash_offset` sets, in percentage, the splash rendering offset relative to the bottom of the display. + ## Unloading If you use a lot of wallpapers, consider unloading those that you no longer need. This will mean you need to load them again if you wish to use them for a second time, but will free the memory used by the preloaded bitmap. (Usually 8 - 20MB, depending on the resolution) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hyprpaper-0.4.0/flake.lock new/hyprpaper-0.6.0/flake.lock --- old/hyprpaper-0.4.0/flake.lock 2023-08-03 13:00:55.000000000 +0200 +++ new/hyprpaper-0.6.0/flake.lock 2024-01-02 22:22:34.000000000 +0100 @@ -1,12 +1,46 @@ { "nodes": { + "hyprlang": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1704230242, + "narHash": "sha256-S8DM+frECqmAdaUb3y5n3RjY73ajZcL5rnmx5YO+CkY=", + "owner": "hyprwm", + "repo": "hyprlang", + "rev": "db5e1399b90d5a339330bdd49c5bca6fe58d6f60", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprlang", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1683014792, - "narHash": "sha256-6Va9iVtmmsw4raBc3QKvQT2KT/NGRWlvUlJj46zN8B8=", + "lastModified": 1702645756, + "narHash": "sha256-qKI6OR3TYJYQB3Q8mAZ+DG4o/BR9ptcv9UnRV2hzljc=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "40c3c94c241286dd2243ea34d3aef8a488f9e4d0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1703637592, + "narHash": "sha256-8MXjxU0RfFfzl57Zy3OfXCITS0qWDNLzlBAdwxGZwfY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1a411f23ba299db155a5b45d5e145b85a7aafc42", + "rev": "cfc3698c31b1fb9cdcf10f36c9643460264d0ca8", "type": "github" }, "original": { @@ -18,7 +52,8 @@ }, "root": { "inputs": { - "nixpkgs": "nixpkgs" + "hyprlang": "hyprlang", + "nixpkgs": "nixpkgs_2" } } }, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hyprpaper-0.4.0/flake.nix new/hyprpaper-0.6.0/flake.nix --- old/hyprpaper-0.4.0/flake.nix 2023-08-03 13:00:55.000000000 +0200 +++ new/hyprpaper-0.6.0/flake.nix 2024-01-02 22:22:34.000000000 +0100 @@ -1,13 +1,17 @@ { description = "Hyprpaper is a blazing fast Wayland wallpaper utility with IPC controls"; - inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + hyprlang.url = "github:hyprwm/hyprlang"; + }; outputs = { self, nixpkgs, ... - }: let + } @ inputs: let inherit (nixpkgs) lib; genSystems = lib.genAttrs [ # Add more systems if they are supported @@ -23,9 +27,10 @@ in { overlays.default = _: prev: rec { hyprpaper = prev.callPackage ./nix/default.nix { - stdenv = prev.gcc12Stdenv; + stdenv = prev.gcc13Stdenv; version = "0.pre" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty"); inherit (prev.xorg) libXdmcp; + inherit (inputs.hyprlang.packages.${prev.system}) hyprlang; }; hyprpaper-debug = hyprpaper.override {debug = true;}; }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hyprpaper-0.4.0/nix/default.nix new/hyprpaper-0.6.0/nix/default.nix --- old/hyprpaper-0.4.0/nix/default.nix 2023-08-03 13:00:55.000000000 +0200 +++ new/hyprpaper-0.6.0/nix/default.nix 2024-01-02 22:22:34.000000000 +0100 @@ -5,15 +5,20 @@ cmake, ninja, cairo, + expat, file, fribidi, + hyprlang, libdatrie, + libGL, libjpeg, libselinux, libsepol, libthai, + libwebp, pango, pcre, + pcre2, util-linux, wayland, wayland-protocols, @@ -35,15 +40,20 @@ buildInputs = [ cairo + expat file fribidi + hyprlang libdatrie + libGL libjpeg libselinux libsepol libthai + libwebp pango pcre + pcre2 wayland wayland-protocols wayland-scanner diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hyprpaper-0.4.0/src/Hyprpaper.cpp new/hyprpaper-0.6.0/src/Hyprpaper.cpp --- old/hyprpaper-0.4.0/src/Hyprpaper.cpp 2023-08-03 13:00:55.000000000 +0200 +++ new/hyprpaper-0.6.0/src/Hyprpaper.cpp 2024-01-02 22:22:34.000000000 +0100 @@ -1,8 +1,8 @@ #include "Hyprpaper.hpp" #include <filesystem> #include <fstream> -#include <sys/types.h> #include <signal.h> +#include <sys/types.h> CHyprpaper::CHyprpaper() = default; @@ -18,6 +18,8 @@ g_pConfigManager = std::make_unique<CConfigManager>(); g_pIPCSocket = std::make_unique<CIPCSocket>(); + g_pConfigManager->parse(); + m_sDisplay = (wl_display*)wl_display_connect(nullptr); if (!m_sDisplay) { @@ -27,7 +29,7 @@ preloadAllWallpapersFromConfig(); - if (m_bIPCEnabled) + if (std::any_cast<Hyprlang::INT>(g_pConfigManager->config->getConfigValue("ipc"))) g_pIPCSocket->initialize(); // run @@ -123,11 +125,12 @@ m_mWallpaperTargets[wp] = CWallpaperTarget(); if (std::filesystem::is_symlink(wp)) { auto real_wp = std::filesystem::read_symlink(wp); - m_mWallpaperTargets[wp].create(real_wp); + std::filesystem::path absolute_path = std::filesystem::path(wp).parent_path() / real_wp; + absolute_path = absolute_path.lexically_normal(); + m_mWallpaperTargets[wp].create(absolute_path); } else { m_mWallpaperTargets[wp].create(wp); } - } g_pConfigManager->m_dRequestedPreloads.clear(); @@ -448,6 +451,8 @@ } void CHyprpaper::renderWallpaperForMonitor(SMonitor* pMonitor) { + static auto* const PRENDERSPLASH = reinterpret_cast<Hyprlang::INT* const*>(g_pConfigManager->config->getConfigValuePtr("splash")->getDataStaticPtr()); + static auto* const PSPLASHOFFSET = reinterpret_cast<Hyprlang::FLOAT* const*>(g_pConfigManager->config->getConfigValuePtr("splash_offset")->getDataStaticPtr()); const auto PWALLPAPERTARGET = m_mMonitorActiveWallpaperTargets[pMonitor]; const auto CONTAIN = m_mMonitorWallpaperRenderData[pMonitor->name].contain; @@ -479,41 +484,24 @@ cairo_paint(PCAIRO); cairo_restore(PCAIRO); - if (CONTAIN) { - cairo_set_source_rgb(PCAIRO, 0, 0, 0); - cairo_rectangle(PCAIRO, 0, 0, DIMENSIONS.x, DIMENSIONS.y); - - cairo_fill(PCAIRO); - - cairo_surface_flush(PBUFFER->surface); - } + // always draw a black background behind the wallpaper + cairo_set_source_rgb(PCAIRO, 0, 0, 0); + cairo_rectangle(PCAIRO, 0, 0, DIMENSIONS.x, DIMENSIONS.y); + cairo_fill(PCAIRO); + cairo_surface_flush(PBUFFER->surface); // get scale // we always do cover - float scale; + double scale; Vector2D origin; - if (!CONTAIN) { - if (pMonitor->size.x / pMonitor->size.y > PWALLPAPERTARGET->m_vSize.x / PWALLPAPERTARGET->m_vSize.y) { - scale = DIMENSIONS.x / PWALLPAPERTARGET->m_vSize.x; - - origin.y = -(PWALLPAPERTARGET->m_vSize.y * scale - DIMENSIONS.y) / 2.f / scale; - - } else { - scale = DIMENSIONS.y / PWALLPAPERTARGET->m_vSize.y; - - origin.x = -(PWALLPAPERTARGET->m_vSize.x * scale - DIMENSIONS.x) / 2.f / scale; - } + const bool LOWASPECTRATIO = pMonitor->size.x / pMonitor->size.y > PWALLPAPERTARGET->m_vSize.x / PWALLPAPERTARGET->m_vSize.y; + if ((CONTAIN && !LOWASPECTRATIO) || (!CONTAIN && LOWASPECTRATIO)) { + scale = DIMENSIONS.x / PWALLPAPERTARGET->m_vSize.x; + origin.y = -(PWALLPAPERTARGET->m_vSize.y * scale - DIMENSIONS.y) / 2.0 / scale; } else { - if (pMonitor->size.x / pMonitor->size.y > PWALLPAPERTARGET->m_vSize.x / PWALLPAPERTARGET->m_vSize.y) { - scale = (DIMENSIONS.y) / PWALLPAPERTARGET->m_vSize.y; - - origin.x = (DIMENSIONS.x - PWALLPAPERTARGET->m_vSize.x * scale) / 2.0 / scale; - } else { - scale = (DIMENSIONS.x) / PWALLPAPERTARGET->m_vSize.x; - - origin.y = (DIMENSIONS.y - PWALLPAPERTARGET->m_vSize.y * scale) / 2.0 / scale; - } + scale = DIMENSIONS.y / PWALLPAPERTARGET->m_vSize.y; + origin.x = -(PWALLPAPERTARGET->m_vSize.x * scale - DIMENSIONS.x) / 2.0 / scale; } Debug::log(LOG, "Image data for %s: %s at [%.2f, %.2f], scale: %.2f (original image size: [%i, %i])", pMonitor->name.c_str(), PWALLPAPERTARGET->m_szPath.c_str(), origin.x, origin.y, scale, (int)PWALLPAPERTARGET->m_vSize.x, (int)PWALLPAPERTARGET->m_vSize.y); @@ -523,7 +511,7 @@ cairo_paint(PCAIRO); - if (g_pHyprpaper->m_bRenderSplash && getenv("HYPRLAND_INSTANCE_SIGNATURE")) { + if (**PRENDERSPLASH && getenv("HYPRLAND_INSTANCE_SIGNATURE")) { auto SPLASH = execAndGet("hyprctl splash"); SPLASH.pop_back(); @@ -539,9 +527,9 @@ cairo_text_extents_t textExtents; cairo_text_extents(PCAIRO, SPLASH.c_str(), &textExtents); - cairo_move_to(PCAIRO, ((DIMENSIONS.x - textExtents.width * scale) / 2.0) / scale, (DIMENSIONS.y * 0.99 - textExtents.height * scale) / scale); + cairo_move_to(PCAIRO, ((DIMENSIONS.x - textExtents.width * scale) / 2.0) / scale, ((DIMENSIONS.y * (100 - **PSPLASHOFFSET)) / 100 - textExtents.height * scale) / scale); - Debug::log(LOG, "Splash font size: %d, pos: %.2f, %.2f", FONTSIZE, (DIMENSIONS.x - textExtents.width) / 2.0 / scale, DIMENSIONS.y * 0.95 - textExtents.height / scale); + Debug::log(LOG, "Splash font size: %d, pos: %.2f, %.2f", FONTSIZE, (DIMENSIONS.x - textExtents.width) / 2.0 / scale, ((DIMENSIONS.y * (100 - **PSPLASHOFFSET)) / 100 - textExtents.height * scale) / scale); cairo_show_text(PCAIRO, SPLASH.c_str()); @@ -554,11 +542,19 @@ wl_surface_attach(pMonitor->pCurrentLayerSurface->pSurface, PBUFFER->buffer, 0, 0); wl_surface_set_buffer_scale(pMonitor->pCurrentLayerSurface->pSurface, pMonitor->pCurrentLayerSurface->pFractionalScaleInfo ? 1 : pMonitor->scale); wl_surface_damage_buffer(pMonitor->pCurrentLayerSurface->pSurface, 0, 0, 0xFFFF, 0xFFFF); + + // our wps are always opaque + auto opaqueRegion = wl_compositor_create_region(g_pHyprpaper->m_sCompositor); + wl_region_add(opaqueRegion, 0, 0, PBUFFER->pixelSize.x, PBUFFER->pixelSize.y); + wl_surface_set_opaque_region(pMonitor->pCurrentLayerSurface->pSurface, opaqueRegion); + if (pMonitor->pCurrentLayerSurface->pFractionalScaleInfo) { Debug::log(LOG, "Submitting viewport dest size %ix%i for %x", static_cast<int>(std::round(pMonitor->size.x)), static_cast<int>(std::round(pMonitor->size.y)), pMonitor->pCurrentLayerSurface); wp_viewport_set_destination(pMonitor->pCurrentLayerSurface->pViewport, static_cast<int>(std::round(pMonitor->size.x)), static_cast<int>(std::round(pMonitor->size.y))); } wl_surface_commit(pMonitor->pCurrentLayerSurface->pSurface); + + wl_region_destroy(opaqueRegion); } // check if we dont need to remove a wallpaper diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hyprpaper-0.4.0/src/Hyprpaper.hpp new/hyprpaper-0.6.0/src/Hyprpaper.hpp --- old/hyprpaper-0.4.0/src/Hyprpaper.hpp 2023-08-03 13:00:55.000000000 +0200 +++ new/hyprpaper-0.6.0/src/Hyprpaper.hpp 2024-01-02 22:22:34.000000000 +0100 @@ -1,13 +1,13 @@ #pragma once -#include "defines.hpp" #include "config/ConfigManager.hpp" -#include "render/WallpaperTarget.hpp" -#include "helpers/Monitor.hpp" +#include "defines.hpp" #include "events/Events.hpp" -#include "helpers/PoolBuffer.hpp" #include "helpers/MiscFunctions.hpp" +#include "helpers/Monitor.hpp" +#include "helpers/PoolBuffer.hpp" #include "ipc/Socket.hpp" +#include "render/WallpaperTarget.hpp" #include <mutex> struct SWallpaperRenderData { @@ -17,17 +17,17 @@ class CHyprpaper { public: // important - wl_display* m_sDisplay; // assured - wl_compositor* m_sCompositor; // assured - wl_shm* m_sSHM; // assured - zwlr_layer_shell_v1* m_sLayerShell = nullptr; // expected + 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 + wp_viewporter* m_sViewporter = nullptr; // expected // init the utility CHyprpaper(); - void init(); - void tick(bool force); + void init(); + void tick(bool force); std::unordered_map<std::string, CWallpaperTarget> m_mWallpaperTargets; std::unordered_map<std::string, std::string> m_mMonitorActiveWallpapers; @@ -36,38 +36,36 @@ std::vector<std::unique_ptr<SPoolBuffer>> m_vBuffers; std::vector<std::unique_ptr<SMonitor>> m_vMonitors; - bool m_bIPCEnabled = true; - bool m_bRenderSplash = false; std::string m_szExplicitConfigPath; - bool m_bNoFractionalScale = false; + bool m_bNoFractionalScale = false; - 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(); + 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(wl_seat*); - bool lockSingleInstance(); // fails on multi-instance - void unlockSingleInstance(); + void unloadWallpaper(const std::string&); + void createSeat(wl_seat*); + bool lockSingleInstance(); // fails on multi-instance + void unlockSingleInstance(); + + std::mutex m_mtTickMutex; - std::mutex m_mtTickMutex; + SMonitor* m_pLastMonitor = nullptr; - SMonitor* m_pLastMonitor = nullptr; private: - - bool m_bShouldExit = false; + bool m_bShouldExit = false; }; inline std::unique_ptr<CHyprpaper> g_pHyprpaper; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hyprpaper-0.4.0/src/config/ConfigManager.cpp new/hyprpaper-0.6.0/src/config/ConfigManager.cpp --- old/hyprpaper-0.4.0/src/config/ConfigManager.cpp 2023-08-03 13:00:55.000000000 +0200 +++ new/hyprpaper-0.6.0/src/config/ConfigManager.cpp 2024-01-02 22:22:34.000000000 +0100 @@ -1,130 +1,18 @@ #include "ConfigManager.hpp" #include "../Hyprpaper.hpp" -CConfigManager::CConfigManager() { - // Initialize the configuration - // Read file from default location - // or from an explicit location given by user - - std::string configPath = getMainConfigPath(); - - std::ifstream ifs; - ifs.open(configPath); - - if (!ifs.good()) { - Debug::log(CRIT, "Config file `%s` couldn't be opened.", configPath.c_str()); - exit(1); - } - - std::string line = ""; - int linenum = 1; - if (ifs.is_open()) { - while (std::getline(ifs, line)) { - // Read line by line - try { - parseLine(line); - } catch (...) { - Debug::log(ERR, "Error reading line from config. Line:"); - Debug::log(NONE, "%s", line.c_str()); - - parseError += "Config error at line " + std::to_string(linenum) + ": Line parsing error."; - } - - if (!parseError.empty()) { - parseError = "Config error at line " + std::to_string(linenum) + ": " + parseError; - break; - } - - ++linenum; - } - - ifs.close(); - } - - if (!parseError.empty()) { - Debug::log(CRIT, "Exiting because of config parse errors!\n%s", parseError.c_str()); - exit(1); - return; - } -} - -std::string CConfigManager::getMainConfigPath() { - if (!g_pHyprpaper->m_szExplicitConfigPath.empty()) - return g_pHyprpaper->m_szExplicitConfigPath; - - static const char* xdgConfigHome = getenv("XDG_CONFIG_HOME"); - std::string configPath; - if (!xdgConfigHome) - configPath = getenv("HOME") + std::string("/.config"); - else - configPath = xdgConfigHome; - - return configPath + "/hypr/hyprpaper.conf"; -} - -std::string CConfigManager::removeBeginEndSpacesTabs(std::string str) { - while (str[0] == ' ' || str[0] == '\t') { - str = str.substr(1); - } - - while (str.length() != 0 && (str[str.length() - 1] == ' ' || str[str.length() - 1] == '\t')) { - str = str.substr(0, str.length() - 1); - } - - return str; -} - -void CConfigManager::parseLine(std::string& line) { - // first check if its not a comment - const auto COMMENTSTART = line.find_first_of('#'); - if (COMMENTSTART == 0) - return; +static Hyprlang::CParseResult handleWallpaper(const char* C, const char* V) { + const std::string COMMAND = C; + const std::string VALUE = V; + Hyprlang::CParseResult result; - // now, cut the comment off - if (COMMENTSTART != std::string::npos) - line = line.substr(0, COMMENTSTART); - - // Strip line - while (line[0] == ' ' || line[0] == '\t') { - line = line.substr(1); - } - - // And parse - // check if command - const auto EQUALSPLACE = line.find_first_of('='); - - if (EQUALSPLACE == std::string::npos) - return; - - const auto COMMAND = removeBeginEndSpacesTabs(line.substr(0, EQUALSPLACE)); - const auto VALUE = removeBeginEndSpacesTabs(line.substr(EQUALSPLACE + 1)); - - parseKeyword(COMMAND, VALUE); -} - -void CConfigManager::parseKeyword(const std::string& COMMAND, const std::string& VALUE) { - if (COMMAND == "wallpaper") - handleWallpaper(COMMAND, VALUE); - else if (COMMAND == "preload") - handlePreload(COMMAND, VALUE); - else if (COMMAND == "unload") - handleUnload(COMMAND, VALUE); - else if (COMMAND == "ipc") - g_pHyprpaper->m_bIPCEnabled = VALUE == "1" || VALUE == "yes" || VALUE == "on" || VALUE == "true"; - else if (COMMAND == "splash") - g_pHyprpaper->m_bRenderSplash = VALUE == "1" || VALUE == "yes" || VALUE == "on" || VALUE == "true"; - else - parseError = "unknown keyword " + COMMAND; -} - -void CConfigManager::handleWallpaper(const std::string& COMMAND, const std::string& VALUE) { if (VALUE.find_first_of(',') == std::string::npos) { - parseError = "wallpaper failed (syntax)"; - return; + result.setError("wallpaper failed (syntax)"); + return result; } auto MONITOR = VALUE.substr(0, VALUE.find_first_of(',')); - auto WALLPAPER = trimPath(VALUE.substr(VALUE.find_first_of(',') + 1)); + auto WALLPAPER = g_pConfigManager->trimPath(VALUE.substr(VALUE.find_first_of(',') + 1)); bool contain = false; @@ -139,21 +27,25 @@ } if (!std::filesystem::exists(WALLPAPER)) { - parseError = "wallpaper failed (no such file)"; - return; + result.setError("wallpaper failed (no such file)"); + return result; } - if (std::find(m_dRequestedPreloads.begin(), m_dRequestedPreloads.end(), WALLPAPER) == m_dRequestedPreloads.end() && !g_pHyprpaper->isPreloaded(WALLPAPER)) { - parseError = "wallpaper failed (not preloaded)"; - return; + if (std::find(g_pConfigManager->m_dRequestedPreloads.begin(), g_pConfigManager->m_dRequestedPreloads.end(), WALLPAPER) == g_pConfigManager->m_dRequestedPreloads.end() && !g_pHyprpaper->isPreloaded(WALLPAPER)) { + result.setError("wallpaper failed (not preloaded)"); + return result; } g_pHyprpaper->clearWallpaperFromMonitor(MONITOR); g_pHyprpaper->m_mMonitorActiveWallpapers[MONITOR] = WALLPAPER; g_pHyprpaper->m_mMonitorWallpaperRenderData[MONITOR].contain = contain; + + return result; } -void CConfigManager::handlePreload(const std::string& COMMAND, const std::string& VALUE) { +static Hyprlang::CParseResult handlePreload(const char* C, const char* V) { + const std::string COMMAND = C; + const std::string VALUE = V; auto WALLPAPER = VALUE; if (WALLPAPER[0] == '~') { @@ -162,30 +54,19 @@ } if (!std::filesystem::exists(WALLPAPER)) { - parseError = "preload failed (no such file)"; - return; + Hyprlang::CParseResult result; + result.setError((std::string{"no such file: "} + WALLPAPER).c_str()); + return result; } - m_dRequestedPreloads.emplace_back(WALLPAPER); -} + g_pConfigManager->m_dRequestedPreloads.emplace_back(WALLPAPER); -void CConfigManager::handleUnload(const std::string& COMMAND, const std::string& VALUE) { - auto WALLPAPER = VALUE; - - if (VALUE == "all") { - handleUnloadAll(COMMAND, VALUE); - return; - } - - if (WALLPAPER[0] == '~') { - static const char* const ENVHOME = getenv("HOME"); - WALLPAPER = std::string(ENVHOME) + WALLPAPER.substr(1); - } - - g_pHyprpaper->unloadWallpaper(WALLPAPER); + return Hyprlang::CParseResult{}; } -void CConfigManager::handleUnloadAll(const std::string& COMMAND, const std::string& VALUE) { +static Hyprlang::CParseResult handleUnloadAll(const char* C, const char* V) { + const std::string COMMAND = C; + const std::string VALUE = V; std::vector<std::string> toUnload; for (auto& [name, target] : g_pHyprpaper->m_mWallpaperTargets) { @@ -206,10 +87,76 @@ for (auto& tu : toUnload) g_pHyprpaper->unloadWallpaper(tu); + + return Hyprlang::CParseResult{}; +} + +static Hyprlang::CParseResult handleUnload(const char* C, const char* V) { + const std::string COMMAND = C; + const std::string VALUE = V; + auto WALLPAPER = VALUE; + + if (VALUE == "all") + return handleUnloadAll(C, V); + + if (WALLPAPER[0] == '~') { + static const char* const ENVHOME = getenv("HOME"); + WALLPAPER = std::string(ENVHOME) + WALLPAPER.substr(1); + } + + g_pHyprpaper->unloadWallpaper(WALLPAPER); + + return Hyprlang::CParseResult{}; +} + +CConfigManager::CConfigManager() { + // Initialize the configuration + // Read file from default location + // or from an explicit location given by user + + std::string configPath = getMainConfigPath(); + + config = std::make_unique<Hyprlang::CConfig>(configPath.c_str(), Hyprlang::SConfigOptions{.allowMissingConfig = true}); + + config->addConfigValue("ipc", {1L}); + config->addConfigValue("splash", {1L}); + config->addConfigValue("splash_offset", {2.F}); + + config->registerHandler(&handleWallpaper, "wallpaper", {.allowFlags = false}); + config->registerHandler(&handleUnload, "unload", {.allowFlags = false}); + config->registerHandler(&handlePreload, "preload", {.allowFlags = false}); + config->registerHandler(&handleUnloadAll, "unloadAll", {.allowFlags = false}); + + config->commence(); +} + +void CConfigManager::parse() { + const auto ERROR = config->parse(); + + if (ERROR.error) + std::cout << "Error in config: \n" + << ERROR.getError() << "\n"; +} + +std::string CConfigManager::getMainConfigPath() { + if (!g_pHyprpaper->m_szExplicitConfigPath.empty()) + return g_pHyprpaper->m_szExplicitConfigPath; + + static const char* xdgConfigHome = getenv("XDG_CONFIG_HOME"); + std::string configPath; + if (!xdgConfigHome) + configPath = getenv("HOME") + std::string("/.config"); + else + configPath = xdgConfigHome; + + return configPath + "/hypr/hyprpaper.conf"; } // trim from both ends std::string CConfigManager::trimPath(std::string path) { + if (path.empty()) + return ""; + // trims whitespaces, tabs and new line feeds size_t pathStartIndex = path.find_first_not_of(" \t\r\n"); size_t pathEndIndex = path.find_last_not_of(" \t\r\n"); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hyprpaper-0.4.0/src/config/ConfigManager.hpp new/hyprpaper-0.6.0/src/config/ConfigManager.hpp --- old/hyprpaper-0.4.0/src/config/ConfigManager.hpp 2023-08-03 13:00:55.000000000 +0200 +++ new/hyprpaper-0.6.0/src/config/ConfigManager.hpp 2024-01-02 22:22:34.000000000 +0100 @@ -1,5 +1,6 @@ #pragma once #include "../defines.hpp" +#include <hyprlang.hpp> class CIPCSocket; @@ -7,23 +8,15 @@ public: // gets all the data from the config CConfigManager(); + void parse(); std::deque<std::string> m_dRequestedPreloads; std::string getMainConfigPath(); - -private: - std::string parseError; - - void parseLine(std::string&); - std::string removeBeginEndSpacesTabs(std::string in); - void parseKeyword(const std::string&, const std::string&); - - void handleWallpaper(const std::string&, const std::string&); - void handlePreload(const std::string&, const std::string&); - void handleUnload(const std::string&, const std::string&); - void handleUnloadAll(const std::string&, const std::string&); std::string trimPath(std::string path); + std::unique_ptr<Hyprlang::CConfig> config; + +private: friend class CIPCSocket; }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hyprpaper-0.4.0/src/helpers/Jpeg.cpp new/hyprpaper-0.6.0/src/helpers/Jpeg.cpp --- old/hyprpaper-0.4.0/src/helpers/Jpeg.cpp 2023-08-03 13:00:55.000000000 +0200 +++ new/hyprpaper-0.6.0/src/helpers/Jpeg.cpp 2024-01-02 22:22:34.000000000 +0100 @@ -4,10 +4,6 @@ #include <sys/types.h> #include <unistd.h> -#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__ -#error "your system is not little endian, jpeg will not work, ping vaxry or something" -#endif - cairo_surface_t* JPEG::createSurfaceFromJPEG(const std::string& path) { if (!std::filesystem::exists(path)) { @@ -44,7 +40,11 @@ jpeg_mem_src(&decompressStruct, (const unsigned char*)imageRawData, fileInfo.st_size); jpeg_read_header(&decompressStruct, true); +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ decompressStruct.out_color_space = JCS_EXT_BGRA; +#else + decompressStruct.out_color_space = JCS_EXT_ARGB; +#endif // decompress jpeg_start_decompress(&decompressStruct); @@ -69,7 +69,7 @@ cairo_surface_mark_dirty(cairoSurface); cairo_surface_set_mime_data(cairoSurface, CAIRO_MIME_TYPE_JPEG, (const unsigned char*)imageRawData, fileInfo.st_size, free, imageRawData); jpeg_finish_decompress(&decompressStruct); - jpeg_destroy_decompress(&decompressStruct); + jpeg_destroy_decompress(&decompressStruct); return cairoSurface; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hyprpaper-0.4.0/src/helpers/Webp.cpp new/hyprpaper-0.6.0/src/helpers/Webp.cpp --- old/hyprpaper-0.4.0/src/helpers/Webp.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/hyprpaper-0.6.0/src/helpers/Webp.cpp 2024-01-02 22:22:34.000000000 +0100 @@ -0,0 +1,84 @@ +#include "Webp.hpp" + +#include <sys/stat.h> +#include <sys/types.h> +#include <unistd.h> + +#include <webp/decode.h> + +cairo_surface_t* WEBP::createSurfaceFromWEBP(const std::string& path) { + + if (!std::filesystem::exists(path)) { + Debug::log(ERR, "createSurfaceFromWEBP: file doesn't exist??"); + exit(1); + } + + void* imageRawData; + + struct stat fileInfo = {}; + + const auto FD = open(path.c_str(), O_RDONLY); + + fstat(FD, &fileInfo); + + imageRawData = malloc(fileInfo.st_size); + + read(FD, imageRawData, fileInfo.st_size); + + close(FD); + + // now the WebP is in the memory + + WebPDecoderConfig config; + if (!WebPInitDecoderConfig(&config)) { + Debug::log(CRIT, "WebPInitDecoderConfig Failed"); + exit(1); + } + + if (WebPGetFeatures((const unsigned char*)imageRawData, fileInfo.st_size, &config.input) != VP8_STATUS_OK) { + Debug::log(ERR, "createSurfaceFromWEBP: file is not webp format"); + free(imageRawData); + exit(1); + } + + const auto HEIGHT = config.input.height; + const auto WIDTH = config.input.width; + + auto cairoSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT); + if (cairo_surface_status(cairoSurface) != CAIRO_STATUS_SUCCESS) { + Debug::log(CRIT, "createSurfaceFromWEBP: Cairo Failed (?)"); + cairo_surface_destroy(cairoSurface); + exit(1); + } + + +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + config.output.colorspace = MODE_bgrA; +#else + config.output.colorspace = MODE_Argb; +#endif + + const auto CAIRODATA = cairo_image_surface_get_data(cairoSurface); + const auto CAIROSTRIDE = cairo_image_surface_get_stride(cairoSurface); + + config.options.no_fancy_upsampling = 1; + config.output.u.RGBA.rgba = CAIRODATA; + config.output.u.RGBA.stride = CAIROSTRIDE; + config.output.u.RGBA.size = CAIROSTRIDE * HEIGHT; + config.output.is_external_memory = 1; + config.output.width = WIDTH; + config.output.height = HEIGHT; + + if (WebPDecode((const unsigned char*)imageRawData, fileInfo.st_size, &config) != VP8_STATUS_OK) { + Debug::log(CRIT, "createSurfaceFromWEBP: WebP Decode Failed (?)"); + exit(1); + } + + cairo_surface_mark_dirty(cairoSurface); + cairo_surface_set_mime_data(cairoSurface, CAIRO_MIME_TYPE_PNG, (const unsigned char*)imageRawData, fileInfo.st_size, free, imageRawData); + + WebPFreeDecBuffer(&config.output); + + return cairoSurface; + +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hyprpaper-0.4.0/src/helpers/Webp.hpp new/hyprpaper-0.6.0/src/helpers/Webp.hpp --- old/hyprpaper-0.4.0/src/helpers/Webp.hpp 1970-01-01 01:00:00.000000000 +0100 +++ new/hyprpaper-0.6.0/src/helpers/Webp.hpp 2024-01-02 22:22:34.000000000 +0100 @@ -0,0 +1,7 @@ +#pragma once + +#include "../defines.hpp" + +namespace WEBP { + cairo_surface_t* createSurfaceFromWEBP(const std::string&); +}; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hyprpaper-0.4.0/src/includes.hpp new/hyprpaper-0.6.0/src/includes.hpp --- old/hyprpaper-0.4.0/src/includes.hpp 2023-08-03 13:00:55.000000000 +0200 +++ new/hyprpaper-0.6.0/src/includes.hpp 2024-01-02 22:22:34.000000000 +0100 @@ -9,7 +9,6 @@ #include <pthread.h> #include <cmath> -#include <cmath> #define class _class #define namespace _namespace diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hyprpaper-0.4.0/src/ipc/Socket.cpp new/hyprpaper-0.6.0/src/ipc/Socket.cpp --- old/hyprpaper-0.4.0/src/ipc/Socket.cpp 2023-08-03 13:00:55.000000000 +0200 +++ new/hyprpaper-0.6.0/src/ipc/Socket.cpp 2024-01-02 22:22:34.000000000 +0100 @@ -1,19 +1,19 @@ #include "Socket.hpp" #include "../Hyprpaper.hpp" -#include <netinet/in.h> +#include <cerrno> #include <cstdio> #include <cstdlib> #include <cstring> +#include <netinet/in.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/types.h> #include <sys/un.h> #include <unistd.h> -#include <cerrno> void CIPCSocket::initialize() { - std::thread([&]() { + std::thread([&]() { const auto SOCKET = socket(AF_UNIX, SOCK_STREAM, 0); if (SOCKET < 0) { @@ -46,42 +46,37 @@ char readBuffer[1024] = {0}; Debug::log(LOG, "hyprpaper socket started at %s (fd: %i)", socketPath.c_str(), SOCKET); - - while(1) { + while (1) { const auto ACCEPTEDCONNECTION = accept(SOCKET, (sockaddr*)&clientAddress, &clientSize); - - Debug::log(LOG, "Accepted incoming socket connection request on fd %i", ACCEPTEDCONNECTION); - if (ACCEPTEDCONNECTION < 0) { Debug::log(ERR, "Couldn't listen on the hyprpaper Socket. (3) IPC will not work."); break; + } else { + do { + Debug::log(LOG, "Accepted incoming socket connection request on fd %i", ACCEPTEDCONNECTION); + std::lock_guard<std::mutex> lg(g_pHyprpaper->m_mtTickMutex); + + auto messageSize = read(ACCEPTEDCONNECTION, readBuffer, 1024); + readBuffer[messageSize == 1024 ? 1023 : messageSize] = '\0'; + if (messageSize == 0) + break; + std::string request(readBuffer); + + m_szRequest = request; + m_bRequestReady = true; + + g_pHyprpaper->tick(true); + while (!m_bReplyReady) { // wait for Hyprpaper to finish processing the request + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + } + write(ACCEPTEDCONNECTION, m_szReply.c_str(), m_szReply.length()); + m_bReplyReady = false; + m_szReply = ""; + + } while (1); + Debug::log(LOG, "Closing Accepted Connection"); + close(ACCEPTEDCONNECTION); } - - std::lock_guard<std::mutex> lg(g_pHyprpaper->m_mtTickMutex); - - auto messageSize = read(ACCEPTEDCONNECTION, readBuffer, 1024); - readBuffer[messageSize == 1024 ? 1023 : messageSize] = '\0'; - - std::string request(readBuffer); - - m_szRequest = request; - m_bRequestReady = true; - - g_pHyprpaper->tick(true); - - while (1) { - if (m_bReplyReady) - break; - - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } - - write(ACCEPTEDCONNECTION, m_szReply.c_str(), m_szReply.length()); - - close(ACCEPTEDCONNECTION); - - m_bReplyReady = false; - m_szReply = ""; } close(SOCKET); @@ -89,7 +84,7 @@ } bool CIPCSocket::mainThreadParseRequest() { - + if (!m_bRequestReady) return false; @@ -104,18 +99,16 @@ // parse if (copy.find("wallpaper") == 0 || copy.find("preload") == 0 || copy.find("unload") == 0) { - g_pConfigManager->parseError = ""; // reset parse error - g_pConfigManager->parseKeyword(copy.substr(0, copy.find_first_of(' ')), copy.substr(copy.find_first_of(' ') + 1)); + const auto RESULT = g_pConfigManager->config->parseDynamic(copy.substr(0, copy.find_first_of(' ')).c_str(), copy.substr(copy.find_first_of(' ') + 1).c_str()); - if (!g_pConfigManager->parseError.empty()) { - m_szReply = g_pConfigManager->parseError; + if (RESULT.error) { + m_szReply = RESULT.getError(); m_bReplyReady = true; m_bRequestReady = false; return false; } - } - else { + } else { m_szReply = "invalid command"; m_bReplyReady = true; m_bRequestReady = false; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hyprpaper-0.4.0/src/render/WallpaperTarget.cpp new/hyprpaper-0.6.0/src/render/WallpaperTarget.cpp --- old/hyprpaper-0.4.0/src/render/WallpaperTarget.cpp 2023-08-03 13:00:55.000000000 +0200 +++ new/hyprpaper-0.6.0/src/render/WallpaperTarget.cpp 2024-01-02 22:22:34.000000000 +0100 @@ -18,6 +18,8 @@ } else if (path.find(".jpg") == len - 4 || path.find(".JPG") == len - 4 || path.find(".jpeg") == len - 5 || path.find(".JPEG") == len - 5) { CAIROSURFACE = JPEG::createSurfaceFromJPEG(path); m_bHasAlpha = false; + } else if (path.find(".webp") == len - 5 || path.find(".WEBP") == len - 5) { + CAIROSURFACE = WEBP::createSurfaceFromWEBP(path); } else { // magic is slow, so only use it when no recognized extension is found auto handle = magic_open(MAGIC_NONE|MAGIC_COMPRESS); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hyprpaper-0.4.0/src/render/WallpaperTarget.hpp new/hyprpaper-0.6.0/src/render/WallpaperTarget.hpp --- old/hyprpaper-0.4.0/src/render/WallpaperTarget.hpp 2023-08-03 13:00:55.000000000 +0200 +++ new/hyprpaper-0.6.0/src/render/WallpaperTarget.hpp 2024-01-02 22:22:34.000000000 +0100 @@ -2,12 +2,13 @@ #include "../defines.hpp" #include "../helpers/Jpeg.hpp" +#include "../helpers/Webp.hpp" class CWallpaperTarget { public: ~CWallpaperTarget(); - + void create(const std::string& path); std::string m_szPath;