Skip to content

Commit

Permalink
AModule: clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
khaneliman committed Jul 1, 2024
1 parent 66f63a3 commit 84cfac7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions include/AModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class AModule : public IModule {
public:
static constexpr const char *MODULE_CLASS = "module";

virtual ~AModule();
~AModule() override;
auto update() -> void override;
virtual auto refresh(int) -> void{};
virtual auto refresh(int shouldRefresh) -> void{};
operator Gtk::Widget &() override;
auto doAction(const std::string &name) -> void override;

Expand All @@ -32,13 +32,13 @@ class AModule : public IModule {
enum SCROLL_DIR { NONE, UP, DOWN, LEFT, RIGHT };

SCROLL_DIR getScrollDir(GdkEventScroll *e);
bool tooltipEnabled();
bool tooltipEnabled() const;

const std::string name_;
const Json::Value &config_;
Gtk::EventBox event_box_;

virtual void setCursor(Gdk::CursorType const c);
virtual void setCursor(Gdk::CursorType const &c);

virtual bool handleToggle(GdkEventButton *const &ev);
virtual bool handleMouseEnter(GdkEventCrossing *const &ev);
Expand Down
12 changes: 6 additions & 6 deletions src/AModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace waybar {

AModule::AModule(const Json::Value& config, const std::string& name, const std::string& id,
bool enable_click, bool enable_scroll)
: name_(std::move(name)),
config_(std::move(config)),
: name_(name),
config_(config),
isTooltip{config_["tooltip"].isBool() ? config_["tooltip"].asBool() : true},
distance_scrolled_y_(0.0),
distance_scrolled_x_(0.0) {
Expand All @@ -22,7 +22,7 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std::

for (Json::Value::const_iterator it = actions.begin(); it != actions.end(); ++it) {
if (it.key().isString() && it->isString())
if (eventActionMap_.count(it.key().asString()) == 0) {
if (!eventActionMap_.contains(it.key().asString())) {
eventActionMap_.insert({it.key().asString(), it->asString()});
enable_click = true;
enable_scroll = true;
Expand Down Expand Up @@ -104,7 +104,7 @@ auto AModule::doAction(const std::string& name) -> void {
}
}

void AModule::setCursor(Gdk::CursorType c) {
void AModule::setCursor(Gdk::CursorType const& c) {
auto gdk_window = event_box_.get_window();
if (gdk_window) {
auto cursor = Gdk::Cursor::create(c);
Expand Down Expand Up @@ -181,7 +181,7 @@ AModule::SCROLL_DIR AModule::getScrollDir(GdkEventScroll* e) {

// ignore reverse-scrolling if event comes from a mouse wheel
GdkDevice* device = gdk_event_get_source_device((GdkEvent*)e);
if (device != NULL && gdk_device_get_source(device) == GDK_SOURCE_MOUSE) {
if (device != nullptr && gdk_device_get_source(device) == GDK_SOURCE_MOUSE) {
reverse = reverse_mouse;
}

Expand Down Expand Up @@ -259,7 +259,7 @@ bool AModule::handleScroll(GdkEventScroll* e) {
return true;
}

bool AModule::tooltipEnabled() { return isTooltip; }
bool AModule::tooltipEnabled() const { return isTooltip; }

AModule::operator Gtk::Widget&() { return event_box_; }

Expand Down

0 comments on commit 84cfac7

Please sign in to comment.