コード例 #1
0
        // Start a double buffer drawing operation.
        internal void Start(Graphics graphics)
        {
            // Re-create the pixmap object if the widget size has changed.
            if (!usesXdbe)
            {
                if (widget.width != width || widget.height != height)
                {
                    try
                    {
                        IntPtr display = dpy.Lock();
                        if (handle != XDrawable.Zero)
                        {
                            Xlib.XFreePixmap(display, (XPixmap)handle);
                        }
                        handle = (XDrawable)
                                 Xlib.XCreatePixmap
                                     (display, (XDrawable)
                                     Xlib.XRootWindowOfScreen(screen.screen),
                                     (uint)(widget.Width),
                                     (uint)(widget.Height),
                                     (uint)Xlib.XDefaultDepthOfScreen
                                         (screen.screen));
                    }
                    finally
                    {
                        dpy.Unlock();
                    }
                }
            }

            // Copy the width and height values from the widget.
            width  = widget.Width;
            height = widget.Height;
        }
コード例 #2
0
 /// <summary>
 /// <para>Constructs a new <see cref="T:Xsharp.Pixmap"/> instance
 /// that represents an off-screen pixmap.  The pixmap is created
 /// on the default screen of the primary display.</para>
 /// </summary>
 ///
 /// <param name="width">
 /// <para>The width of the new pixmap.</para>
 /// </param>
 ///
 /// <param name="height">
 /// <para>The height of the new pixmap.</para>
 /// </param>
 ///
 /// <exception cref="T:Xsharp.XException">
 /// <para>The <paramref name="width"/> or <paramref name="height"/>
 /// values are out of range.</para>
 /// </exception>
 public Pixmap(int width, int height)
     : base(Xsharp.Application.Primary.Display,
            Xsharp.Application.Primary.Display.DefaultScreenOfDisplay,
            DrawableKind.Pixmap)
 {
     if (width < 1 || width > 32767 ||
         height < 1 || height > 32767)
     {
         throw new XException(S._("X_InvalidPixmapSize"));
     }
     try
     {
         IntPtr display = dpy.Lock();
         SetPixmapHandle(Xlib.XCreatePixmap
                             (display, (XDrawable)
                             Xlib.XRootWindowOfScreen(screen.screen),
                             (uint)width, (uint)height,
                             (uint)Xlib.XDefaultDepthOfScreen(screen.screen)));
         this.width  = width;
         this.height = height;
     }
     finally
     {
         dpy.Unlock();
     }
 }
コード例 #3
0
        /// <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();
            }
        }