feat(keyboard): improve keyboard response time

Use libinput event for keyboard state updates.
The state will update when CAPS_LOCK, NUM_LOCK or SCROLL_LOCK has been
released,
`interval` will have no effect after this change.
This commit is contained in:
asas1asas200
2022-08-22 20:36:21 +08:00
parent fd24d7bcf6
commit 061f4550f4
4 changed files with 104 additions and 37 deletions

View File

@ -3,12 +3,15 @@
#include <fmt/chrono.h>
#include <gtkmm/label.h>
#include <unordered_map>
#include "AModule.hpp"
#include "bar.hpp"
#include "util/sleeper_thread.hpp"
extern "C" {
#include <libevdev/libevdev.h>
#include <libinput.h>
}
namespace waybar::modules {
@ -20,6 +23,8 @@ class KeyboardState : public AModule {
auto update() -> void;
private:
auto findKeyboards() -> void;
Gtk::Box box_;
Gtk::Label numlock_label_;
Gtk::Label capslock_label_;
@ -34,6 +39,8 @@ class KeyboardState : public AModule {
int fd_;
libevdev* dev_;
struct libinput* libinput_;
std::unordered_map<std::string, struct libinput_device*> libinput_devices_;
util::SleeperThread thread_;
};