Use more accurate source for wxClientDC size with GTK3

Because GdkWindow size is updated somewhat asynchronously, it can lag behind
current window size. So get size from wxWindow instead. See #19062
This commit is contained in:
Paul Cornett
2021-01-28 07:30:19 -08:00
parent 9d45591e15
commit 22349a79aa

View File

@@ -307,6 +307,7 @@ wxClientDCImpl::wxClientDCImpl(wxClientDC* owner, wxWindow* window)
GdkWindow* gdkWindow = NULL; GdkWindow* gdkWindow = NULL;
if (widget) if (widget)
{ {
window->GetClientSize(&m_size.x, &m_size.y);
gdkWindow = gtk_widget_get_window(widget); gdkWindow = gtk_widget_get_window(widget);
m_ok = true; m_ok = true;
} }
@@ -317,17 +318,10 @@ wxClientDCImpl::wxClientDCImpl(wxClientDC* owner, wxWindow* window)
cairo_destroy(cr); cairo_destroy(cr);
gc->EnableOffset(m_contentScaleFactor <= 1); gc->EnableOffset(m_contentScaleFactor <= 1);
SetGraphicsContext(gc); SetGraphicsContext(gc);
if (gtk_widget_get_has_window(widget)) if (!gtk_widget_get_has_window(widget))
{
m_size.x = gdk_window_get_width(gdkWindow);
m_size.y = gdk_window_get_height(gdkWindow);
}
else
{ {
GtkAllocation a; GtkAllocation a;
gtk_widget_get_allocation(widget, &a); gtk_widget_get_allocation(widget, &a);
m_size.x = a.width;
m_size.y = a.height;
cairo_rectangle(cr, a.x, a.y, a.width, a.height); cairo_rectangle(cr, a.x, a.y, a.width, a.height);
cairo_clip(cr); cairo_clip(cr);
SetDeviceLocalOrigin(a.x, a.y); SetDeviceLocalOrigin(a.x, a.y);