// End a double buffer drawing operation. internal void End(Graphics graphics) { try { IntPtr display = dpy.Lock(); if (handle != XDrawable.Zero) { 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); } else { using (Graphics g = new Graphics(widget)) { Xlib.XCopyArea (display, handle, widget.GetGCHandle(), g.gc, 0, 0, (uint)width, (uint)height, 0, 0); } } } } finally { dpy.Unlock(); } }
/// <summary> /// <para>Constructs a new <see cref="T:Xsharp.DoubleBuffer"/> /// instance.</para> /// </summary> /// /// <param name="widget"> /// <para>The widget to attach the double buffer to.</para> /// </param> /// /// <exception cref="T:System.ArgumentNullException"> /// <para>Raised if <paramref name="widget"/> is <see langword="null"/>. /// </para> /// </exception> public DoubleBuffer(InputOutputWidget widget) : base(GetDisplay(widget), GetScreen(widget), DrawableKind.DoubleBuffer) { this.widget = widget; this.width = widget.width; this.height = widget.height; try { IntPtr display = dpy.Lock(); // Determine if the X server supports double buffering. try { Xlib.Xint major, minor; if (Xlib.XdbeQueryExtension (display, out major, out minor) != XStatus.Zero) { usesXdbe = true; } else { usesXdbe = false; } } catch (Exception) { // Xdbe functions are not present in "Xext". usesXdbe = false; } // Create the back buffer or pixmap, as appropriate. if (usesXdbe) { handle = Xlib.XdbeAllocateBackBufferName (display, widget.GetWidgetHandle(), Xlib.XdbeSwapAction.Background); } else { handle = (XDrawable) Xlib.XCreatePixmap (display, (XDrawable) Xlib.XRootWindowOfScreen(screen.screen), (uint)width, (uint)height, (uint)Xlib.XDefaultDepthOfScreen (screen.screen)); } } finally { dpy.Unlock(); } }
/// <summary> /// <para>Constructs a new <see cref="T:Xsharp.DoubleBuffer"/> /// instance.</para> /// </summary> /// /// <param name="widget"> /// <para>The widget to attach the double buffer to.</para> /// </param> /// /// <exception cref="T:System.ArgumentNullException"> /// <para>Raised if <paramref name="widget"/> is <see langword="null"/>. /// </para> /// </exception> public DoubleBuffer(InputOutputWidget widget) : base(GetDisplay(widget), GetScreen(widget), DrawableKind.DoubleBuffer) { this.widget = widget; this.width = widget.width; this.height = widget.height; try { IntPtr display = dpy.Lock(); // Determine if the X server supports double buffering. try { Xlib.Xint major, minor; if(Xlib.XdbeQueryExtension (display, out major, out minor) != XStatus.Zero) { usesXdbe = true; } else { usesXdbe = false; } } catch(Exception) { // Xdbe functions are not present in "Xext". usesXdbe = false; } // Create the back buffer or pixmap, as appropriate. if(usesXdbe) { handle = Xlib.XdbeAllocateBackBufferName (display, widget.GetWidgetHandle(), Xlib.XdbeSwapAction.Background); } else { handle = (XDrawable) Xlib.XCreatePixmap (display, (XDrawable) Xlib.XRootWindowOfScreen(screen.screen), (uint)width, (uint)height, (uint)Xlib.XDefaultDepthOfScreen (screen.screen)); } } finally { dpy.Unlock(); } }