From 9ad8b6d6b7bbb7f42b8ad09519f2529eadf234e5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 17 Jul 2019 16:07:53 +0200 Subject: [PATCH] Fix bug in scrolled single line wxTextCtrl::HitTest() with GTK 3 There seems to be something wrong with the vertical offset returned by gtk_entry_get_layout_offsets() in GTK 3, so just don't use it at all, as we don't need it anyhow. --- src/gtk/textctrl.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 190c6840eb..b19a3f5367 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -1451,7 +1451,17 @@ 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;