Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ All notable changes to eww will be listed here, starting at changes since versio
Attempting to index in an empty JSON string (`'""'`) is now an error.

### Fixes
- Fix `:visible` updates being lost for widgets that have not yet been mapped, e.g. inside a closed revealer (By: 61021)
- Fix crash on invalid `formattime` format string (By: luca3s)
- Fix crash on NaN or infinite graph value (By: luca3s)
- Re-enable some scss features (By: w-lfchen)
Expand Down
20 changes: 14 additions & 6 deletions crates/eww/src/widgets/widget_definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use itertools::Itertools;
use once_cell::sync::Lazy;

use std::{
cell::RefCell,
cell::{Cell, RefCell},
cmp::Ordering,
collections::{HashMap, HashSet},
rc::Rc,
Expand Down Expand Up @@ -150,15 +150,22 @@ pub(super) fn resolve_widget_attrs(bargs: &mut BuilderArgs, gtk_widget: &gtk::Wi
let css_provider = gtk::CssProvider::new();
let css_provider2 = css_provider.clone();

// the first-map handler reads this cell so `visible` updates before the first map aren't lost
// (a closed revealer's children map long after build)
let latest_visible = Rc::new(Cell::new(true));
let visible_result: Result<_> = (|| {
let visible_expr = bargs.widget_use.attrs.attrs.get("visible").map(|x| x.value.as_simplexpr()).transpose()?;
if let Some(visible_expr) = visible_expr {
let visible = bargs.scope_graph.evaluate_simplexpr_in_scope(bargs.calling_scope, &visible_expr)?.as_bool()?;
connect_first_map(gtk_widget, move |w| {
if visible {
w.show();
} else {
w.hide();
latest_visible.set(visible);
connect_first_map(gtk_widget, {
let latest_visible = latest_visible.clone();
move |w| {
if latest_visible.get() {
w.show();
} else {
w.hide();
}
}
});
}
Expand Down Expand Up @@ -207,6 +214,7 @@ pub(super) fn resolve_widget_attrs(bargs: &mut BuilderArgs, gtk_widget: &gtk::Wi
},
// @prop visible - visibility of the widget
prop(visible: as_bool = true) {
latest_visible.set(visible);
if visible { gtk_widget.show(); } else { gtk_widget.hide(); }
},
// @prop style - inline scss style applied to the widget
Expand Down