From 434935613cc42abc616aacc6b62c170e80e98a6a Mon Sep 17 00:00:00 2001 From: John Beard Date: Sun, 28 Apr 2019 17:00:00 +0100 Subject: [PATCH] Eeschema: Fix/circumvert GTK3 tree view bug There is a rendering bug in GTK3, which appears to be an upstream GTK issue. This can be worked around by, when filtering, ensuring the *parent* item of the selected item is visible. This will not cause the selected item to not be visible, as the selected item will be the first shown child. So it will be visible, as long as the list box is greater than a single row high, which it will be in all practical scenarios. This is done on all platforms, as it has a beneficial side-effect: the parent library of the selection is naturally shown to the user, so they don't need to scroll up to see what library their current filter selection was in. Fixes: lp:1804400 * https://bugs.launchpad.net/kicad/+bug/1804400 (cherry picked from commit 10900c918f14563d4007bfa2ac8a59081ee1437a) --- common/lib_tree_model_adapter.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/common/lib_tree_model_adapter.cpp b/common/lib_tree_model_adapter.cpp index 422ec5debc..0a26788af4 100644 --- a/common/lib_tree_model_adapter.cpp +++ b/common/lib_tree_model_adapter.cpp @@ -182,6 +182,22 @@ void LIB_TREE_MODEL_ADAPTER::UpdateSearchString( wxString const& aSearch ) { auto item = wxDataViewItem( bestMatch ); m_widget->Select( item ); + + // Make sure the *parent* item is visible. The selected item is the + // first (shown) child of the parent. So it's always right below the parent, + // and this way the user can also see what library the selected part belongs to, + // without having a case where the selection is off the screen (unless the + // window is a single row high, which is unlikely) + // + // This also happens to circumvent https://bugs.launchpad.net/kicad/+bug/1804400 + // which appears to be a GTK+3 bug. + { + wxDataViewItem parent = GetParent( item ); + + if( parent.IsOk() ) + item = parent; + } + m_widget->EnsureVisible( item ); }