Skip to content

Commit 387a040

Browse files
committed
GTK4: Migration keyboard-state
Signed-off-by: Viktar Lukashonak <myxabeer@gmail.com>
1 parent e64896e commit 387a040

File tree

7 files changed

+94
-80
lines changed

7 files changed

+94
-80
lines changed

Diff for: include/AIconLabel.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class AIconLabel : public ALabel {
1414
bool enable_click = false, bool enable_scroll = false);
1515
virtual ~AIconLabel() = default;
1616
auto update() -> void override;
17+
operator Gtk::Widget &() override;
1718

1819
protected:
1920
Gtk::Image image_;

Diff for: include/modules/keyboard_state.hpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,23 @@
44
#include <gtkmm/label.h>
55

66
#include <set>
7-
#include <unordered_map>
87

98
#include "AModule.hpp"
109
#include "bar.hpp"
1110
#include "util/sleeper_thread.hpp"
1211

1312
extern "C" {
14-
#include <libevdev/libevdev.h>
1513
#include <libinput.h>
1614
}
1715

1816
namespace waybar::modules {
1917

20-
class KeyboardState : public AModule {
18+
class KeyboardState final : public AModule {
2119
public:
2220
KeyboardState(const std::string&, const waybar::Bar&, const Json::Value&);
2321
virtual ~KeyboardState();
2422
auto update() -> void override;
23+
operator Gtk::Widget &() override;
2524

2625
private:
2726
auto tryAddDevice(const std::string&) -> void;

Diff for: meson.build

+17-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ sigcpp = dependency('sigc++-3.0', version: ['>=3.4.0'])
7575
gtkmm = dependency('gtkmm-4.0', version : ['>=4.12.0'])
7676
giounix = dependency('gio-unix-2.0', version: ['>=2.76.4'])
7777
spdlog = dependency('spdlog', version : ['>=1.10.0'], fallback : ['spdlog', 'spdlog_dep'], default_options : ['external_fmt=enabled'])
78+
libinotify = dependency('libinotify', required: false)
79+
libepoll = dependency('epoll-shim', required: false)
80+
libinput = dependency('libinput', required: get_option('libinput'))
7881
libudev = dependency('libudev', required: get_option('libudev'))
82+
libevdev = dependency('libevdev', required: get_option('libevdev'))
7983
xkbregistry = dependency('xkbregistry')
8084
libnl = dependency('libnl-3.0', required: get_option('libnl'))
8185
libnlgen = dependency('libnl-genl-3.0', required: get_option('libnl'))
@@ -195,11 +199,18 @@ if libudev.found() and (is_linux or libepoll.found())
195199
)
196200
endif
197201

198-
#if libsndio.found()
202+
if libevdev.found() and (is_linux or libepoll.found()) and libinput.found() and (is_linux or libinotify.found())
203+
add_project_arguments('-DHAVE_LIBEVDEV', language: 'cpp')
204+
add_project_arguments('-DHAVE_LIBINPUT', language: 'cpp')
205+
src_files += files('src/modules/keyboard_state.cpp')
206+
man_files += files('man/waybar-keyboard-state.5.scd')
207+
endif
208+
209+
if libsndio.found()
199210
add_project_arguments('-DHAVE_LIBSNDIO', language: 'cpp')
200211
src_files += files('src/modules/sndio.cpp')
201212
man_files += files('man/waybar-sndio.5.scd')
202-
#endif
213+
endif
203214

204215
if get_option('rfkill').enabled() and is_linux
205216
add_project_arguments('-DWANT_RFKILL', language: 'cpp')
@@ -323,6 +334,7 @@ executable(
323334
gtkmm,
324335
giounix,
325336
sigcpp,
337+
libevdev,
326338
libudev,
327339
jsoncpp,
328340
wayland_client,
@@ -331,6 +343,9 @@ executable(
331343
spdlog,
332344
xkbregistry,
333345
cava,
346+
libinotify,
347+
libepoll,
348+
libinput,
334349
libnl,
335350
libnlgen,
336351
libpulse,

Diff for: src/AIconLabel.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ bool AIconLabel::iconEnabled() const {
2121
return config_["icon"].isBool() ? config_["icon"].asBool() : false;
2222
}
2323

24+
AIconLabel::operator Gtk::Widget&() { return box_; };
25+
2426
} // namespace waybar

Diff for: src/bar.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ auto waybar::Bar::setupWidgets() -> void {
530530
getModules(factory, "modules-center");
531531
getModules(factory, "modules-right");
532532
for (auto const& module : modules_left_) {
533-
left_.prepend(*module);
533+
left_.append(*module);
534534
}
535535
for (auto const& module : modules_center_) {
536536
center_.append(*module);

Diff for: src/factory.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name,
148148
}
149149
if (ref == "sway/workspaces") {
150150
return new waybar::modules::sway::Workspaces(id, bar_, config_[name]);
151-
}/*
151+
}
152152
if (ref == "sway/window") {
153153
return new waybar::modules::sway::Window(id, bar_, config_[name]);
154-
}*/
154+
}
155155
if (ref == "sway/language") {
156156
return new waybar::modules::sway::Language(id, config_[name]);
157157
}
@@ -258,12 +258,11 @@ gtk4 todo
258258
return new waybar::modules::BacklightSlider(id, config_[name]);
259259
}
260260
#endif
261-
/*
262261
#ifdef HAVE_LIBEVDEV
263262
if (ref == "keyboard-state") {
264263
return new waybar::modules::KeyboardState(id, bar_, config_[name]);
265264
}
266-
#endif*/
265+
#endif
267266
#ifdef HAVE_LIBPULSE
268267
if (ref == "pulseaudio") {
269268
return new waybar::modules::Pulseaudio(id, config_[name]);
@@ -276,12 +275,12 @@ gtk4 todo
276275
if (ref == "mpd") {
277276
return new waybar::modules::MPD(id, config_[name]);
278277
}
279-
#endif
278+
#endif*/
280279
#ifdef HAVE_LIBSNDIO
281280
if (ref == "sndio") {
282281
return new waybar::modules::Sndio(id, config_[name]);
283282
}
284-
#endif*/
283+
#endif
285284
#ifdef HAVE_GIO_UNIX
286285
if (ref == "bluetooth") {
287286
return new waybar::modules::Bluetooth(id, config_[name]);

0 commit comments

Comments
 (0)