Esempio n. 1
0
        void OnFocusInEvent(X11.XFocusChangeEvent ev)
        {
            var title = WindowIndexByFrame[ev.window].title;
            var frame = ev.window;

            Xlib.XSetWindowBorder(this.display, frame, this.Colours.ActiveFrameColor);
            Xlib.XSetWindowBackground(this.display, title, this.Colours.ActiveTitleColor);
            Xlib.XSetWindowBorder(this.display, title, this.Colours.ActiveTitleBorder);
            Xlib.XClearWindow(this.display, title); // Force colour update

            UpdateWindowTitle(title);               //Redraw the title, purged by clearing.
        }
Esempio n. 2
0
        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
        }
Esempio n. 3
0
        // Annoyingly, this event fires when an application quits itself, resuling in some bad window errors.
        void OnFocusOutEvent(X11.XFocusChangeEvent ev)
        {
            var title = WindowIndexByFrame[ev.window].title;
            var frame = ev.window;

            if (Status.Failure == Xlib.XSetWindowBorder(this.display, frame, this.Colours.InactiveTitleBorder))
            {
                return; // If the windows have been destroyed asynchronously, cut this short.
            }
            Xlib.XSetWindowBackground(this.display, title, this.Colours.InactiveTitleColor);
            Xlib.XSetWindowBorder(this.display, title, this.Colours.InactiveFrameColor);
            Xlib.XClearWindow(this.display, title);
            UpdateWindowTitle(title);

            SetFocusTrap(WindowIndexByFrame[ev.window].child);
        }