screenshot: fix compilation due to dubious cast

fixes #257
This commit is contained in:
Vaxry 2024-09-11 10:29:39 +01:00
parent 11e15b437e
commit e695669fd8
4 changed files with 13 additions and 14 deletions

View file

@ -47,9 +47,9 @@ SKeybind* CGlobalShortcutsPortal::getShortcutById(const std::string& appID, cons
}
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::string description;
std::string description;
for (auto& [k, v] : data) {
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);
else {
PSHORTCUT = session->keybinds.emplace_back(std::make_unique<SKeybind>()).get();
PSHORTCUT->shortcut =
hyprland_global_shortcuts_manager_v1_register_shortcut(m_sState.manager, id.c_str(), session->appid.c_str(), description.c_str(), "");
PSHORTCUT->shortcut = 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);
}
@ -142,7 +141,7 @@ void CGlobalShortcutsPortal::onBindShortcuts(sdbus::MethodCall& call) {
PSESSION->registered = true;
for (auto& s : shortcuts) {
const auto* PSHORTCUT = registerShortcut(PSESSION, s);
const auto* PSHORTCUT = registerShortcut(PSESSION, s);
std::unordered_map<std::string, sdbus::Variant> shortcutData;
shortcutData["description"] = PSHORTCUT->description;

View file

@ -41,12 +41,12 @@ class CGlobalShortcutsPortal {
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);
SKeybind* getShortcutById(const std::string& appID, const std::string& shortcutId);
SKeybind* registerShortcut(SSession* session, const DBusShortcut& shortcut);
SSession* getSession(sdbus::ObjectPath& path);
SKeybind* getShortcutById(const std::string& appID, const std::string& shortcutId);
SKeybind* registerShortcut(SSession* session, const DBusShortcut& shortcut);
const std::string INTERFACE_NAME = "org.freedesktop.impl.portal.GlobalShortcuts";
const std::string OBJECT_PATH = "/org/freedesktop/portal/desktop";
const std::string INTERFACE_NAME = "org.freedesktop.impl.portal.GlobalShortcuts";
const std::string OBJECT_PATH = "/org/freedesktop/portal/desktop";
};

View file

@ -41,7 +41,7 @@ void pickHyprPicker(sdbus::MethodCall& call) {
auto [r, g, b] = colors;
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();
@ -91,7 +91,7 @@ void pickSlurp(sdbus::MethodCall& call) {
auto reply = call.createReply();
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 << results;