From 1f591e36f1e6212e5b4748495b3c45354cae46c1 Mon Sep 17 00:00:00 2001 From: Simon Plakolb Date: Thu, 20 Oct 2022 10:27:41 +0200 Subject: [PATCH 1/2] button: Hardcode min-width property set to zero Buttons come with an intrinsic min-width but lack a method to alter this property. Setting the requested size to zero has also no effect on it. The only way found to work is to hard code the CSS into the button. --- include/AButton.hpp | 1 + src/AButton.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/AButton.hpp b/include/AButton.hpp index 4628f1ea..ce29a09f 100644 --- a/include/AButton.hpp +++ b/include/AButton.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include diff --git a/src/AButton.cpp b/src/AButton.cpp index 1ef1804b..2952b0d8 100644 --- a/src/AButton.cpp +++ b/src/AButton.cpp @@ -18,6 +18,12 @@ AButton::AButton(const Json::Value& config, const std::string& name, const std:: default_format_(format_) { button_.set_name(name); button_.set_relief(Gtk::RELIEF_NONE); + + /* https://github.com/Alexays/Waybar/issues/1731 */ + auto css = Gtk::CssProvider::create(); + css->load_from_data("button { min-width: 0; }"); + button_.get_style_context()->add_provider(css, GTK_STYLE_PROVIDER_PRIORITY_USER); + if (!id.empty()) { button_.get_style_context()->add_class(id); } From 05dbfe261af282f511f12388c730425e69fe26fa Mon Sep 17 00:00:00 2001 From: Simon Plakolb Date: Thu, 20 Oct 2022 10:34:20 +0200 Subject: [PATCH 2/2] style: Revert set default minimal width of buttons to zero #1737 --- resources/style.css | 2 -- 1 file changed, 2 deletions(-) diff --git a/resources/style.css b/resources/style.css index ae6e496d..40d870af 100644 --- a/resources/style.css +++ b/resources/style.css @@ -40,8 +40,6 @@ button { /* Avoid rounded borders under each button name */ border: none; border-radius: 0; - /* https://github.com/Alexays/Waybar/issues/1731 */ - min-width: 0; } /* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */