Start on rpc, open existing instances ui when trying to launch gsr-ui a second time

This commit is contained in:
dec05eba
2024-12-30 22:57:48 +01:00
parent a3d4455b3d
commit c2dca2e8f8
7 changed files with 201 additions and 19 deletions

View File

@@ -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);