Skip to content

Commit 2ff2861

Browse files
Merge remote-tracking branch 'upstream/master'
2 parents c4f1aba + 0594574 commit 2ff2861

127 files changed

Lines changed: 2291 additions & 836 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ result-*
5252

5353
.ccls-cache
5454
_codeql_detected_source_root
55+
heaptrack*

include/AModule.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class AModule : public IModule {
4848
virtual bool handleMouseLeave(GdkEventCrossing* const& ev);
4949
virtual bool handleScroll(GdkEventScroll*);
5050
virtual bool handleRelease(GdkEventButton* const& ev);
51-
GObject* menu_;
51+
GObject* menu_ = nullptr;
5252

5353
private:
5454
bool handleUserEvent(GdkEventButton* const& ev);

include/group.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class Group : public AModule {
3030
bool handleMouseEnter(GdkEventCrossing* const& ev) override;
3131
bool handleMouseLeave(GdkEventCrossing* const& ev) override;
3232
bool handleToggle(GdkEventButton* const& ev) override;
33+
bool handleScroll(GdkEventScroll* e) override;
3334
void show_group();
3435
void hide_group();
3536
};

include/modules/custom.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class Custom : public ALabel {
3535
std::string id_;
3636
std::string alt_;
3737
std::string tooltip_;
38+
std::string last_tooltip_markup_;
3839
const bool tooltip_format_enabled_;
3940
std::vector<std::string> class_;
4041
int percentage_;

include/modules/disk.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Disk : public ALabel {
2222
std::string path_;
2323
std::string unit_;
2424

25-
float calc_specific_divisor(const std::string divisor);
25+
float calc_specific_divisor(const std::string& divisor);
2626
};
2727

2828
} // namespace waybar::modules

include/modules/gamemode.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Gamemode : public AModule {
2626
const std::string DEFAULT_FORMAT = "{glyph}";
2727
const std::string DEFAULT_FORMAT_ALT = "{glyph} {count}";
2828
const std::string DEFAULT_TOOLTIP_FORMAT = "Games running: {count}";
29-
const std::string DEFAULT_GLYPH = "";
29+
const std::string DEFAULT_GLYPH = "󰊴";
3030

3131
void appear(const Glib::RefPtr<Gio::DBus::Connection>& connection, const Glib::ustring& name,
3232
const Glib::ustring& name_owner);

include/modules/hyprland/backend.hpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#pragma once
22

3+
#include <atomic>
34
#include <filesystem>
45
#include <list>
56
#include <mutex>
7+
#include <optional>
68
#include <string>
79
#include <thread>
810
#include <utility>
@@ -34,19 +36,33 @@ class IPC {
3436
Json::Value getSocket1JsonReply(const std::string& rq);
3537
static std::filesystem::path getSocketFolder(const char* instanceSig);
3638

39+
/// Dispatch a Hyprland command. Automatically uses the correct protocol
40+
/// (legacy text or Lua-based) depending on the running Hyprland version.
41+
static std::string dispatch(const std::string& dispatcher, const std::string& arg);
42+
43+
/// Build a Lua-format dispatch command string.
44+
static std::string buildLuaDispatch(const std::string& dispatcher, const std::string& arg);
45+
3746
protected:
3847
static std::filesystem::path socketFolder_;
3948

49+
/// Detect whether the running Hyprland uses the Lua-based IPC protocol.
50+
/// Returns true for Hyprland >= 0.54 (Lua config), false for older versions.
51+
static bool isLuaProtocol();
52+
53+
static std::optional<bool> s_luaProtocolDetected_; // cached detection result
54+
4055
private:
4156
void socketListener();
4257
void parseIPC(const std::string&);
4358

4459
std::thread ipcThread_;
4560
std::mutex callbackMutex_;
61+
std::mutex socketMutex_;
4662
util::JsonParser parser_;
4763
std::list<std::pair<std::string, EventHandler*>> callbacks_;
48-
int socketfd_; // the hyprland socket file descriptor
49-
pid_t socketOwnerPid_;
50-
bool running_ = true; // the ipcThread will stop running when this is false
64+
int socketfd_ = -1; // the hyprland socket file descriptor
65+
pid_t socketOwnerPid_ = -1;
66+
std::atomic<bool> running_ = true; // the ipcThread will stop running when this is false
5167
};
5268
}; // namespace waybar::modules::hyprland

include/modules/hyprland/window.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@ class Window : public waybar::AAppIconLabel, public EventHandler {
2020

2121
private:
2222
struct Workspace {
23-
int id;
24-
int windows;
23+
int id = 0;
24+
int windows = 0;
2525
std::string last_window;
2626
std::string last_window_title;
2727

2828
static auto parse(const Json::Value& value) -> Workspace;
2929
};
3030

3131
struct WindowData {
32-
bool floating;
32+
bool floating = false;
3333
int monitor = -1;
3434
std::string class_name;
3535
std::string initial_class_name;
3636
std::string title;
3737
std::string initial_title;
38-
bool fullscreen;
39-
bool grouped;
38+
bool fullscreen = false;
39+
bool grouped = false;
4040

4141
static auto parse(const Json::Value&) -> WindowData;
4242
};
@@ -47,19 +47,19 @@ class Window : public waybar::AAppIconLabel, public EventHandler {
4747
void queryActiveWorkspace();
4848
void setClass(const std::string&, bool enable);
4949

50-
bool separateOutputs_;
50+
bool separateOutputs_ = false;
5151
std::mutex mutex_;
5252
const Bar& bar_;
5353
util::JsonParser parser_;
5454
WindowData windowData_;
5555
Workspace workspace_;
5656
std::string soloClass_;
5757
std::string lastSoloClass_;
58-
bool solo_;
59-
bool allFloating_;
60-
bool swallowing_;
61-
bool fullscreen_;
62-
bool focused_;
58+
bool solo_ = false;
59+
bool allFloating_ = false;
60+
bool swallowing_ = false;
61+
bool fullscreen_ = false;
62+
bool focused_ = false;
6363

6464
IPC& m_ipc;
6565
};

include/modules/hyprland/windowcreationpayload.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ struct WindowRepr {
4040

4141
class WindowCreationPayload {
4242
public:
43-
WindowCreationPayload(std::string workspace_name, WindowAddress window_address,
43+
WindowCreationPayload(const std::string& workspace_name, WindowAddress window_address,
4444
WindowRepr window_repr);
45-
WindowCreationPayload(std::string workspace_name, WindowAddress window_address,
46-
std::string window_class, std::string window_title, bool is_active);
45+
WindowCreationPayload(const std::string& workspace_name, WindowAddress window_address,
46+
const std::string& window_class, const std::string& window_title,
47+
bool is_active);
4748
WindowCreationPayload(Json::Value const& client_data);
4849

4950
int incrementTimeSpentUncreated();

include/modules/hyprland/workspaces.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <gtkmm/enums.h>
55
#include <gtkmm/label.h>
66
#include <json/value.h>
7+
#include <sigc++/connection.h>
78

89
#include <cstdint>
910
#include <map>
@@ -43,6 +44,7 @@ class Workspaces : public AModule, public EventHandler {
4344
auto moveToMonitor() const -> bool { return m_moveToMonitor; }
4445
auto enableTaskbar() const -> bool { return m_enableTaskbar; }
4546
auto taskbarWithIcon() const -> bool { return m_taskbarWithIcon; }
47+
auto barScroll() const -> bool { return m_barScroll; }
4648

4749
auto getBarOutput() const -> std::string { return m_bar.output->name; }
4850
auto formatBefore() const -> std::string { return m_formatBefore; }
@@ -58,7 +60,7 @@ class Workspaces : public AModule, public EventHandler {
5860
enum class ActiveWindowPosition { NONE, FIRST, LAST };
5961
auto activeWindowPosition() const -> ActiveWindowPosition { return m_activeWindowPosition; }
6062

61-
std::string getRewrite(std::string window_class, std::string window_title);
63+
std::string getRewrite(const std::string& window_class, const std::string& window_title);
6264
std::string& getWindowSeparator() { return m_formatWindowSeparator; }
6365
bool isWorkspaceIgnored(std::string const& workspace_name);
6466

@@ -122,6 +124,8 @@ class Workspaces : public AModule, public EventHandler {
122124
static std::pair<std::string, std::string> splitDoublePayload(std::string const& payload);
123125
static std::tuple<std::string, std::string, std::string> splitTriplePayload(
124126
std::string const& payload);
127+
// scroll events
128+
bool handleScroll(GdkEventScroll* e) override;
125129

126130
// Update methods
127131
void doUpdate();
@@ -145,6 +149,7 @@ class Workspaces : public AModule, public EventHandler {
145149
bool m_specialVisibleOnly = false;
146150
bool m_persistentOnly = false;
147151
bool m_moveToMonitor = false;
152+
bool m_barScroll = false;
148153
Json::Value m_persistentWorkspaceConfig;
149154

150155
// Map for windows stored in workspaces not present in the current bar.
@@ -204,6 +209,7 @@ class Workspaces : public AModule, public EventHandler {
204209
std::mutex m_mutex;
205210
const Bar& m_bar;
206211
Gtk::Box m_box;
212+
sigc::connection m_scrollEventConnection_;
207213
IPC& m_ipc;
208214
};
209215

0 commit comments

Comments
 (0)