mirror of
https://github.com/hyprwm/Hyprland
synced 2025-01-11 20:29:48 +01:00
protocols: allow xdg share pickers to reconcile with hyprctl
This commit is contained in:
parent
b0cd9972e8
commit
d4c5be7fd0
4 changed files with 21 additions and 2 deletions
|
@ -1145,6 +1145,12 @@ inline static const std::vector<SConfigOptionDescription> 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:
|
||||
|
|
|
@ -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});
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "ForeignToplevelWlr.hpp"
|
||||
#include <algorithm>
|
||||
#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<Hyprlang::INT>("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<PHLWINDOW>(data);
|
||||
|
|
|
@ -48,6 +48,7 @@ class CForeignToplevelWlrManager {
|
|||
PHLWINDOWREF lastFocus; // READ-ONLY
|
||||
|
||||
SP<CForeignToplevelHandleWlr> handleForWindow(PHLWINDOW pWindow);
|
||||
std::string getWindowTitle(PHLWINDOW pWindow);
|
||||
|
||||
std::vector<WP<CForeignToplevelHandleWlr>> handles;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue