diff -ur pnetlib/System.Drawing/Toolkit/IToolkitWindowBuffer.cs pnetlib.new/System.Drawing/Toolkit/IToolkitWindowBuffer.cs --- pnetlib/System.Drawing/Toolkit/IToolkitWindowBuffer.cs 2004-01-19 00:03:16.000000000 +0100 +++ pnetlib.new/System.Drawing/Toolkit/IToolkitWindowBuffer.cs 2005-09-08 14:13:02.065566875 +0200 @@ -29,8 +29,8 @@ public interface IToolkitWindowBuffer : IDisposable { // Return a buffer toolkit graphics to do the cached drawing. - IToolkitGraphics BeginDoubleBuffer(); + IToolkitGraphics BeginDoubleBuffer(Rectangle r); // Write the cache to the screen and dispose the toolkit graphics. void EndDoubleBuffer(); } -} \ No newline at end of file +} diff -ur pnetlib/System.Drawing.Win32/DrawingWindowBuffer.cs pnetlib.new/System.Drawing.Win32/DrawingWindowBuffer.cs --- pnetlib/System.Drawing.Win32/DrawingWindowBuffer.cs 2004-01-19 02:53:46.000000000 +0100 +++ pnetlib.new/System.Drawing.Win32/DrawingWindowBuffer.cs 2005-09-08 14:22:01.628293606 +0200 @@ -51,7 +51,7 @@ } - public IToolkitGraphics BeginDoubleBuffer() + public IToolkitGraphics BeginDoubleBuffer(System.Drawing.Rectangle r) { Size newSize = (window as IToolkitWindow).Dimensions.Size; // If the size changes, we need to recreate the buffer. @@ -93,4 +93,4 @@ } } -} \ No newline at end of file +} diff -ur pnetlib/System.Drawing.Xsharp/DrawingWindowBuffer.cs pnetlib.new/System.Drawing.Xsharp/DrawingWindowBuffer.cs --- pnetlib/System.Drawing.Xsharp/DrawingWindowBuffer.cs 2004-01-24 02:16:21.000000000 +0100 +++ pnetlib.new/System.Drawing.Xsharp/DrawingWindowBuffer.cs 2005-09-08 14:20:35.020289314 +0200 @@ -64,7 +64,7 @@ } // Begin a double buffer operation. - public IToolkitGraphics BeginDoubleBuffer() + public IToolkitGraphics BeginDoubleBuffer(System.Drawing.Rectangle r) { // Create the double buffer if necessary. if(buffer == null) @@ -72,6 +72,9 @@ CreateBuffer(widget.Width, widget.Height); } + Xsharp.Rectangle rect = new Xsharp.Rectangle (r.X, r.Y, r.Width, r.Height); + buffer.SetClipRectangle (rect); + // Create a graphics object for the buffer and return it. graphics = new DrawingGraphics (toolkit, new Xsharp.Graphics(buffer)); diff -ur pnetlib/System.Windows.Forms/Control.cs pnetlib.new/System.Windows.Forms/Control.cs --- pnetlib/System.Windows.Forms/Control.cs 2005-09-01 09:25:57.000000000 +0200 +++ pnetlib.new/System.Windows.Forms/Control.cs 2005-09-08 15:27:27.979669066 +0200 @@ -5938,7 +5938,8 @@ { Graphics gFull = null; Graphics g = null; - IToolkitGraphics toolkitGraphics = buffer.BeginDoubleBuffer(); + IToolkitGraphics toolkitGraphics = buffer.BeginDoubleBuffer(clipBounds); + toolkitGraphics.SetClipRect (clipBounds.X, clipBounds.Y, clipBounds.Width, clipBounds.Height); try { if (borderStyle != BorderStyle.None) @@ -5948,6 +5949,7 @@ } g = ToolkitManager.CreateGraphics(toolkitGraphics, clientRectangle); + g.SetClip (clipBounds); PaintEventArgs e = new PaintEventArgs(g, clipBounds); if (GetStyle(ControlStyles.AllPaintingInWmPaint)) diff -ur pnetlib/Xsharp/DoubleBuffer.cs pnetlib.new/Xsharp/DoubleBuffer.cs --- pnetlib/Xsharp/DoubleBuffer.cs 2005-03-10 18:30:02.000000000 +0100 +++ pnetlib.new/Xsharp/DoubleBuffer.cs 2005-09-08 15:49:26.588645650 +0200 @@ -39,6 +39,7 @@ // Internal state. private InputOutputWidget widget; private bool usesXdbe; + private Rectangle clipRect; /// /// Constructs a new @@ -60,6 +61,7 @@ this.widget = widget; this.width = widget.width; this.height = widget.height; + this.clipRect = new Rectangle (0, 0, widget.width, widget.height); try { IntPtr display = dpy.Lock(); @@ -169,6 +171,11 @@ } } + public void SetClipRectangle (Rectangle r) + { + clipRect = r; + } + // Start a double buffer drawing operation. internal void Start(Graphics graphics) { @@ -231,21 +238,34 @@ IntPtr display = dpy.Lock(); if(handle != XDrawable.Zero) { - if(usesXdbe) + using(Graphics g = new Graphics(widget)) { - Xlib.XdbeSwapInfo info = new Xlib.XdbeSwapInfo(); - info.swap_window = widget.GetWidgetHandle(); - info.swap_action = Xlib.XdbeSwapAction.Background; - Xlib.XdbeSwapBuffers(display, ref info, 1); - } - else - { - using(Graphics g = new Graphics(widget)) + if(usesXdbe) + { + Xlib.XdbeSwapInfo info = new Xlib.XdbeSwapInfo(); + info.swap_window = widget.GetWidgetHandle(); + info.swap_action = Xlib.XdbeSwapAction.Background; + Xlib.XdbeSwapBuffers(display, ref info, 1); + + // Copy the new front buffer back to the back + // buffer (needed for clipping). + Xlib.XCopyArea + (display, + widget.GetGCHandle(), handle, g.gc, + 0, 0, + (uint)widget.width, (uint)widget.height, + 0, 0); + } + else { + // Copy only the unclipped part of the buffer + // to the screen. Xlib.XCopyArea (display, handle, - widget.GetGCHandle(), g.gc, 0, 0, - (uint)width, (uint)height, 0, 0); + widget.GetGCHandle(), g.gc, + clipRect.x, clipRect.y, + (uint)clipRect.width, (uint)clipRect.height, + clipRect.x, clipRect.y); } } }