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:
@@ -444,7 +444,7 @@ static gboolean expose_event(GtkWidget*, GdkEventExpose* gdk_event, wxWindow* wi
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
static gboolean
|
static gboolean
|
||||||
#ifdef __WXGTK3__
|
#ifdef __WXGTK3__
|
||||||
draw_border(GtkWidget*, cairo_t* cr, wxWindow* win)
|
draw_border(GtkWidget* widget, cairo_t* cr, wxWindow* win)
|
||||||
#else
|
#else
|
||||||
draw_border(GtkWidget* widget, GdkEventExpose* gdk_event, wxWindow* win)
|
draw_border(GtkWidget* widget, GdkEventExpose* gdk_event, wxWindow* win)
|
||||||
#endif
|
#endif
|
||||||
@@ -461,10 +461,20 @@ draw_border(GtkWidget* widget, GdkEventExpose* gdk_event, wxWindow* win)
|
|||||||
|
|
||||||
GtkAllocation alloc;
|
GtkAllocation alloc;
|
||||||
gtk_widget_get_allocation(win->m_wxwindow, &alloc);
|
gtk_widget_get_allocation(win->m_wxwindow, &alloc);
|
||||||
const int x = alloc.x;
|
int x = alloc.x;
|
||||||
const int y = alloc.y;
|
int y = alloc.y;
|
||||||
const int w = alloc.width;
|
const int w = alloc.width;
|
||||||
const int h = alloc.height;
|
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)
|
if (w <= 0 || h <= 0)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user