Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protocols: allow xdg share pickers to reconcile with hyprctl #8939

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/config/ConfigDescriptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down
15 changes: 13 additions & 2 deletions src/protocols/ForeignToplevelWlr.cpp
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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();
Expand All @@ -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();
}

Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/protocols/ForeignToplevelWlr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
Loading