diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a5bee3..d1ed1be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,7 @@ add_subdirectory(hyprland-share-picker) find_package(Threads REQUIRED) find_package(PkgConfig REQUIRED) -pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols libpipewire-0.3 libspa-0.2 libdrm gbm) +pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols libpipewire-0.3 libspa-0.2 libdrm gbm hyprlang>=0.2.0) file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp") add_executable(xdg-desktop-portal-hyprland ${SRCFILES}) diff --git a/src/core/PortalManager.cpp b/src/core/PortalManager.cpp index 9e4abce..7d95514 100644 --- a/src/core/PortalManager.cpp +++ b/src/core/PortalManager.cpp @@ -198,6 +198,25 @@ inline const zwp_linux_dmabuf_feedback_v1_listener dmabufFeedbackListener = { // +CPortalManager::CPortalManager() { + const auto XDG_CONFIG_HOME = getenv("XDG_CONFIG_HOME"); + const auto HOME = getenv("HOME"); + + if (!HOME && !XDG_CONFIG_HOME) { + Debug::log(CRIT, "Cannot proceed: neither $HOME nor $XDG_CONFIG_HOME is present in env"); + throw "$HOME and $XDG_CONFIG_HOME both missing from env"; + } + + std::string path = XDG_CONFIG_HOME ? std::string{XDG_CONFIG_HOME} + "/hypr/xdph.conf" : std::string{HOME} + "/.config/hypr/xdph.conf"; + + m_sConfig.config = std::make_unique(path, Hyprlang::SConfigOptions{.allowMissingConfig = true}); + + m_sConfig.config->addConfigValue("general:toplevel_dynamic_bind", {0L}); + + m_sConfig.config->commence(); + m_sConfig.config->parse(); +} + void CPortalManager::onGlobal(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version) { const std::string INTERFACE = interface; @@ -238,7 +257,8 @@ void CPortalManager::onGlobal(void* data, struct wl_registry* registry, uint32_t m_sHelpers.toplevel = std::make_unique(registry, name, version); // remove when another fix is found for https://github.com/hyprwm/xdg-desktop-portal-hyprland/issues/147 - m_sHelpers.toplevel->activate(); + if (!std::any_cast(m_sConfig.config->getConfigValue("general:toplevel_dynamic_bind"))) + m_sHelpers.toplevel->activate(); } } diff --git a/src/core/PortalManager.hpp b/src/core/PortalManager.hpp index 9b341e1..a701fdb 100644 --- a/src/core/PortalManager.hpp +++ b/src/core/PortalManager.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "../portals/Screencopy.hpp" #include "../portals/Screenshot.hpp" @@ -30,6 +31,8 @@ struct SDMABUFModifier { class CPortalManager { public: + CPortalManager(); + void init(); void onGlobal(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version); @@ -67,6 +70,10 @@ class CPortalManager { } dma; } m_sWaylandConnection; + struct { + std::unique_ptr config; + } m_sConfig; + std::vector m_vDMABUFMods; void addTimer(const CTimer& timer);