diff --git a/src/config/ConfigDescriptions.hpp b/src/config/ConfigDescriptions.hpp index 17657983..927b017e 100644 --- a/src/config/ConfigDescriptions.hpp +++ b/src/config/ConfigDescriptions.hpp @@ -1145,6 +1145,12 @@ inline static const std::vector CONFIG_OPTIONS = { .type = CONFIG_OPTION_INT, .data = SConfigOptionDescription::SRangeData{1000, 0, 5000}, }, + SConfigOptionDescription{ + .value = "misc:xdg_portal_window_address_forwarding", + .description = "forwards the window address in the title of the xdg portal window.", + .type = CONFIG_OPTION_BOOL, + .data = SConfigOptionDescription::SBoolData{false}, + }, /* * binds: diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index bdce573f..30461ee9 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -389,6 +389,7 @@ CConfigManager::CConfigManager() { m_pConfig->addConfigValue("misc:disable_xdg_env_checks", Hyprlang::INT{0}); m_pConfig->addConfigValue("misc:disable_hyprland_qtutils_check", Hyprlang::INT{0}); m_pConfig->addConfigValue("misc:lockdead_screen_delay", Hyprlang::INT{1000}); + m_pConfig->addConfigValue("misc:xdg_portal_window_address_forwarding", Hyprlang::INT{0}); m_pConfig->addConfigValue("group:insert_after_current", Hyprlang::INT{1}); m_pConfig->addConfigValue("group:focus_removed_window", Hyprlang::INT{1}); diff --git a/src/protocols/ForeignToplevelWlr.cpp b/src/protocols/ForeignToplevelWlr.cpp index 6bbd377c..768f896e 100644 --- a/src/protocols/ForeignToplevelWlr.cpp +++ b/src/protocols/ForeignToplevelWlr.cpp @@ -1,6 +1,7 @@ #include "ForeignToplevelWlr.hpp" #include #include "../Compositor.hpp" +#include "../config/ConfigValue.hpp" #include "protocols/core/Output.hpp" #include "render/Renderer.hpp" @@ -204,9 +205,11 @@ void CForeignToplevelWlrManager::onMap(PHLWINDOW pWindow) { } LOGM(LOG, "Newly mapped window {:016x}", (uintptr_t)pWindow.get()); + resource->sendToplevel(NEWHANDLE->resource.get()); NEWHANDLE->resource->sendAppId(pWindow->m_szClass.c_str()); - NEWHANDLE->resource->sendTitle(pWindow->m_szTitle.c_str()); + NEWHANDLE->resource->sendTitle(getWindowTitle(pWindow).c_str()); + if (const auto PMONITOR = pWindow->m_pMonitor.lock(); PMONITOR) NEWHANDLE->sendMonitor(PMONITOR); NEWHANDLE->sendState(); @@ -229,7 +232,7 @@ void CForeignToplevelWlrManager::onTitle(PHLWINDOW pWindow) { if (!H || H->closed) return; - H->resource->sendTitle(pWindow->m_szTitle.c_str()); + H->resource->sendTitle(getWindowTitle(pWindow).c_str()); H->resource->sendDone(); } @@ -310,6 +313,14 @@ bool CForeignToplevelWlrManager::good() { return resource->resource(); } +std::string CForeignToplevelWlrManager::getWindowTitle(PHLWINDOW pWindow) { + // forward window address so xdg-portal custom pickers can reconcile with hyprctl + if (*CConfigValue("misc:xdg_portal_window_address_forwarding")) + return std::format("0x{:x} {}", (uintptr_t)pWindow.get(), pWindow->m_szTitle); + + return pWindow->m_szTitle; +} + CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { static auto P = g_pHookSystem->hookDynamic("openWindow", [this](void* self, SCallbackInfo& info, std::any data) { const auto PWINDOW = std::any_cast(data); diff --git a/src/protocols/ForeignToplevelWlr.hpp b/src/protocols/ForeignToplevelWlr.hpp index 880b7a14..cc5c5dab 100644 --- a/src/protocols/ForeignToplevelWlr.hpp +++ b/src/protocols/ForeignToplevelWlr.hpp @@ -48,6 +48,7 @@ class CForeignToplevelWlrManager { PHLWINDOWREF lastFocus; // READ-ONLY SP handleForWindow(PHLWINDOW pWindow); + std::string getWindowTitle(PHLWINDOW pWindow); std::vector> handles; };