/// <summary> Initialize local ressources for all constructors. </summary> private void InitializeXrwVisibleRectObjRessources() { _gc = X11lib.XCreateGC(_display, _window, 0, IntPtr.Zero); if (_gc == IntPtr.Zero) { throw new OperationCanceledException("Failed to create graphics context."); } _backgroundColorPixel = X11lib.XAllocParsedColorByName(_display, _screenNumber, XrwTheme.BackGroundColor); _darkShadowColorPixel = X11lib.XAllocParsedColorByName(_display, _screenNumber, XrwTheme.DarkShadowColor); _lightShadowColorPixel = X11lib.XAllocParsedColorByName(_display, _screenNumber, XrwTheme.LightShadowColor); }
/// <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 InitializeTransientShellResources(ref TPoint offset) { /* Get the colors black and white. */ TPixel black = X11lib.XBlackPixel(_display, _screenNumber); /* get color black */ TPixel white = X11lib.XWhitePixel(_display, _screenNumber); /* get color white */ /* Once the display is initialized, create the window. * It will have the foreground white and background black */ _window = X11lib.XCreateSimpleWindow(_display, X11lib.XDefaultRootWindow(_display), (TInt)offset.X, (TInt)offset.Y, (TUint)_assignedSize.Width, (TUint)_assignedSize.Height, 0, 0, black); if (_window == IntPtr.Zero) { Console.WriteLine(CLASS_NAME + "::InitializeTransientShellResources () ERROR. Can not create transient shell."); return; } X11lib.XSelectInput(_display, _window, EventMask.StructureNotifyMask | EventMask.ExposureMask | EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.EnterWindowMask | EventMask.LeaveWindowMask | EventMask.PointerMotionMask | EventMask.FocusChangeMask | EventMask.KeyPressMask | EventMask.KeyReleaseMask | EventMask.SubstructureNotifyMask); _hasOwnWindow = true; /* Hook the closing event from windows manager. */ _wmDeleteMessage = X11lib.XInternAtom(_display, "WM_DELETE_WINDOW", false); if (X11lib.XSetWMProtocols(_display, _window, ref _wmDeleteMessage, (X11.TInt) 1) == 0) { Console.WriteLine(CLASS_NAME + "::InitializeTransientShellResources () WARNING: Failed to register 'WM_DELETE_WINDOW' event."); } X11lib.XSetTransientForHint(_display, _window, Parent.Window); /* Recreate the foreground Graphics Context with. */ if (_gc != IntPtr.Zero) { if (XrwApplicationSettings.VERBOSE_OUTPUT_TO_CONSOLE) { Console.WriteLine(CLASS_NAME + "::InitializeTransientShellResources () Replace the foreground GC."); } X11lib.XFreeGC(_display, _gc); _gc = IntPtr.Zero; } _gc = X11lib.XCreateGC(_display, _window, 0, IntPtr.Zero); X11lib.XSetForeground(_display, _gc, white); }
/// <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); }