From ab0f2c13af984e461e05635ffe5f29453d65105a Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Wed, 20 Jan 2021 17:48:35 -0800 Subject: [PATCH 1/2] fix(client): attach styles only once Gdk >= 3.10 has only one GdkScreen. No need to reattach styles on every output change. --- src/client.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index 24984a47..9fdf8703 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -129,9 +129,6 @@ void waybar::Client::handleOutputDone(void *data, struct zxdg_output_v1 * /*xdg_ wl_display_roundtrip(client->wl_display); for (const auto &config : configs) { client->bars.emplace_back(std::make_unique(&output, config)); - Glib::RefPtr screen = client->bars.back()->window.get_screen(); - client->style_context_->add_provider_for_screen( - screen, client->css_provider_, GTK_STYLE_PROVIDER_PRIORITY_USER); } } } catch (const std::exception &e) { @@ -232,6 +229,9 @@ auto waybar::Client::setupCss(const std::string &css_file) -> void { if (!css_provider_->load_from_path(css_file)) { throw std::runtime_error("Can't open style file"); } + // there's always only one screen + style_context_->add_provider_for_screen( + Gdk::Screen::get_default(), css_provider_, GTK_STYLE_PROVIDER_PRIORITY_USER); } void waybar::Client::bindInterfaces() { From 7fa1c118335cad40fdb92db49f4e35c8f8dc0bac Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Wed, 20 Jan 2021 19:36:16 -0800 Subject: [PATCH 2/2] fix(client): unsubscribe after receiving xdg_output.done event Ignore any further xdg_output events. Name and description are constant for the lifetime of wl_output in xdg-output-unstable-v1 version 2 and we don't need other properties. Fixes #990. --- src/client.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index 9fdf8703..0ad4e6bb 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -123,14 +123,14 @@ void waybar::Client::handleOutputDone(void *data, struct zxdg_output_v1 * /*xdg_ spdlog::debug("Output detection done: {} ({})", output.name, output.identifier); auto configs = client->getOutputConfigs(output); - if (configs.empty()) { - output.xdg_output.reset(); - } else { + if (!configs.empty()) { wl_display_roundtrip(client->wl_display); for (const auto &config : configs) { client->bars.emplace_back(std::make_unique(&output, config)); } } + // unsubscribe + output.xdg_output.reset(); } catch (const std::exception &e) { std::cerr << e.what() << std::endl; }