Fix drawing border with GTK3 when non-native control is a child of a native widget

Such as wxSearchCtrl in GtkToolbar. See #18522
This commit is contained in:
Paul Cornett
2019-10-06 08:28:44 -07:00
parent 95d63c1fca
commit 82caca68ba

View File

@@ -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;