public WindowManager(SimpleLogger.LogLevel level) { this.Log = new SimpleLogger(level); var pDisplayText = Xlib.XDisplayName(null); var DisplayText = Marshal.PtrToStringAnsi(pDisplayText); if (DisplayText == String.Empty) { Log.Error("No display configured for X11; check the value of the DISPLAY variable is set correctly"); Environment.Exit(1); } Log.Info($"Connecting to X11 Display {DisplayText}"); this.display = Xlib.XOpenDisplay(null); if (display == IntPtr.Zero) { Log.Error("Unable to open the default X display"); Environment.Exit(1); } this.root = Xlib.XDefaultRootWindow(display); OnError = this.ErrorHandler; Xlib.XSetErrorHandler(OnError); // This will trigger a bad access error if another window manager is already running Xlib.XSelectInput(this.display, this.root, EventMask.SubstructureRedirectMask | EventMask.SubstructureNotifyMask | EventMask.ButtonPressMask | EventMask.KeyPressMask); Xlib.XSync(this.display, false); // Setup cursors this.Cursors.DefaultCursor = Xlib.XCreateFontCursor(this.display, FontCursor.XC_left_ptr); this.Cursors.TitleCursor = Xlib.XCreateFontCursor(this.display, FontCursor.XC_fleur); this.Cursors.FrameCursor = Xlib.XCreateFontCursor(this.display, FontCursor.XC_sizing); Xlib.XDefineCursor(this.display, this.root, this.Cursors.DefaultCursor); // Setup colours this.Colours.DesktopBackground = GetPixelByName("black"); this.Colours.WindowBackground = GetPixelByName("white"); this.Colours.InactiveTitleBorder = GetPixelByName("light slate grey"); this.Colours.InactiveTitleColor = GetPixelByName("slate grey"); this.Colours.InactiveFrameColor = GetPixelByName("dark slate grey"); this.Colours.ActiveFrameColor = GetPixelByName("dark goldenrod"); this.Colours.ActiveTitleColor = GetPixelByName("gold"); this.Colours.ActiveTitleBorder = GetPixelByName("saddle brown"); Xlib.XSetWindowBackground(this.display, this.root, this.Colours.DesktopBackground); Xlib.XClearWindow(this.display, this.root); // force a redraw with the new background color }