From f35bec8056d81da597d26a72c4b631690c74e7b7 Mon Sep 17 00:00:00 2001 From: Lisael Date: Fri, 9 Jul 2021 16:02:23 +0200 Subject: [PATCH] Fix focus on hidden widget in Either (#1860) * Fix focus on hidden widget in Either * udpate CHANGELOG and AUTHORS * Fix (?) hidden widget focus bug in Tab I couldn't reproduce the bug in the example as the tab bar steals the focus anyway when we click on a tab Whatever, it's still cleaner. I also removed spurious ctx.request_layout calls, as it's already called in ctx.children_changed * update the changelog Co-authored-by: Bruno Dupuis Co-authored-by: Christoph --- AUTHORS | 1 + CHANGELOG.md | 3 +++ druid/src/widget/either.rs | 2 +- druid/src/widget/tabs.rs | 6 +----- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/AUTHORS b/AUTHORS index 22ddab5b01..71553959d2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -15,3 +15,4 @@ Garrett Risley Robert Wittams Jaap Aarts Maximilian Köstler +Bruno Dupuis diff --git a/CHANGELOG.md b/CHANGELOG.md index b85a23205d..2c20904e5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,6 +84,7 @@ You can find its changes [documented below](#070---2021-01-01). - X11 backend now supports scaling([#1751] by [@Maan2003]) - X11 backend now supports changing cursors ([#1755] by [@Maan2003]) - X11 backend now uses the platform locale ([#1756] by [@Maan2003]) +- `Either` and `Tab` widgets were still propagating events to hidden widgets ([#1860] by [@lisael]) ### Visual @@ -493,6 +494,7 @@ Last release without a changelog :( [@r-ml]: https://github.com/r-ml [@djeedai]: https://github.com/djeedai [@bjorn]: https://github.com/bjorn +[@lisael]: https://github.com/lisael [#599]: https://github.com/linebender/druid/pull/599 [#611]: https://github.com/linebender/druid/pull/611 @@ -744,6 +746,7 @@ Last release without a changelog :( [#1825]: https://github.com/linebender/druid/pull/1825 [#1843]: https://github.com/linebender/druid/pull/1843 [#1851]: https://github.com/linebender/druid/pull/1851 +[#1860]: https://github.com/linebender/druid/pull/1860 [#1861]: https://github.com/linebender/druid/pull/1861 [#1863]: https://github.com/linebender/druid/pull/1863 diff --git a/druid/src/widget/either.rs b/druid/src/widget/either.rs index aa86b56023..3fa03bc48f 100644 --- a/druid/src/widget/either.rs +++ b/druid/src/widget/either.rs @@ -75,7 +75,7 @@ impl Widget for Either { let current = (self.closure)(data, env); if current != self.current { self.current = current; - ctx.request_layout(); + ctx.children_changed(); } self.current_widget().update(ctx, data, env) } diff --git a/druid/src/widget/tabs.rs b/druid/src/widget/tabs.rs index 13057b94ce..9c8693030c 100644 --- a/druid/src/widget/tabs.rs +++ b/druid/src/widget/tabs.rs @@ -374,7 +374,6 @@ impl Widget> for TabBar { if let LifeCycle::WidgetAdded = event { self.ensure_tabs(data); ctx.children_changed(); - ctx.request_layout(); } for (_, tab) in self.tabs.iter_mut() { @@ -397,7 +396,6 @@ impl Widget> for TabBar { if data.policy.tabs_changed(&old_data.inner, &data.inner) { self.ensure_tabs(data); ctx.children_changed(); - ctx.request_layout(); } else if old_data.selected != data.selected { ctx.request_paint(); } @@ -611,7 +609,6 @@ impl Widget> for TabsBody { if let LifeCycle::WidgetAdded = event { self.make_tabs(data); ctx.children_changed(); - ctx.request_layout(); } if event.should_propagate_to_hidden() { @@ -638,7 +635,6 @@ impl Widget> for TabsBody { ) { let init = if data.policy.tabs_changed(&old_data.inner, &data.inner) { ctx.children_changed(); - ctx.request_layout(); Some(self.make_tabs(data)) } else { None @@ -648,7 +644,7 @@ impl Widget> for TabsBody { self.transition_state = self .transition .tab_changed(old_data.selected, data.selected); - ctx.request_layout(); + ctx.children_changed(); if self.transition_state.is_some() { ctx.request_anim_frame();