fe5a6f0
From cd8811bf142172c4920ba13a685472ceb405ef78 Mon Sep 17 00:00:00 2001
fe5a6f0
From: Paul Cornett <paulcor@users.noreply.github.com>
fe5a6f0
Date: Thu, 3 Nov 2016 09:14:30 -0700
fe5a6f0
Subject: [PATCH] Fix paint clipping region with GTK+ >= 3.20
fe5a6f0
fe5a6f0
Apparently the clip is no longer set properly. Fixes wxDC::Clear() overwriting
fe5a6f0
areas outside the window. Problem can be seen in the Audacity toolbars.
fe5a6f0
fe5a6f0
(cherry picked from commit bca7313499c11a6d7fecd2baa355ac09fd3ac83b)
fe5a6f0
---
fe5a6f0
 src/gtk/window.cpp | 14 +++++++++++++-
fe5a6f0
 1 file changed, 13 insertions(+), 1 deletion(-)
fe5a6f0
fe5a6f0
diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp
fe5a6f0
index 41fffb4..96789de 100644
fe5a6f0
--- a/src/gtk/window.cpp
fe5a6f0
+++ b/src/gtk/window.cpp
fe5a6f0
@@ -4099,9 +4099,21 @@ void wxWindowGTK::GTKSendPaintEvents(const GdkRegion* region)
fe5a6f0
 #endif
fe5a6f0
 {
fe5a6f0
 #ifdef __WXGTK3__
fe5a6f0
-    m_paintContext = cr;
fe5a6f0
+    {
fe5a6f0
+        cairo_region_t* region = gdk_window_get_clip_region(gtk_widget_get_window(m_wxwindow));
fe5a6f0
+        cairo_rectangle_int_t rect;
fe5a6f0
+        cairo_region_get_extents(region, &rect);
fe5a6f0
+        cairo_region_destroy(region);
fe5a6f0
+        cairo_rectangle(cr, rect.x, rect.y, rect.width, rect.height);
fe5a6f0
+        cairo_clip(cr);
fe5a6f0
+    }
fe5a6f0
     double x1, y1, x2, y2;
fe5a6f0
     cairo_clip_extents(cr, &x1, &y1, &x2, &y2;;
fe5a6f0
+
fe5a6f0
+    if (x1 >= x2 || y1 >= y2)
fe5a6f0
+        return;
fe5a6f0
+
fe5a6f0
+    m_paintContext = cr;
fe5a6f0
     m_updateRegion = wxRegion(int(x1), int(y1), int(x2 - x1), int(y2 - y1));
fe5a6f0
 #else // !__WXGTK3__
fe5a6f0
     m_updateRegion = wxRegion(region);