Use a minimum step as provided by wireplubmer; Default step to 1
parent
75990c2867
commit
d22fd3bbd1
|
@ -38,7 +38,7 @@ class Wireplumber : public ALabel {
|
||||||
uint32_t pending_plugins_;
|
uint32_t pending_plugins_;
|
||||||
bool muted_;
|
bool muted_;
|
||||||
double volume_;
|
double volume_;
|
||||||
double step_;
|
double min_step_;
|
||||||
uint32_t node_id_{0};
|
uint32_t node_id_{0};
|
||||||
std::string node_name_;
|
std::string node_name_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,7 +15,7 @@ waybar::modules::Wireplumber::Wireplumber(const std::string& id, const Json::Val
|
||||||
pending_plugins_(0),
|
pending_plugins_(0),
|
||||||
muted_(false),
|
muted_(false),
|
||||||
volume_(0.0),
|
volume_(0.0),
|
||||||
step_(0.0),
|
min_step_(0.0),
|
||||||
node_id_(0) {
|
node_id_(0) {
|
||||||
wp_init(WP_INIT_PIPEWIRE);
|
wp_init(WP_INIT_PIPEWIRE);
|
||||||
wp_core_ = wp_core_new(NULL, NULL);
|
wp_core_ = wp_core_new(NULL, NULL);
|
||||||
|
@ -103,7 +103,7 @@ void waybar::modules::Wireplumber::updateVolume(waybar::modules::Wireplumber* se
|
||||||
}
|
}
|
||||||
|
|
||||||
g_variant_lookup(variant, "volume", "d", &self->volume_);
|
g_variant_lookup(variant, "volume", "d", &self->volume_);
|
||||||
g_variant_lookup(variant, "step", "d", &self->step_);
|
g_variant_lookup(variant, "step", "d", &self->min_step_);
|
||||||
g_variant_lookup(variant, "mute", "b", &self->muted_);
|
g_variant_lookup(variant, "mute", "b", &self->muted_);
|
||||||
g_clear_pointer(&variant, g_variant_unref);
|
g_clear_pointer(&variant, g_variant_unref);
|
||||||
|
|
||||||
|
@ -324,15 +324,16 @@ bool waybar::modules::Wireplumber::handleScroll(GdkEventScroll* e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
double max_volume = 1;
|
double max_volume = 1;
|
||||||
double step = step_;
|
double step = 1.0 / 100.0;
|
||||||
// isDouble returns true for integers as well, just in case
|
|
||||||
if (config_["scroll-step"].isDouble()) {
|
if (config_["scroll-step"].isDouble()) {
|
||||||
step = config_["scroll-step"].asDouble() / 100.0;
|
step = config_["scroll-step"].asDouble() / 100.0;
|
||||||
}
|
}
|
||||||
if (config_["max-volume"].isInt()) {
|
if (config_["max-volume"].isDouble()) {
|
||||||
max_volume = config_["max-volume"].asInt() / 100.0;
|
max_volume = config_["max-volume"].asDouble() / 100.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (step < min_step_) step = min_step_;
|
||||||
|
|
||||||
double new_vol = volume_;
|
double new_vol = volume_;
|
||||||
if (dir == SCROLL_DIR::UP) {
|
if (dir == SCROLL_DIR::UP) {
|
||||||
if (volume_ < max_volume) {
|
if (volume_ < max_volume) {
|
||||||
|
|
Loading…
Reference in New Issue