Merge pull request #4993 from cebem1nt/master
feature: group - add reveal-delay config option for drawer
This commit is contained in:
@@ -10,6 +10,8 @@
|
|||||||
namespace waybar {
|
namespace waybar {
|
||||||
|
|
||||||
class Group : public AModule {
|
class Group : public AModule {
|
||||||
|
sigc::connection reveal_timeout_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Group(const std::string&, const std::string&, const Json::Value&, bool);
|
Group(const std::string&, const std::string&, const Json::Value&, bool);
|
||||||
~Group() override = default;
|
~Group() override = default;
|
||||||
@@ -26,6 +28,7 @@ class Group : public AModule {
|
|||||||
bool is_first_widget = true;
|
bool is_first_widget = true;
|
||||||
bool is_drawer = false;
|
bool is_drawer = false;
|
||||||
bool click_to_reveal = false;
|
bool click_to_reveal = false;
|
||||||
|
int reveal_delay = 0;
|
||||||
std::string add_class_to_drawer_children;
|
std::string add_class_to_drawer_children;
|
||||||
bool handleMouseEnter(GdkEventCrossing* const& ev) override;
|
bool handleMouseEnter(GdkEventCrossing* const& ev) override;
|
||||||
bool handleMouseLeave(GdkEventCrossing* const& ev) override;
|
bool handleMouseLeave(GdkEventCrossing* const& ev) override;
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ Group::Group(const std::string& name, const std::string& id, const Json::Value&
|
|||||||
? drawer_config["transition-left-to-right"].asBool()
|
? drawer_config["transition-left-to-right"].asBool()
|
||||||
: true);
|
: true);
|
||||||
click_to_reveal = drawer_config["click-to-reveal"].asBool();
|
click_to_reveal = drawer_config["click-to-reveal"].asBool();
|
||||||
|
reveal_delay = drawer_config["reveal-delay"].asInt();
|
||||||
|
|
||||||
const bool start_expanded =
|
const bool start_expanded =
|
||||||
(drawer_config["start-expanded"].isBool() ? drawer_config["start-expanded"].asBool()
|
(drawer_config["start-expanded"].isBool() ? drawer_config["start-expanded"].asBool()
|
||||||
@@ -104,13 +105,27 @@ void Group::hide_group() {
|
|||||||
|
|
||||||
bool Group::handleMouseEnter(GdkEventCrossing* const& e) {
|
bool Group::handleMouseEnter(GdkEventCrossing* const& e) {
|
||||||
if (!click_to_reveal) {
|
if (!click_to_reveal) {
|
||||||
|
if (reveal_delay > 0) {
|
||||||
|
if (reveal_timeout_.connected()) {
|
||||||
|
reveal_timeout_.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
reveal_timeout_ = Glib::signal_timeout().connect(
|
||||||
|
[this]() { show_group(); return false; },
|
||||||
|
reveal_delay);
|
||||||
|
} else {
|
||||||
show_group();
|
show_group();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Group::handleMouseLeave(GdkEventCrossing* const& e) {
|
bool Group::handleMouseLeave(GdkEventCrossing* const& e) {
|
||||||
if (!click_to_reveal && e->detail != GDK_NOTIFY_INFERIOR) {
|
if (!click_to_reveal && e->detail != GDK_NOTIFY_INFERIOR) {
|
||||||
|
if (reveal_delay > 0 && reveal_timeout_.connected()) {
|
||||||
|
reveal_timeout_.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
hide_group();
|
hide_group();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user