Esempio n. 1
0
        // Set this cursor on a widget.
        internal void SetCursor(Widget widget)
        {
            Display dpy = widget.dpy;

            try
            {
                IntPtr  display = dpy.Lock();
                XWindow window  = widget.GetWidgetHandle();
                if (source != null)
                {
                    if (cursor == XCursor.Zero)
                    {
                        XColor foreground = new XColor();
                        foreground.red   = (ushort)0;
                        foreground.green = (ushort)0;
                        foreground.blue  = (ushort)0;
                        foreground.flags =
                            (XColor.DoRed | XColor.DoGreen | XColor.DoBlue);
                        XColor background = new XColor();
                        background.red   = (ushort)0xFFFF;
                        background.green = (ushort)0xFFFF;
                        background.blue  = (ushort)0xFFFF;
                        background.flags =
                            (XColor.DoRed | XColor.DoGreen | XColor.DoBlue);
                        if (reverse)
                        {
                            cursor = Xlib.XCreatePixmapCursor
                                         (display,
                                         source.GetPixmapHandle(),
                                         mask.GetPixmapHandle(),
                                         ref background, ref foreground,
                                         (uint)hotspotX, (uint)hotspotY);
                        }
                        else
                        {
                            cursor = Xlib.XCreatePixmapCursor
                                         (display,
                                         source.GetPixmapHandle(),
                                         mask.GetPixmapHandle(),
                                         ref foreground, ref background,
                                         (uint)hotspotX, (uint)hotspotY);
                        }
                    }
                    Xlib.XDefineCursor(display, window, cursor);
                }
                else if (type == CursorType.XC_inherit_parent)
                {
                    Xlib.XUndefineCursor(display, window);
                }
                else
                {
                    Xlib.XDefineCursor
                        (display, window, dpy.GetCursor(type));
                }
            }
            finally
            {
                dpy.Unlock();
            }
        }