Beispiel #1
0
        /// <summary> Initialize local ressources for all constructors. </summary>
        /// <param name="assignedPosition"> The position of the top left top corner assigned by the window manager (for shell widgets) or geometry management (by non-shell widgets). Passed as reference to avoid structure copy constructor calls. <see cref="TPoint"/> </param>
        public void InitializeOverrideShellResources(ref TPoint assignedPosition)
        {
            TInt depth = X11lib.XDefaultDepth(_display, _screenNumber);

            X11lib.WindowAttributeMask  mask       = X11lib.WindowAttributeMask.CWOverrideRedirect | X11lib.WindowAttributeMask.CWSaveUnder;
            X11lib.XSetWindowAttributes attributes = new X11lib.XSetWindowAttributes();
            attributes.override_redirect = (TBoolean)1;
            attributes.save_under        = (TBoolean)1;
            _window = X11lib.XCreateWindow(_display, X11lib.XDefaultRootWindow(_display), (TInt)assignedPosition.X, (TInt)assignedPosition.Y, (TUint)_assignedSize.Width, (TUint)_assignedSize.Height,
                                           0, depth, (TUint)X11lib.WindowClass.InputOutput, IntPtr.Zero, mask, ref attributes);
            if (_window == IntPtr.Zero)
            {
                Console.WriteLine(CLASS_NAME + "::InitializeOverrideShellResources () ERROR. Can not create menu shell.");
                return;
            }

            _hasOwnWindow = true;

            X11lib.XSelectInput(_display, _window,
                                EventMask.ExposureMask | EventMask.ButtonPressMask | EventMask.ButtonReleaseMask |
                                EventMask.EnterWindowMask | EventMask.LeaveWindowMask | EventMask.PointerMotionMask |
                                EventMask.FocusChangeMask | EventMask.KeyPressMask | EventMask.KeyReleaseMask |
                                EventMask.SubstructureNotifyMask);

            /* Create the foreground Graphics Context. */
            if (_gc != IntPtr.Zero)
            {
                if (XrwApplicationSettings.VERBOSE_OUTPUT_TO_CONSOLE)
                {
                    Console.WriteLine(CLASS_NAME + "::InitializeOverrideShellResources () Replace the foreground GC.");
                }
                X11lib.XFreeGC(_display, _gc);
                _gc = IntPtr.Zero;
            }
            _gc = X11lib.XCreateGC(_display, _window, 0, IntPtr.Zero);
        }
Beispiel #2
0
        // ###############################################################################
        // ### M E T H O D S
        // ###############################################################################

        #region Methods

        /// <summary> Load the icon from indicated path and set it as shell icon. </summary>
        /// <returns> <c>true</c>, if icon was set, <c>false</c> otherwise. </returns>
        /// <param name='iconPath'> The icon path. </param>
        public bool SetShellIcon(string iconPath)
        {
            bool result = false;

            if (_shell == IntPtr.Zero)
            {
                Console.WriteLine(CLASS_NAME + "::SetShellIcon() ERROR: Member attribute '_shell' null.");
                return(result);
            }
            if (string.IsNullOrEmpty(iconPath))
            {
                Console.WriteLine(CLASS_NAME + "::SetShellIcon() ERROR: Paramerter 'iconPath' null or empty.");
                return(result);
            }

            IntPtr display      = Xtlib.XtDisplay(_shell);
            IntPtr window       = Xtlib.XtWindow(_shell);
            TInt   screenNumber = Xtlib.XDefaultScreen(display);

            using (X11Graphic appIcon = new X11Graphic(display, (int)screenNumber, IntPtr.Zero, X11lib.XDefaultDepth(display, screenNumber), iconPath))
            {
                _appIconPixMap = appIcon.CreateIndependentGraphicPixmap(display, window);
                _appMaskPixMap = appIcon.CreateIndependentMaskPixmap(display, window);
                if (_appIconPixMap != IntPtr.Zero && _appMaskPixMap != IntPtr.Zero)
                {
                    X11lib.XWMHints wmHints = new X11lib.XWMHints();
                    IntPtr          wmAddr  = X11lib.XAllocWMHints(ref wmHints);

                    wmHints.flags = X11lib.XWMHintMask.IconPixmapHint |
                                    X11lib.XWMHintMask.IconPositionHint |
                                    X11lib.XWMHintMask.IconMaskHint;
                    wmHints.icon_pixmap = _appIconPixMap;
                    wmHints.icon_mask   = _appMaskPixMap;
                    wmHints.icon_x      = 0;
                    wmHints.icon_y      = 0;

                    X11lib.XSetWMHints(display, window, ref wmHints);
                    X11lib.XFree(wmAddr);

                    result = true;
                }
                else
                {
                    Console.WriteLine(CLASS_NAME + "::SetShellIcon () ERROR: Can not create application icon.");
                }
            }

            return(result);
        }