From 892795ac9cf46e873ed31852b069f50cdd49c0ba Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Tue, 19 Jan 2021 22:50:41 -0800 Subject: [PATCH] Apply a better fix for HitTest failures in the tests with GTK3 The actual cause of the problem was the tests making the single-line text control height far too large. So just use the default height for single-line controls. --- src/gtk/textctrl.cpp | 10 ---------- tests/controls/textctrltest.cpp | 8 +++++--- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 2fe014a3c8..86adcd3bd4 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -1582,17 +1582,7 @@ wxTextCtrl::HitTest(const wxPoint& pt, long *pos) const gtk_entry_get_layout_offsets(GTK_ENTRY(m_text), &ofsX, &ofsY); x -= ofsX; - - // There is something really weird going on with vertical offset under - // GTK 3: normally it is just 0, because a single line control doesn't - // scroll vertically anyhow, but sometimes it can have big positive or - // negative values after scrolling horizontally, resulting in test - // failures in TextCtrlTestCase::HitTestSingleLine::Scrolled. So just - // ignore it completely, as, again, it shouldn't matter for single line - // text controls in any case, and so do not do this: -#ifndef __WXGTK3__ y -= ofsY; -#endif // !__WXGTK3__ // And scale the coordinates for Pango. x *= PANGO_SCALE; diff --git a/tests/controls/textctrltest.cpp b/tests/controls/textctrltest.cpp index 3990fc675b..9d17f13892 100644 --- a/tests/controls/textctrltest.cpp +++ b/tests/controls/textctrltest.cpp @@ -166,14 +166,16 @@ long TextCtrlTestCase::ms_style = 0; void TextCtrlTestCase::CreateText(long extraStyles) { + const long style = ms_style | extraStyles; + const int h = (style & wxTE_MULTILINE) ? TEXT_HEIGHT : -1; m_text = new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, "", - wxDefaultPosition, wxSize(400, TEXT_HEIGHT), - ms_style | extraStyles); + wxDefaultPosition, wxSize(400, h), + style); } void TextCtrlTestCase::setUp() { - CreateText(ms_style); + CreateText(0); } void TextCtrlTestCase::tearDown()