From 82caca68ba344d35a30a05a13e4aa658df867b52 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Sun, 6 Oct 2019 08:28:44 -0700 Subject: [PATCH] Fix drawing border with GTK3 when non-native control is a child of a native widget Such as wxSearchCtrl in GtkToolbar. See #18522 --- src/gtk/window.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 5338cda85b..14bbcf1d55 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -444,7 +444,7 @@ static gboolean expose_event(GtkWidget*, GdkEventExpose* gdk_event, wxWindow* wi extern "C" { static gboolean #ifdef __WXGTK3__ -draw_border(GtkWidget*, cairo_t* cr, wxWindow* win) +draw_border(GtkWidget* widget, cairo_t* cr, wxWindow* win) #else draw_border(GtkWidget* widget, GdkEventExpose* gdk_event, wxWindow* win) #endif @@ -461,10 +461,20 @@ draw_border(GtkWidget* widget, GdkEventExpose* gdk_event, wxWindow* win) GtkAllocation alloc; gtk_widget_get_allocation(win->m_wxwindow, &alloc); - const int x = alloc.x; - const int y = alloc.y; + int x = alloc.x; + int y = alloc.y; const int w = alloc.width; const int h = alloc.height; +#ifdef __WXGTK3__ + if (!gtk_widget_get_has_window(widget)) + { + // cairo_t origin is set to widget's origin, need to adjust + // coordinates for child when they are not relative to parent + gtk_widget_get_allocation(widget, &alloc); + x -= alloc.x; + y -= alloc.y; + } +#endif if (w <= 0 || h <= 0) return false;