if (m_pen.GetStyle() != wxTRANSPARENT)
{
+/*
for (i = 0 ; i < n ; i++)
{
gdk_draw_line( m_window, m_penGC,
gdkpoints[(i+1)%n].x,
gdkpoints[(i+1)%n].y);
}
+*/
+ gdk_draw_polygon( m_window, m_penGC, FALSE, gdkpoints, n );
+
}
}
IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxClientDC)
+// Limit the paint region to the window size. Sometimes
+// the paint region is too big, and this risks X11 errors
+static void wxLimitRegionToSize(wxRegion& region, const wxSize& sz)
+{
+ wxRect originalRect = region.GetBox();
+ wxRect rect(originalRect);
+ if (rect.width + rect.x > sz.x)
+ rect.width = sz.x - rect.x;
+ if (rect.height + rect.y > sz.y)
+ rect.height = sz.y - rect.y;
+ if (rect != originalRect)
+ {
+ region = wxRegion(rect);
+ wxLogTrace(wxT("painting"), wxT("Limiting region from %d, %d, %d, %d to %d, %d, %d, %d\n"),
+ originalRect.x, originalRect.y, originalRect.width, originalRect.height,
+ rect.x, rect.y, rect.width, rect.height);
+ }
+}
+
wxPaintDC::wxPaintDC( wxWindow *win )
: wxClientDC( win )
{
if (!win->m_clipPaintRegion)
return;
+ wxSize sz = win->GetSize();
m_paintClippingRegion = win->GetUpdateRegion();
+ wxLimitRegionToSize(m_paintClippingRegion, sz);
+
GdkRegion *region = m_paintClippingRegion.GetRegion();
if ( region )
{
- m_paintClippingRegion = win->GetUpdateRegion();
- GdkRegion *region = m_paintClippingRegion.GetRegion();
- if ( region )
- {
- m_currentClippingRegion.Union( m_paintClippingRegion );
+ m_currentClippingRegion.Union( m_paintClippingRegion );
+ wxLimitRegionToSize(m_currentClippingRegion, sz);
- gdk_gc_set_clip_region( m_penGC, region );
- gdk_gc_set_clip_region( m_brushGC, region );
- gdk_gc_set_clip_region( m_textGC, region );
- gdk_gc_set_clip_region( m_bgGC, region );
- }
+ if (sz.x <= 0 || sz.y <= 0)
+ return ;
+
+ gdk_gc_set_clip_region( m_penGC, region );
+ gdk_gc_set_clip_region( m_brushGC, region );
+ gdk_gc_set_clip_region( m_textGC, region );
+ gdk_gc_set_clip_region( m_bgGC, region );
}
#endif // USE_PAINT_REGION
}