Fix mouse event coordinates for single-line wxTextCtrl with GTK3

This commit is contained in:
Paul Cornett
2021-01-21 11:27:00 -08:00
parent 5473dfbfa4
commit 638f0f89fc

View File

@@ -59,6 +59,21 @@ template<typename T> void InitMouseEvent(wxWindowGTK *win,
event.m_x = (wxCoord)gdk_event->x - pt.x;
event.m_y = (wxCoord)gdk_event->y - pt.y;
// Some no-window widgets, notably GtkEntry on GTK3, have a GdkWindow
// covering part of their area. Event coordinates from that window are
// not relative to the widget, so do the conversion here.
if (!gtk_widget_get_has_window(win->m_widget) &&
gtk_widget_get_window(win->m_widget) == gdk_window_get_parent(gdk_event->window))
{
GtkAllocation a;
gtk_widget_get_allocation(win->m_widget, &a);
int posX, posY;
gdk_window_get_position(gdk_event->window, &posX, &posY);
event.m_x += posX - a.x;
event.m_y += posY - a.y;
}
if ((win->m_wxwindow) && (win->GetLayoutDirection() == wxLayout_RightToLeft))
{
// origin in the upper right corner