예제 #1
0
        public void Show()
        {
            if (_x11Extensions == null)
            {
                throw new InvalidOperationException("No Graphics API implementation in use");
            }

            var display = Marshal.PtrToStructure <X11.XDisplay>(NativeHandle);
            var screen  = Marshal.PtrToStructure <X11.Screen>(display.screens + display.default_screen);

            var visualInfo = _x11Extensions.GetVisualInfo(display);
            var visual     = Marshal.PtrToStructure <X11.Visual>(visualInfo.visual);

            var cmap             = X11.XCreateColormap(NativeHandle, screen.root, ref visual, 0 /*AllocNone*/);
            var windowAttributes = new X11.XSetWindowAttributes
            {
                colormap   = cmap,
                event_mask = EventMask
            };

            WindowId = X11.XCreateWindow(NativeHandle, screen.root, 0, 0, (uint)Width, (uint)Height, 0, visualInfo.depth, 1, ref visual, 1L << 13 /*CWColormap*/ | 1L << 11 /*CWEventMask*/, ref windowAttributes);

            X11.XMapWindow(NativeHandle, WindowId);
            X11.XStoreName(NativeHandle, WindowId, _title);

            //Attach events
            var wmResize = X11.XInternAtom(NativeHandle, "WM_SIZE_HINTS", true);

            _wmDelete = X11.XInternAtom(NativeHandle, "WM_DELETE_WINDOW", true);
            var events = new[] { wmResize, _wmDelete };

            X11.XSetWMProtocols(NativeHandle, WindowId, events, events.Length);
        }
예제 #2
0
        public LinuxX11WindowImpl(LinuxX11Platform platform,
                                  int width,
                                  int height)
        {
            _platform = platform;
            X11.XSetWindowAttributes attributes = new X11.XSetWindowAttributes();
            var screen = Xlib.XDefaultScreen(_platform.Display);

            _visual = Xlib.XDefaultVisual(_platform.Display, screen);
            var depth = Xlib.XDefaultDepth(_platform.Display, screen);

            attributes.background_pixel = 0;
            attributes.bit_gravity      = 10;

            _window = Xlib.XCreateWindow(platform.Display,
                                         Xlib.XDefaultRootWindow(platform.Display),
                                         300,
                                         300,
                                         (uint)width,
                                         (uint)height,
                                         1,
                                         depth,
                                         1,
                                         _visual,
                                         1 << 1 | 1 << 4,
                                         ref attributes);

            Xlib.XSelectInput(platform.Display, _window, X11.EventMask.ExposureMask |
                              X11.EventMask.StructureNotifyMask |
                              X11.EventMask.EnterWindowMask |
                              X11.EventMask.LeaveWindowMask |
                              X11.EventMask.PointerMotionMask);
        }