From 22349a79aa21ce6b8c9a92376d46cd0f1f91282b Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Thu, 28 Jan 2021 07:30:19 -0800 Subject: [PATCH] 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 --- src/gtk/dc.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/gtk/dc.cpp b/src/gtk/dc.cpp index e2da24f70b..753da3e76c 100644 --- a/src/gtk/dc.cpp +++ b/src/gtk/dc.cpp @@ -307,6 +307,7 @@ wxClientDCImpl::wxClientDCImpl(wxClientDC* owner, wxWindow* window) GdkWindow* gdkWindow = NULL; if (widget) { + window->GetClientSize(&m_size.x, &m_size.y); gdkWindow = gtk_widget_get_window(widget); m_ok = true; } @@ -317,17 +318,10 @@ wxClientDCImpl::wxClientDCImpl(wxClientDC* owner, wxWindow* window) cairo_destroy(cr); gc->EnableOffset(m_contentScaleFactor <= 1); SetGraphicsContext(gc); - if (gtk_widget_get_has_window(widget)) - { - m_size.x = gdk_window_get_width(gdkWindow); - m_size.y = gdk_window_get_height(gdkWindow); - } - else + if (!gtk_widget_get_has_window(widget)) { GtkAllocation 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_clip(cr); SetDeviceLocalOrigin(a.x, a.y);