Skip to content

Commit

Permalink
AModule: retain existing default behavior when unconfigured
Browse files Browse the repository at this point in the history
  • Loading branch information
khaneliman committed Jul 2, 2024
1 parent 5d6c5ec commit 6c8347f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 6 additions & 4 deletions man/waybar-styles.5.scd.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,24 @@ You can apply special styling to any module for when the cursor hovers it.
## Setting cursor style

Most, if not all, module types support setting the `cursor` option. This is
configured in your `config.jsonc`. If set to `true`, when hovering the module a
configured in your `config.jsonc`. If set to `false`, when hovering the module a
"pointer"(as commonly known from web CSS styling `cursor: pointer`) style cursor
will be shown.
will not be shown. Default behavior is to indicate an interaction event is
available.

There are more cursor types to choose from by setting the `cursor` option to
a number, see Gdk3 official docs for all possible cursor types:
https://docs.gtk.org/gdk3/enum.CursorType.html.
However, note that not all cursor options listed may be available on
your system. If you attempt to use a cursor which is not available, the
application will crash.

Example of enabling pointer(`Gdk::Hand2`) cursor type on a custom module:
Example of disabling pointer(`Gdk::Hand2`) cursor type on a custom module:

```
"custom/my-custom-module": {
...
"cursor": true,
"cursor": false,
}
```

Expand Down
4 changes: 4 additions & 0 deletions src/AModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std::
event_box_.signal_scroll_event().connect(sigc::mem_fun(*this, &AModule::handleScroll));
}

// Respect user configuration of cursor
if (config_.isMember("cursor")) {
if (config_["cursor"].isBool() && config_["cursor"].asBool()) {
setCursor(Gdk::HAND2);
Expand All @@ -77,6 +78,9 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std::
} else {
spdlog::warn("unknown cursor option configured on module {}", name_);
}
} else {
// Default behavior indicating event availability
setCursor(Gdk::HAND2);
}
}

Expand Down

0 comments on commit 6c8347f

Please sign in to comment.