Merge branch 'Alexays:master' into master

This commit is contained in:
Sonter 2024-09-16 17:11:32 +00:00 committed by GitHub
commit 9e8ebe668d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 50 additions and 37 deletions

View File

@ -18,11 +18,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1724819573, "lastModified": 1726062873,
"narHash": "sha256-GnR7/ibgIH1vhoy8cYdmXE6iyZqKqFxQSVkFgosBh6w=", "narHash": "sha256-IiA3jfbR7K/B5+9byVi9BZGWTD4VSbWe8VLpp9B/iYk=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "71e91c409d1e654808b2621f28a327acfdad8dc2", "rev": "4f807e8940284ad7925ebd0a0993d2a1791acb2f",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -42,7 +42,7 @@ struct bar_margins {
}; };
struct bar_mode { struct bar_mode {
std::optional<bar_layer> layer; bar_layer layer;
bool exclusive; bool exclusive;
bool passthrough; bool passthrough;
bool visible; bool visible;

View File

@ -106,7 +106,7 @@ if libsndio.found()
endif endif
endif endif
gtk_layer_shell = dependency('gtk-layer-shell-0', version: ['>=0.6.0'], gtk_layer_shell = dependency('gtk-layer-shell-0', version: ['>=0.9.0'],
default_options: ['introspection=false', 'vapi=false'], default_options: ['introspection=false', 'vapi=false'],
fallback: ['gtk-layer-shell', 'gtk_layer_shell']) fallback: ['gtk-layer-shell', 'gtk_layer_shell'])
systemd = dependency('systemd', required: get_option('systemd')) systemd = dependency('systemd', required: get_option('systemd'))

View File

@ -154,6 +154,16 @@ void AAppIconLabel::updateAppIcon() {
update_app_icon_ = false; update_app_icon_ = false;
if (app_icon_name_.empty()) { if (app_icon_name_.empty()) {
image_.set_visible(false); image_.set_visible(false);
}
else if (app_icon_name_.front() == '/') {
auto pixbuf = Gdk::Pixbuf::create_from_file(app_icon_name_);
int scaled_icon_size = app_icon_size_ * image_.get_scale_factor();
pixbuf = Gdk::Pixbuf::create_from_file(app_icon_name_, scaled_icon_size, scaled_icon_size);
auto surface = Gdk::Cairo::create_surface_from_pixbuf(pixbuf, image_.get_scale_factor(),
image_.get_window());
image_.set(surface);
image_.set_visible(true);
} else { } else {
image_.set_from_icon_name(app_icon_name_, Gtk::ICON_SIZE_INVALID); image_.set_from_icon_name(app_icon_name_, Gtk::ICON_SIZE_INVALID);
image_.set_visible(true); image_.set_visible(true);

View File

@ -37,19 +37,19 @@ const Bar::bar_mode_map Bar::PRESET_MODES = { //
.visible = true}}, .visible = true}},
{"hide", {"hide",
{// {//
.layer = bar_layer::TOP, .layer = bar_layer::OVERLAY,
.exclusive = false, .exclusive = false,
.passthrough = false, .passthrough = false,
.visible = true}}, .visible = true}},
{"invisible", {"invisible",
{// {//
.layer = std::nullopt, .layer = bar_layer::BOTTOM,
.exclusive = false, .exclusive = false,
.passthrough = true, .passthrough = true,
.visible = false}}, .visible = false}},
{"overlay", {"overlay",
{// {//
.layer = bar_layer::TOP, .layer = bar_layer::OVERLAY,
.exclusive = false, .exclusive = false,
.passthrough = true, .passthrough = true,
.visible = true}}}; .visible = true}}};
@ -59,7 +59,7 @@ const std::string Bar::MODE_INVISIBLE = "invisible";
const std::string_view DEFAULT_BAR_ID = "bar-0"; const std::string_view DEFAULT_BAR_ID = "bar-0";
/* Deserializer for enum bar_layer */ /* Deserializer for enum bar_layer */
void from_json(const Json::Value& j, std::optional<bar_layer>& l) { void from_json(const Json::Value& j, bar_layer& l) {
if (j == "bottom") { if (j == "bottom") {
l = bar_layer::BOTTOM; l = bar_layer::BOTTOM;
} else if (j == "top") { } else if (j == "top") {
@ -132,6 +132,7 @@ void from_json(const Json::Value& j, std::map<Key, Value>& m) {
waybar::Bar::Bar(struct waybar_output* w_output, const Json::Value& w_config) waybar::Bar::Bar(struct waybar_output* w_output, const Json::Value& w_config)
: output(w_output), : output(w_output),
config(w_config), config(w_config),
surface(nullptr),
window{Gtk::WindowType::WINDOW_TOPLEVEL}, window{Gtk::WindowType::WINDOW_TOPLEVEL},
x_global(0), x_global(0),
y_global(0), y_global(0),
@ -316,13 +317,13 @@ void waybar::Bar::setMode(const std::string& mode) {
void waybar::Bar::setMode(const struct bar_mode& mode) { void waybar::Bar::setMode(const struct bar_mode& mode) {
auto* gtk_window = window.gobj(); auto* gtk_window = window.gobj();
if (mode.layer == bar_layer::BOTTOM) { auto layer = GTK_LAYER_SHELL_LAYER_BOTTOM;
gtk_layer_set_layer(gtk_window, GTK_LAYER_SHELL_LAYER_BOTTOM); if (mode.layer == bar_layer::TOP) {
} else if (mode.layer == bar_layer::TOP) { layer = GTK_LAYER_SHELL_LAYER_TOP;
gtk_layer_set_layer(gtk_window, GTK_LAYER_SHELL_LAYER_TOP);
} else if (mode.layer == bar_layer::OVERLAY) { } else if (mode.layer == bar_layer::OVERLAY) {
gtk_layer_set_layer(gtk_window, GTK_LAYER_SHELL_LAYER_OVERLAY); layer = GTK_LAYER_SHELL_LAYER_OVERLAY;
} }
gtk_layer_set_layer(gtk_window, layer);
if (mode.exclusive) { if (mode.exclusive) {
gtk_layer_auto_exclusive_zone_enable(gtk_window); gtk_layer_auto_exclusive_zone_enable(gtk_window);
@ -339,6 +340,13 @@ void waybar::Bar::setMode(const struct bar_mode& mode) {
window.get_style_context()->add_class("hidden"); window.get_style_context()->add_class("hidden");
window.set_opacity(0); window.set_opacity(0);
} }
/*
* All the changes above require `wl_surface_commit`.
* gtk-layer-shell schedules a commit on the next frame event in GTK, but this could fail in
* certain scenarios, such as fully occluded bar.
*/
gtk_layer_try_force_commit(gtk_window);
wl_display_flush(Client::inst()->wl_display);
} }
void waybar::Bar::setPassThrough(bool passthrough) { void waybar::Bar::setPassThrough(bool passthrough) {

View File

@ -104,11 +104,9 @@ void Item::proxyReady(Glib::RefPtr<Gio::AsyncResult>& result) {
this->updateImage(); this->updateImage();
} catch (const Glib::Error& err) { } catch (const Glib::Error& err) {
spdlog::error("Failed to create DBus Proxy for {} {}: {}", bus_name, object_path, spdlog::error("Failed to create DBus Proxy for {} {}: {}", bus_name, object_path, err.what());
std::string(err.what()));
} catch (const std::exception& err) { } catch (const std::exception& err) {
spdlog::error("Failed to create DBus Proxy for {} {}: {}", bus_name, object_path, spdlog::error("Failed to create DBus Proxy for {} {}: {}", bus_name, object_path, err.what());
std::string(err.what()));
} }
} }
@ -126,15 +124,14 @@ ToolTip get_variant<ToolTip>(const Glib::VariantBase& value) {
result.text = get_variant<Glib::ustring>(container.get_child(2)); result.text = get_variant<Glib::ustring>(container.get_child(2));
auto description = get_variant<Glib::ustring>(container.get_child(3)); auto description = get_variant<Glib::ustring>(container.get_child(3));
if (!description.empty()) { if (!description.empty()) {
result.text = fmt::format("<b>{}</b>\n{}", std::string(result.text), std::string(description)); result.text = fmt::format("<b>{}</b>\n{}", result.text, description);
} }
return result; return result;
} }
void Item::setProperty(const Glib::ustring& name, Glib::VariantBase& value) { void Item::setProperty(const Glib::ustring& name, Glib::VariantBase& value) {
try { try {
spdlog::trace("Set tray item property: {}.{} = {}", id.empty() ? bus_name : id, spdlog::trace("Set tray item property: {}.{} = {}", id.empty() ? bus_name : id, name, value);
std::string(name), get_variant<std::string>(value));
if (name == "Category") { if (name == "Category") {
category = get_variant<std::string>(value); category = get_variant<std::string>(value);
@ -179,12 +176,10 @@ void Item::setProperty(const Glib::ustring& name, Glib::VariantBase& value) {
} }
} catch (const Glib::Error& err) { } catch (const Glib::Error& err) {
spdlog::warn("Failed to set tray item property: {}.{}, value = {}, err = {}", spdlog::warn("Failed to set tray item property: {}.{}, value = {}, err = {}",
id.empty() ? bus_name : id, std::string(name), get_variant<std::string>(value), id.empty() ? bus_name : id, name, value, err.what());
std::string(err.what()));
} catch (const std::exception& err) { } catch (const std::exception& err) {
spdlog::warn("Failed to set tray item property: {}.{}, value = {}, err = {}", spdlog::warn("Failed to set tray item property: {}.{}, value = {}, err = {}",
id.empty() ? bus_name : id, std::string(name), get_variant<std::string>(value), id.empty() ? bus_name : id, name, value, err.what());
std::string(err.what()));
} }
} }
@ -226,9 +221,9 @@ void Item::processUpdatedProperties(Glib::RefPtr<Gio::AsyncResult>& _result) {
this->updateImage(); this->updateImage();
} catch (const Glib::Error& err) { } catch (const Glib::Error& err) {
spdlog::warn("Failed to update properties: {}", std::string(err.what())); spdlog::warn("Failed to update properties: {}", err.what());
} catch (const std::exception& err) { } catch (const std::exception& err) {
spdlog::warn("Failed to update properties: {}", std::string(err.what())); spdlog::warn("Failed to update properties: {}", err.what());
} }
update_pending_.clear(); update_pending_.clear();
} }
@ -250,7 +245,7 @@ static const std::map<std::string_view, std::set<std::string_view>> signal2props
void Item::onSignal(const Glib::ustring& sender_name, const Glib::ustring& signal_name, void Item::onSignal(const Glib::ustring& sender_name, const Glib::ustring& signal_name,
const Glib::VariantContainerBase& arguments) { const Glib::VariantContainerBase& arguments) {
spdlog::trace("Tray item '{}' got signal {}", id, std::string(signal_name)); spdlog::trace("Tray item '{}' got signal {}", id, signal_name);
auto changed = signal2props.find(signal_name.raw()); auto changed = signal2props.find(signal_name.raw());
if (changed != signal2props.end()) { if (changed != signal2props.end()) {
if (update_pending_.empty()) { if (update_pending_.empty()) {

View File

@ -1,13 +1,13 @@
[wrap-file] [wrap-file]
directory = fmt-11.0.1 directory = fmt-11.0.2
source_url = https://github.com/fmtlib/fmt/archive/11.0.1.tar.gz source_url = https://github.com/fmtlib/fmt/archive/11.0.2.tar.gz
source_filename = fmt-11.0.1.tar.gz source_filename = fmt-11.0.2.tar.gz
source_hash = 7d009f7f89ac84c0a83f79ed602463d092fbf66763766a907c97fd02b100f5e9 source_hash = 6cb1e6d37bdcb756dbbe59be438790db409cdb4868c66e888d5df9f13f7c027f
patch_filename = fmt_11.0.1-1_patch.zip patch_filename = fmt_11.0.2-1_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/fmt_11.0.1-1/get_patch patch_url = https://wrapdb.mesonbuild.com/v2/fmt_11.0.2-1/get_patch
patch_hash = 0a8b93d1ee6d84a82d3872a9bfb4c3977d8a53f7f484d42d1f7ed63ed496d549 patch_hash = 90c9e3b8e8f29713d40ca949f6f93ad115d78d7fb921064112bc6179e6427c5e
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/fmt_11.0.1-1/fmt-11.0.1.tar.gz source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/fmt_11.0.2-1/fmt-11.0.2.tar.gz
wrapdb_version = 11.0.1-1 wrapdb_version = 11.0.2-1
[provide] [provide]
fmt = fmt_dep fmt = fmt_dep