mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-11-25 07:35:57 +01:00
parent
11e15b437e
commit
e695669fd8
4 changed files with 13 additions and 14 deletions
|
@ -47,9 +47,9 @@ SKeybind* CGlobalShortcutsPortal::getShortcutById(const std::string& appID, cons
|
||||||
}
|
}
|
||||||
|
|
||||||
SKeybind* CGlobalShortcutsPortal::registerShortcut(SSession* session, const DBusShortcut& shortcut) {
|
SKeybind* CGlobalShortcutsPortal::registerShortcut(SSession* session, const DBusShortcut& shortcut) {
|
||||||
std::string id = shortcut.get<0>();
|
std::string id = shortcut.get<0>();
|
||||||
std::unordered_map<std::string, sdbus::Variant> data = shortcut.get<1>();
|
std::unordered_map<std::string, sdbus::Variant> data = shortcut.get<1>();
|
||||||
std::string description;
|
std::string description;
|
||||||
|
|
||||||
for (auto& [k, v] : data) {
|
for (auto& [k, v] : data) {
|
||||||
if (k == "description")
|
if (k == "description")
|
||||||
|
@ -63,8 +63,7 @@ SKeybind* CGlobalShortcutsPortal::registerShortcut(SSession* session, const DBus
|
||||||
Debug::log(WARN, "[globalshortcuts] shortcut {} already registered for appid {}", id, session->appid);
|
Debug::log(WARN, "[globalshortcuts] shortcut {} already registered for appid {}", id, session->appid);
|
||||||
else {
|
else {
|
||||||
PSHORTCUT = session->keybinds.emplace_back(std::make_unique<SKeybind>()).get();
|
PSHORTCUT = session->keybinds.emplace_back(std::make_unique<SKeybind>()).get();
|
||||||
PSHORTCUT->shortcut =
|
PSHORTCUT->shortcut = hyprland_global_shortcuts_manager_v1_register_shortcut(m_sState.manager, id.c_str(), session->appid.c_str(), description.c_str(), "");
|
||||||
hyprland_global_shortcuts_manager_v1_register_shortcut(m_sState.manager, id.c_str(), session->appid.c_str(), description.c_str(), "");
|
|
||||||
hyprland_global_shortcut_v1_add_listener(PSHORTCUT->shortcut, &shortcutListener, PSHORTCUT);
|
hyprland_global_shortcut_v1_add_listener(PSHORTCUT->shortcut, &shortcutListener, PSHORTCUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +141,7 @@ void CGlobalShortcutsPortal::onBindShortcuts(sdbus::MethodCall& call) {
|
||||||
PSESSION->registered = true;
|
PSESSION->registered = true;
|
||||||
|
|
||||||
for (auto& s : shortcuts) {
|
for (auto& s : shortcuts) {
|
||||||
const auto* PSHORTCUT = registerShortcut(PSESSION, s);
|
const auto* PSHORTCUT = registerShortcut(PSESSION, s);
|
||||||
|
|
||||||
std::unordered_map<std::string, sdbus::Variant> shortcutData;
|
std::unordered_map<std::string, sdbus::Variant> shortcutData;
|
||||||
shortcutData["description"] = PSHORTCUT->description;
|
shortcutData["description"] = PSHORTCUT->description;
|
||||||
|
|
|
@ -41,12 +41,12 @@ class CGlobalShortcutsPortal {
|
||||||
|
|
||||||
std::unique_ptr<sdbus::IObject> m_pObject;
|
std::unique_ptr<sdbus::IObject> m_pObject;
|
||||||
|
|
||||||
using DBusShortcut = sdbus::Struct<std::string, std::unordered_map<std::string, sdbus::Variant>>;
|
using DBusShortcut = sdbus::Struct<std::string, std::unordered_map<std::string, sdbus::Variant>>;
|
||||||
|
|
||||||
SSession* getSession(sdbus::ObjectPath& path);
|
SSession* getSession(sdbus::ObjectPath& path);
|
||||||
SKeybind* getShortcutById(const std::string& appID, const std::string& shortcutId);
|
SKeybind* getShortcutById(const std::string& appID, const std::string& shortcutId);
|
||||||
SKeybind* registerShortcut(SSession* session, const DBusShortcut& shortcut);
|
SKeybind* registerShortcut(SSession* session, const DBusShortcut& shortcut);
|
||||||
|
|
||||||
const std::string INTERFACE_NAME = "org.freedesktop.impl.portal.GlobalShortcuts";
|
const std::string INTERFACE_NAME = "org.freedesktop.impl.portal.GlobalShortcuts";
|
||||||
const std::string OBJECT_PATH = "/org/freedesktop/portal/desktop";
|
const std::string OBJECT_PATH = "/org/freedesktop/portal/desktop";
|
||||||
};
|
};
|
|
@ -281,7 +281,7 @@ static void hlOnBufferDone(void* data, hyprland_toplevel_export_frame_v1* frame)
|
||||||
|
|
||||||
hyprland_toplevel_export_frame_v1_copy(frame, PSTREAM->currentPWBuffer->wlBuffer, false);
|
hyprland_toplevel_export_frame_v1_copy(frame, PSTREAM->currentPWBuffer->wlBuffer, false);
|
||||||
PSESSION->sharingData.copyRetries = 0;
|
PSESSION->sharingData.copyRetries = 0;
|
||||||
|
|
||||||
Debug::log(TRACE, "[sc] wlr frame copied");
|
Debug::log(TRACE, "[sc] wlr frame copied");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ void pickHyprPicker(sdbus::MethodCall& call) {
|
||||||
|
|
||||||
auto [r, g, b] = colors;
|
auto [r, g, b] = colors;
|
||||||
std::unordered_map<std::string, sdbus::Variant> results;
|
std::unordered_map<std::string, sdbus::Variant> results;
|
||||||
results["color"] = sdbus::Struct(std::tuple{r / 255.0, g / 255.0, b / 255.0});
|
results["color"] = sdbus::Struct<double, double, double>(r / 255.0, g / 255.0, b / 255.0);
|
||||||
|
|
||||||
auto reply = call.createReply();
|
auto reply = call.createReply();
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ void pickSlurp(sdbus::MethodCall& call) {
|
||||||
auto reply = call.createReply();
|
auto reply = call.createReply();
|
||||||
|
|
||||||
std::unordered_map<std::string, sdbus::Variant> results;
|
std::unordered_map<std::string, sdbus::Variant> results;
|
||||||
results["color"] = sdbus::Struct(std::tuple{r, g, b});
|
results["color"] = sdbus::Struct<double, double, double>(r, g, b);
|
||||||
|
|
||||||
reply << (uint32_t)0;
|
reply << (uint32_t)0;
|
||||||
reply << results;
|
reply << results;
|
||||||
|
|
Loading…
Reference in a new issue