From c2dca2e8f812302d9465186bf001442a29919088 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 30 Dec 2024 22:57:48 +0100 Subject: Start on rpc, open existing instances ui when trying to launch gsr-ui a second time --- src/GlobalHotkeysLinux.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/GlobalHotkeysLinux.cpp') diff --git a/src/GlobalHotkeysLinux.cpp b/src/GlobalHotkeysLinux.cpp index f3ec2b3..d16cc06 100644 --- a/src/GlobalHotkeysLinux.cpp +++ b/src/GlobalHotkeysLinux.cpp @@ -89,7 +89,7 @@ namespace gsr { } bool GlobalHotkeysLinux::bind_action(const std::string &id, GlobalHotkeyCallback callback) { - return bound_actions_by_id.insert(std::make_pair(id, callback)).second; + return bound_actions_by_id.insert(std::make_pair(id, std::move(callback))).second; } void GlobalHotkeysLinux::poll_events() { @@ -103,20 +103,23 @@ namespace gsr { return; } + std::string action; char buffer[256]; while(true) { char *line = fgets(buffer, sizeof(buffer), read_file); if(!line) break; - const int line_len = strlen(line); + int line_len = strlen(line); if(line_len == 0) continue; - if(line[line_len - 1] == '\n') + if(line[line_len - 1] == '\n') { line[line_len - 1] = '\0'; + --line_len; + } - const std::string action = line; + action = line; auto it = bound_actions_by_id.find(action); if(it != bound_actions_by_id.end()) it->second(action); -- cgit v1.2.3