mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-03-31 09:17:04 +09:00
Fix high cpu usage when running global hotkeys without grab and then connecting a secondary keyboard
This commit is contained in:
@@ -152,19 +152,24 @@ namespace gsr {
|
|||||||
if(read_led_brightness_timer.get_elapsed_time_seconds() > 0.2) {
|
if(read_led_brightness_timer.get_elapsed_time_seconds() > 0.2) {
|
||||||
read_led_brightness_timer.restart();
|
read_led_brightness_timer.restart();
|
||||||
|
|
||||||
bool led_status_outdated = false;
|
bool any_keyboard_with_led_enabled = false;
|
||||||
|
bool any_keyboard_with_led_disabled = false;
|
||||||
char buffer[32];
|
char buffer[32];
|
||||||
for(int led_brightness_file_fd : led_brightness_files) {
|
for(int led_brightness_file_fd : led_brightness_files) {
|
||||||
const ssize_t bytes_read = read(led_brightness_file_fd, buffer, sizeof(buffer));
|
const ssize_t bytes_read = read(led_brightness_file_fd, buffer, sizeof(buffer));
|
||||||
if(bytes_read > 0) {
|
if(bytes_read > 0) {
|
||||||
if(buffer[0] == '0')
|
if(buffer[0] == '0')
|
||||||
led_status_outdated = true;
|
any_keyboard_with_led_disabled = true;
|
||||||
|
else
|
||||||
|
any_keyboard_with_led_enabled = true;
|
||||||
lseek(led_brightness_file_fd, 0, SEEK_SET);
|
lseek(led_brightness_file_fd, 0, SEEK_SET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(led_status_outdated && led_enabled)
|
if(led_enabled && any_keyboard_with_led_disabled)
|
||||||
run_gsr_global_hotkeys_set_leds(true);
|
run_gsr_global_hotkeys_set_leds(true);
|
||||||
|
else if(!led_enabled && any_keyboard_with_led_enabled)
|
||||||
|
run_gsr_global_hotkeys_set_leds(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,17 +243,6 @@ static void keyboard_event_process_input_event_data(keyboard_event *self, event_
|
|||||||
fprintf(stderr, "Error: failed to write event data to virtual keyboard for exclusively grabbed device\n");
|
fprintf(stderr, "Error: failed to write event data to virtual keyboard for exclusively grabbed device\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(event.type == EV_LED) {
|
|
||||||
write(fd, &event, sizeof(event));
|
|
||||||
|
|
||||||
const struct input_event syn_event = {
|
|
||||||
.type = EV_SYN,
|
|
||||||
.code = 0,
|
|
||||||
.value = 0
|
|
||||||
};
|
|
||||||
write(fd, &syn_event, sizeof(syn_event));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!extra_data->is_possibly_non_keyboard_device)
|
if(!extra_data->is_possibly_non_keyboard_device)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user