mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-11-22 06:35:57 +01:00
parent
4880c50146
commit
4adb6c4c41
3 changed files with 21 additions and 11 deletions
|
@ -153,18 +153,15 @@ void CScreencopyPortal::onSelectSources(sdbus::MethodCall& call) {
|
||||||
restoreData.timeIssued);
|
restoreData.timeIssued);
|
||||||
} else {
|
} else {
|
||||||
// ver 3
|
// ver 3
|
||||||
auto sv = data.get<std::unordered_map<std::string, sdbus::Variant>>();
|
auto sv = data.get<std::unordered_map<std::string, sdbus::Variant>>();
|
||||||
|
|
||||||
uint64_t windowHandle = 0;
|
restoreData.exists = true;
|
||||||
|
|
||||||
restoreData.windowHandle = 0;
|
|
||||||
restoreData.exists = true;
|
|
||||||
|
|
||||||
for (auto& [tkkey, tkval] : sv) {
|
for (auto& [tkkey, tkval] : sv) {
|
||||||
if (tkkey == "output")
|
if (tkkey == "output")
|
||||||
restoreData.output = tkval.get<std::string>();
|
restoreData.output = tkval.get<std::string>();
|
||||||
else if (tkkey == "windowHandle")
|
else if (tkkey == "windowHandle")
|
||||||
windowHandle = tkval.get<uint64_t>();
|
restoreData.windowHandle = tkval.get<uint64_t>();
|
||||||
else if (tkkey == "windowClass")
|
else if (tkkey == "windowClass")
|
||||||
restoreData.windowClass = tkval.get<std::string>();
|
restoreData.windowClass = tkval.get<std::string>();
|
||||||
else if (tkkey == "withCursor")
|
else if (tkkey == "withCursor")
|
||||||
|
@ -177,8 +174,8 @@ void CScreencopyPortal::onSelectSources(sdbus::MethodCall& call) {
|
||||||
Debug::log(LOG, "[screencopy] restore token v3, unknown prop {}", tkkey);
|
Debug::log(LOG, "[screencopy] restore token v3, unknown prop {}", tkkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug::log(LOG, "[screencopy] Restore token v3 {} with data: {} {} {} {} {}", restoreData.token, windowHandle, restoreData.windowClass, restoreData.output,
|
Debug::log(LOG, "[screencopy] Restore token v3 {} with data: {} {} {} {} {}", restoreData.token, restoreData.windowHandle, restoreData.windowClass,
|
||||||
restoreData.withCursor, restoreData.timeIssued);
|
restoreData.output, restoreData.withCursor, restoreData.timeIssued);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (key == "persist_mode") {
|
} else if (key == "persist_mode") {
|
||||||
|
@ -201,9 +198,12 @@ void CScreencopyPortal::onSelectSources(sdbus::MethodCall& call) {
|
||||||
if (RESTOREDATAVALID) {
|
if (RESTOREDATAVALID) {
|
||||||
Debug::log(LOG, "[screencopy] restore data valid, not prompting");
|
Debug::log(LOG, "[screencopy] restore data valid, not prompting");
|
||||||
|
|
||||||
|
const bool WINDOW = !restoreData.windowClass.empty();
|
||||||
|
const auto HANDLEMATCH = WINDOW && restoreData.windowHandle != 0 ? g_pPortalManager->m_sHelpers.toplevel->handleFromHandleFull(restoreData.windowHandle) : nullptr;
|
||||||
|
|
||||||
SHAREDATA.output = restoreData.output;
|
SHAREDATA.output = restoreData.output;
|
||||||
SHAREDATA.type = !restoreData.windowClass.empty() ? TYPE_WINDOW : TYPE_OUTPUT;
|
SHAREDATA.type = WINDOW ? TYPE_WINDOW : TYPE_OUTPUT;
|
||||||
SHAREDATA.windowHandle = !restoreData.windowClass.empty() ? g_pPortalManager->m_sHelpers.toplevel->handleFromClass(restoreData.windowClass)->handle : nullptr;
|
SHAREDATA.windowHandle = WINDOW ? (HANDLEMATCH ? HANDLEMATCH->handle : g_pPortalManager->m_sHelpers.toplevel->handleFromClass(restoreData.windowClass)->handle) : nullptr;
|
||||||
SHAREDATA.windowClass = restoreData.windowClass;
|
SHAREDATA.windowClass = restoreData.windowClass;
|
||||||
SHAREDATA.allowToken = true; // user allowed token before
|
SHAREDATA.allowToken = true; // user allowed token before
|
||||||
PSESSION->cursorMode = restoreData.withCursor;
|
PSESSION->cursorMode = restoreData.withCursor;
|
||||||
|
|
|
@ -80,4 +80,13 @@ SP<SToplevelHandle> CToplevelManager::handleFromHandleLower(uint32_t handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SP<SToplevelHandle> CToplevelManager::handleFromHandleFull(uint64_t handle) {
|
||||||
|
for (auto& tl : m_vToplevels) {
|
||||||
|
if ((uint64_t)tl->handle->resource() == handle)
|
||||||
|
return tl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ class CToplevelManager {
|
||||||
void deactivate();
|
void deactivate();
|
||||||
SP<SToplevelHandle> handleFromClass(const std::string& windowClass);
|
SP<SToplevelHandle> handleFromClass(const std::string& windowClass);
|
||||||
SP<SToplevelHandle> handleFromHandleLower(uint32_t handle);
|
SP<SToplevelHandle> handleFromHandleLower(uint32_t handle);
|
||||||
|
SP<SToplevelHandle> handleFromHandleFull(uint64_t handle);
|
||||||
|
|
||||||
std::vector<SP<SToplevelHandle>> m_vToplevels;
|
std::vector<SP<SToplevelHandle>> m_vToplevels;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue