From bde9072f68db1fed276e2ca376a1d95b4b8998d2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 3 Oct 2001 17:01:29 +0000 Subject: [PATCH] reduced flicker when switching focus to/from the report list ctrl under wxGTK git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11808 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/listctrl.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 38ff1e693c..b3680c13d5 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -2621,6 +2621,14 @@ void wxListMainWindow::RefreshSelected() to = GetItemCount() - 1; } + // VZ: this code would work fine if wxGTK wxWindow::Refresh() were + // reasonable, i.e. if it only generated one expose event for + // several calls to it - as it is, each Refresh() results in a + // repaint which provokes flicker too horrible to be seen + // + // when/if wxGTK is fixed, this code should be restored as normally it + // should generate _less_ flicker than the version below +#ifndef __WXGTK__ if ( HasCurrent() && m_current >= from && m_current <= to ) { RefreshLine(m_current); @@ -2634,6 +2642,26 @@ void wxListMainWindow::RefreshSelected() RefreshLine(line); } } +#else // __WXGTK__ + size_t selMin = (size_t)-1, + selMax = 0; + + for ( size_t line = from; line <= to; line++ ) + { + if ( IsHighlighted(line) ) + { + if ( line < selMin ) + selMin = line; + if ( line > selMax ) + selMax = line; + } + } + + if ( selMin != (size_t)-1 ) + { + RefreshLines(selMin, selMax); + } +#endif // !__WXGTK__/__WXGTK__ } void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) @@ -3361,6 +3389,13 @@ extern wxWindow *g_focusWindow; void wxListMainWindow::OnSetFocus( wxFocusEvent &WXUNUSED(event) ) { + // wxGTK sends us EVT_SET_FOCUS events even if we had never got + // EVT_KILL_FOCUS before which means that we finish by redrawing the items + // which are already drawn correctly resulting in horrible flicker - avoid + // it + if ( m_hasFocus ) + return; + m_hasFocus = TRUE; if (!GetParent()) -- 2.47.2