コード例 #1
0
        public XI2MouseKeyboard()
        {
            window = new X11WindowInfo();

            window.Display = Functions.XOpenDisplay(IntPtr.Zero);
            using (new XLock(window.Display))
            {
                XSetWindowAttributes attr = new XSetWindowAttributes();

                window.Screen     = Functions.XDefaultScreen(window.Display);
                window.RootWindow = Functions.XRootWindow(window.Display, window.Screen);
                window.Handle     = Functions.XCreateWindow(window.Display, window.RootWindow,
                                                            0, 0, 1, 1, 0, 0,
                                                            CreateWindowArgs.InputOnly, IntPtr.Zero,
                                                            SetWindowValuemask.Nothing, attr);

                KeyMap = new X11KeyMap(window.Display);
            }

            if (!IsSupported(window.Display))
            {
                throw new NotSupportedException("XInput2 not supported.");
            }

            // Enable XI2 mouse/keyboard events
            // Note: the input event loop blocks waiting for these events
            // *or* a custom ClientMessage event that instructs us to exit.
            // See SendExitEvent() below.
            using (new XLock(window.Display))
                using (XIEventMask mask = new XIEventMask(1,
                                                          XIEventMasks.RawKeyPressMask |
                                                          XIEventMasks.RawKeyReleaseMask |
                                                          XIEventMasks.RawButtonPressMask |
                                                          XIEventMasks.RawButtonReleaseMask |
                                                          XIEventMasks.RawMotionMask |
                                                          XIEventMasks.MotionMask |
                                                          XIEventMasks.DeviceChangedMask))
                {
                    XI.SelectEvents(window.Display, window.RootWindow, mask);
                    UpdateDevices();
                }

            ProcessingThread = new Thread(ProcessEvents);
            ProcessingThread.IsBackground = true;
            ProcessingThread.Start();
        }
コード例 #2
0
        public XDisplay(bool fullScreen)
        {
            _display = XOpenDisplay("");

            int    screenNumber = XDefaultScreen(_display);
            int    depth        = XDefaultDepth(_display, screenNumber);
            IntPtr visual       = XDefaultVisual(_display, screenNumber);
            IntPtr screenPtr    = XScreenOfDisplay(_display, screenNumber);
            Screen screen       = Noesis.Marshal.PtrToStructure <Screen>(screenPtr);

            IntPtr root = XRootWindow(_display, screenNumber);

            XSetWindowAttributes attr = new XSetWindowAttributes();

            attr.event_mask = EventMask.FocusChangeMask | EventMask.StructureNotifyMask | EventMask.SubstructureNotifyMask |
                              EventMask.PointerMotionMask | EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.KeyPressMask | EventMask.KeyReleaseMask;
            _window = XCreateWindow(_display, root, 0, 0, (uint)screen.width, (uint)screen.height, 0, depth, (uint)WindowClass.InputOutput, visual, (IntPtr)AttributeMask.CWEventMask, ref attr);

            if (fullScreen)
            {
                uint[] data     = { XInternAtom(_display, "_NET_WM_STATE_FULLSCREEN", true) };
                uint   property = XInternAtom(_display, "_NET_WM_STATE", false);

                XChangeProperty(_display, (IntPtr)_window, property, 4 /*XA_ATOM*/, 32, 0 /*PropModeReplace*/, data, 1);
            }

            _xim = XOpenIM(_display, IntPtr.Zero, null, null);
            if (_xim == IntPtr.Zero)
            {
                XSetLocaleModifiers("@im=none");
                _xim = XOpenIM(_display, IntPtr.Zero, null, null);
            }

            if (_xim != IntPtr.Zero)
            {
                _xic = XCreateIC(_xim, "inputStyle", (IntPtr)0x0408L, "clientWindow", (IntPtr)_window, "focusWindow", (IntPtr)_window, IntPtr.Zero);
                if (_xic != IntPtr.Zero)
                {
                    XSetICFocus(_xic);
                    _utf8 = new UTF8Encoding();
                }
            }
        }
コード例 #3
0
            public DumbWindow(X11Info x11, IntPtr?parent = null)
            {
                _display = x11.Display;

                /*Handle = XCreateSimpleWindow(x11.Display, XLib.XDefaultRootWindow(_display),
                 *  0, 0, 1, 1, 0, IntPtr.Zero, IntPtr.Zero);*/
                var attr = new XSetWindowAttributes
                {
                    backing_store = 1,
                    bit_gravity   = Gravity.NorthWestGravity,
                    win_gravity   = Gravity.NorthWestGravity,
                };

                parent = parent ?? XDefaultRootWindow(x11.Display);

                Handle = XCreateWindow(_display, parent.Value, 0, 0,
                                       1, 1, 0, 0,
                                       (int)CreateWindowArgs.InputOutput,
                                       IntPtr.Zero,
                                       new UIntPtr((uint)(SetWindowValuemask.BorderPixel | SetWindowValuemask.BitGravity |
                                                          SetWindowValuemask.BackPixel |
                                                          SetWindowValuemask.WinGravity | SetWindowValuemask.BackingStore)), ref attr);
            }
コード例 #4
0
ファイル: X11Window.cs プロジェクト: yatli/Avalonia
        public X11Window(AvaloniaX11Platform platform, IWindowImpl popupParent)
        {
            _platform = platform;
            _popup    = popupParent != null;
            _x11      = platform.Info;
            _mouse    = new MouseDevice();
            _touch    = new TouchDevice();
            _keyboard = platform.KeyboardDevice;

            var glfeature             = AvaloniaLocator.Current.GetService <IPlatformOpenGlInterface>();
            XSetWindowAttributes attr = new XSetWindowAttributes();
            var valueMask             = default(SetWindowValuemask);

            attr.backing_store = 1;
            attr.bit_gravity   = Gravity.NorthWestGravity;
            attr.win_gravity   = Gravity.NorthWestGravity;
            valueMask         |= SetWindowValuemask.BackPixel | SetWindowValuemask.BorderPixel
                                 | SetWindowValuemask.BackPixmap | SetWindowValuemask.BackingStore
                                 | SetWindowValuemask.BitGravity | SetWindowValuemask.WinGravity;

            if (_popup)
            {
                attr.override_redirect = true;
                valueMask |= SetWindowValuemask.OverrideRedirect;
            }

            XVisualInfo?visualInfo = null;

            // OpenGL seems to be do weird things to it's current window which breaks resize sometimes
            _useRenderWindow = glfeature != null;

            var glx = glfeature as GlxPlatformOpenGlInterface;

            if (glx != null)
            {
                visualInfo = *glx.Display.VisualInfo;
            }
            else if (glfeature == null)
            {
                visualInfo = _x11.TransparentVisualInfo;
            }

            var egl = glfeature as EglPlatformOpenGlInterface;

            var visual = IntPtr.Zero;
            var depth  = 24;

            if (visualInfo != null)
            {
                visual        = visualInfo.Value.visual;
                depth         = (int)visualInfo.Value.depth;
                attr.colormap = XCreateColormap(_x11.Display, _x11.RootWindow, visualInfo.Value.visual, 0);
                valueMask    |= SetWindowValuemask.ColorMap;
            }

            int defaultWidth = 0, defaultHeight = 0;

            if (!_popup && Screen != null)
            {
                var monitor = Screen.AllScreens.OrderBy(x => x.PixelDensity)
                              .FirstOrDefault(m => m.Bounds.Contains(Position));

                if (monitor != null)
                {
                    // Emulate Window 7+'s default window size behavior.
                    defaultWidth  = (int)(monitor.WorkingArea.Width * 0.75d);
                    defaultHeight = (int)(monitor.WorkingArea.Height * 0.7d);
                }
            }

            // check if the calculated size is zero then compensate to hardcoded resolution
            defaultWidth  = Math.Max(defaultWidth, 300);
            defaultHeight = Math.Max(defaultHeight, 200);

            _handle = XCreateWindow(_x11.Display, _x11.RootWindow, 10, 10, defaultWidth, defaultHeight, 0,
                                    depth,
                                    (int)CreateWindowArgs.InputOutput,
                                    visual,
                                    new UIntPtr((uint)valueMask), ref attr);

            if (_useRenderWindow)
            {
                _renderHandle = XCreateWindow(_x11.Display, _handle, 0, 0, defaultWidth, defaultHeight, 0, depth,
                                              (int)CreateWindowArgs.InputOutput,
                                              visual,
                                              new UIntPtr((uint)(SetWindowValuemask.BorderPixel | SetWindowValuemask.BitGravity |
                                                                 SetWindowValuemask.WinGravity | SetWindowValuemask.BackingStore)), ref attr);
            }
            else
            {
                _renderHandle = _handle;
            }

            Handle    = new PlatformHandle(_handle, "XID");
            _realSize = new PixelSize(defaultWidth, defaultHeight);
            platform.Windows[_handle] = OnEvent;
            XEventMask ignoredMask = XEventMask.SubstructureRedirectMask
                                     | XEventMask.ResizeRedirectMask
                                     | XEventMask.PointerMotionHintMask;

            if (platform.XI2 != null)
            {
                ignoredMask |= platform.XI2.AddWindow(_handle, this);
            }
            var mask = new IntPtr(0xffffff ^ (int)ignoredMask);

            XSelectInput(_x11.Display, _handle, mask);
            var protocols = new[]
            {
                _x11.Atoms.WM_DELETE_WINDOW
            };

            XSetWMProtocols(_x11.Display, _handle, protocols, protocols.Length);
            XChangeProperty(_x11.Display, _handle, _x11.Atoms._NET_WM_WINDOW_TYPE, _x11.Atoms.XA_ATOM,
                            32, PropertyMode.Replace, new[] { _x11.Atoms._NET_WM_WINDOW_TYPE_NORMAL }, 1);

            if (platform.Options.WmClass != null)
            {
                SetWmClass(platform.Options.WmClass);
            }

            var surfaces = new List <object>
            {
                new X11FramebufferSurface(_x11.DeferredDisplay, _renderHandle,
                                          depth, () => RenderScaling)
            };

            if (egl != null)
            {
                surfaces.Insert(0,
                                new EglGlPlatformSurface(egl,
                                                         new SurfaceInfo(this, _x11.DeferredDisplay, _handle, _renderHandle)));
            }
            if (glx != null)
            {
                surfaces.Insert(0, new GlxGlPlatformSurface(glx.Display, glx.DeferredContext,
                                                            new SurfaceInfo(this, _x11.Display, _handle, _renderHandle)));
            }

            Surfaces = surfaces.ToArray();
            UpdateMotifHints();
            UpdateSizeHints(null);
            _xic = XCreateIC(_x11.Xim, XNames.XNInputStyle, XIMProperties.XIMPreeditNothing | XIMProperties.XIMStatusNothing,
                             XNames.XNClientWindow, _handle, IntPtr.Zero);
            _transparencyHelper = new TransparencyHelper(_x11, _handle, platform.Globals);
            _transparencyHelper.SetTransparencyRequest(WindowTransparencyLevel.None);

            XFlush(_x11.Display);
            if (_popup)
            {
                PopupPositioner = new ManagedPopupPositioner(new ManagedPopupPositionerPopupImplHelper(popupParent, MoveResize));
            }
            if (platform.Options.UseDBusMenu)
            {
                NativeMenuExporter = DBusMenuExporter.TryCreate(_handle);
            }
            NativeControlHost = new X11NativeControlHost(_platform, this);
            DispatcherTimer.Run(() =>
            {
                Paint?.Invoke(default);
コード例 #5
0
 public static extern IntPtr XCreateWindow(IntPtr display, IntPtr parent, int x, int y, int width, int height,
                                           int border_width, int depth, int xclass, IntPtr visual, UIntPtr valuemask,
                                           ref XSetWindowAttributes attributes);
コード例 #6
0
        public X11Window(AvaloniaX11Platform platform, bool popup)
        {
            _platform = platform;
            _popup    = popup;
            _x11      = platform.Info;
            _mouse    = platform.MouseDevice;
            _keyboard = platform.KeyboardDevice;

            var glfeature             = AvaloniaLocator.Current.GetService <IWindowingPlatformGlFeature>();
            XSetWindowAttributes attr = new XSetWindowAttributes();
            var valueMask             = default(SetWindowValuemask);

            attr.backing_store = 1;
            attr.bit_gravity   = Gravity.NorthWestGravity;
            attr.win_gravity   = Gravity.NorthWestGravity;
            valueMask         |= SetWindowValuemask.BackPixel | SetWindowValuemask.BorderPixel
                                 | SetWindowValuemask.BackPixmap | SetWindowValuemask.BackingStore
                                 | SetWindowValuemask.BitGravity | SetWindowValuemask.WinGravity;

            if (popup)
            {
                attr.override_redirect = true;
                valueMask |= SetWindowValuemask.OverrideRedirect;
            }

            XVisualInfo?visualInfo = null;

            // OpenGL seems to be do weird things to it's current window which breaks resize sometimes
            _useRenderWindow = glfeature != null;

            var glx = glfeature as GlxGlPlatformFeature;

            if (glx != null)
            {
                visualInfo = *glx.Display.VisualInfo;
            }
            else if (glfeature == null)
            {
                visualInfo = _x11.TransparentVisualInfo;
            }

            var egl = glfeature as EglGlPlatformFeature;

            var visual = IntPtr.Zero;
            var depth  = 24;

            if (visualInfo != null)
            {
                visual        = visualInfo.Value.visual;
                depth         = (int)visualInfo.Value.depth;
                attr.colormap = XCreateColormap(_x11.Display, _x11.RootWindow, visualInfo.Value.visual, 0);
                valueMask    |= SetWindowValuemask.ColorMap;
            }

            _handle = XCreateWindow(_x11.Display, _x11.RootWindow, 10, 10, 300, 200, 0,
                                    depth,
                                    (int)CreateWindowArgs.InputOutput,
                                    visual,
                                    new UIntPtr((uint)valueMask), ref attr);

            if (_useRenderWindow)
            {
                _renderHandle = XCreateWindow(_x11.Display, _handle, 0, 0, 300, 200, 0, depth,
                                              (int)CreateWindowArgs.InputOutput,
                                              visual,
                                              new UIntPtr((uint)(SetWindowValuemask.BorderPixel | SetWindowValuemask.BitGravity |
                                                                 SetWindowValuemask.WinGravity | SetWindowValuemask.BackingStore)), ref attr);
            }
            else
            {
                _renderHandle = _handle;
            }

            Handle    = new PlatformHandle(_handle, "XID");
            _realSize = new PixelSize(300, 200);
            platform.Windows[_handle] = OnEvent;
            XEventMask ignoredMask = XEventMask.SubstructureRedirectMask
                                     | XEventMask.ResizeRedirectMask
                                     | XEventMask.PointerMotionHintMask;

            if (platform.XI2 != null)
            {
                ignoredMask |= platform.XI2.AddWindow(_handle, this);
            }
            var mask = new IntPtr(0xffffff ^ (int)ignoredMask);

            XSelectInput(_x11.Display, _handle, mask);
            var protocols = new[]
            {
                _x11.Atoms.WM_DELETE_WINDOW
            };

            XSetWMProtocols(_x11.Display, _handle, protocols, protocols.Length);
            XChangeProperty(_x11.Display, _handle, _x11.Atoms._NET_WM_WINDOW_TYPE, _x11.Atoms.XA_ATOM,
                            32, PropertyMode.Replace, new[] { _x11.Atoms._NET_WM_WINDOW_TYPE_NORMAL }, 1);

            if (platform.Options.WmClass != null)
            {
                SetWmClass(platform.Options.WmClass);
            }

            var surfaces = new List <object>
            {
                new X11FramebufferSurface(_x11.DeferredDisplay, _renderHandle,
                                          depth, () => Scaling)
            };

            if (egl != null)
            {
                surfaces.Insert(0,
                                new EglGlPlatformSurface((EglDisplay)egl.Display, egl.DeferredContext,
                                                         new SurfaceInfo(this, _x11.DeferredDisplay, _handle, _renderHandle)));
            }
            if (glx != null)
            {
                surfaces.Insert(0, new GlxGlPlatformSurface(glx.Display, glx.DeferredContext,
                                                            new SurfaceInfo(this, _x11.Display, _handle, _renderHandle)));
            }

            Surfaces = surfaces.ToArray();
            UpdateMotifHints();
            _xic = XCreateIC(_x11.Xim, XNames.XNInputStyle, XIMProperties.XIMPreeditNothing | XIMProperties.XIMStatusNothing,
                             XNames.XNClientWindow, _handle, IntPtr.Zero);
            XFlush(_x11.Display);
        }
コード例 #7
0
        public Mini(string[] args)
        {
            if (args.Length > 0)
            {
                if (args[0].Equals("--version"))
                {
                    Console.WriteLine(VERSION_STRING);
                    Environment.Exit(0);
                }
            }

            XGCValues            gv;
            XSetWindowAttributes sattr;

            focused_client = null;
            focus_model    = DEFAULT_FOCUS_MODEL;

            //  for (int i = 0; i < argc; i++)
            //    command_line = command_line + argv[i] + " ";

            try {
                dpy = new XDisplay(":0");

                try {
                    font = new XFont(dpy, DEFAULT_FONT);
                } catch {
                    font = new XFont(dpy, "Fixed");
                }
            } catch (Exception e) {
                Console.WriteLine("{0} check your DISPLAY variable.", e.Message);
                Environment.Exit(-1);
            }

            XEvent ev = new XEvent(dpy);

            ev.ErrorHandlerEvent += new ErrorHandler(ErrorHandler);

            // SET UP ATOMS
            atom_wm_state        = new XAtom(dpy, "WM_STATE", false);
            atom_wm_change_state = new XAtom(dpy, "WM_CHANGE_STATE", false);
            atom_wm_protos       = new XAtom(dpy, "WM_PROTOCOLS", false);
            atom_wm_delete       = new XAtom(dpy, "WM_DELETE_WINDOW", false);
            atom_wm_takefocus    = new XAtom(dpy, "WM_TAKE_FOCUS", false);

            XSetWindowAttributes pattr = new XSetWindowAttributes();

            pattr.override_redirect = true;
            _button_proxy_win       = new XWindow(dpy, new Rectangle(-80, -80, 24, 24));
            _button_proxy_win.ChangeAttributes(XWindowAttributeFlags.CWOverrideRedirect, pattr);

            // SETUP COLORS USED FOR WINDOW TITLE BARS and WINDOW BORDERS
            fg               = new XColor(dpy, DEFAULT_FOREGROUND_COLOR);
            bg               = new XColor(dpy, DEFAULT_BACKGROUND_COLOR);
            bd               = new XColor(dpy, DEFAULT_BORDER_COLOR);
            fc               = new XColor(dpy, DEFAULT_FOCUS_COLOR);
            focused_border   = new XColor(dpy, FOCUSED_BORDER_COLOR);
            unfocused_border = new XColor(dpy, UNFOCUSED_BORDER_COLOR);

            //shape = XShapeQueryExtension(dpy, &shape_event, &dummy);

            move_curs  = new XCursor(dpy, XCursors.XC_fleur);
            arrow_curs = new XCursor(dpy, XCursors.XC_left_ptr);

            root.DefineCursor(arrow_curs);

            gv.function   = XGCFunctionMask.GXcopy;
            gv.foreground = fg.Pixel;
            gv.font       = font.FID;
            string_gc     = new XGC(dpy, root, XGCValuesMask.GCFunction | XGCValuesMask.GCForeground | XGCValuesMask.GCFont, gv);

            gv.foreground = unfocused_border.Pixel;
            unfocused_gc  = new XGC(dpy, root, XGCValuesMask.GCForeground | XGCValuesMask.GCFont, gv);

            gv.foreground    = fg.Pixel;
            focused_title_gc = new XGC(dpy, root, XGCValuesMask.GCForeground | XGCValuesMask.GCFont, gv);

            gv.foreground = bd.Pixel;
            gv.line_width = DEFAULT_BORDER_WIDTH;
            border_gc     = new XGC(dpy, root, XGCValuesMask.GCFunction | XGCValuesMask.GCForeground | XGCValuesMask.GCLineWidth, gv);

            gv.foreground     = fg.Pixel;
            gv.function       = XGCFunctionMask.GXinvert;
            gv.subwindow_mode = XSubwindowMode.IncludeInferiors;
            invert_gc         = new XGC(dpy, root, XGCValuesMask.GCForeground | XGCValuesMask.GCFunction | XGCValuesMask.GCSubwindowMode | XGCValuesMask.GCLineWidth | XGCValuesMask.GCFont, gv);

            sattr.event_mask = XEventMask.SubstructureRedirectMask | XEventMask.SubstructureNotifyMask | XEventMask.ButtonPressMask | XEventMask.ButtonReleaseMask | XEventMask.FocusChangeMask | XEventMask.EnterWindowMask | XEventMask.LeaveWindowMask | XEventMask.PropertyChangeMask | XEventMask.ButtonMotionMask;

            root.ChangeAttributes(XWindowAttributeFlags.CWEventMask, sattr);

            queryWindowTree();

            ev.KeyPressHandlerEvent         += new KeyPressHandler(handleKeyPressEvent);
            ev.ButtonPressHandlerEvent      += new ButtonPressHandler(handleButtonPressEvent);
            ev.ButtonReleaseHandlerEvent    += new ButtonReleaseHandler(handleButtonReleaseEvent);
            ev.ConfigureRequestHandlerEvent += new ConfigureRequestHandler(handleConfigureRequestEvent);
            ev.MotionNotifyHandlerEvent     += new MotionNotifyHandler(handleMotionNotifyEvent);
            ev.MapRequestHandlerEvent       += new MapRequestHandler(handleMapRequestEvent);
            ev.UnmapNotifyHandlerEvent      += new UnmapNotifyHandler(handleUnmapNotifyEvent);
            ev.DestroyNotifyHandlerEvent    += new DestroyNotifyHandler(handleDestroyNotifyEvent);
            ev.EnterNotifyHandlerEvent      += new EnterNotifyHandler(handleEnterNotifyEvent);
            ev.FocusInHandlerEvent          += new FocusInHandler(handleFocusInEvent);
            ev.FocusOutHandlerEvent         += new FocusOutHandler(handleFocusOutEvent);
            ev.PropertyNotifyHandlerEvent   += new PropertyNotifyHandler(handlePropertyNotifyEvent);
            ev.ExposeHandlerEvent           += new ExposeHandler(handleExposeEvent);
            ev.ShapeHandlerEvent            += new ShapeHandler(handleShapeEvent);
        }
コード例 #8
0
ファイル: X11.cs プロジェクト: cesmec/CoreLoader
 internal static extern uint XCreateWindow(IntPtr display, ulong parent, int x, int y, uint width, uint height, uint borderWidth, int depth, uint @class, ref Visual visual, ulong valueMask, ref XSetWindowAttributes attributes);
コード例 #9
0
ファイル: XDisplay.cs プロジェクト: awesomedotnetcore/Managed
 public static extern Window XCreateWindow(IntPtr display, Window parent, int x, int y, uint width, uint height, uint border_width, int depth, uint @class, IntPtr visual, ulong valuemask, ref XSetWindowAttributes attributes);
コード例 #10
0
        // Internal constructor that is used by the "InputOutputWidget" subclass.
        internal InputOnlyWidget(Widget parent, int x, int y,
                                 int width, int height, Color background,
                                 bool rootAllowed, bool overrideRedirect)
            : base(GetDisplay(parent, rootAllowed), GetScreen(parent),
                   DrawableKind.Widget, parent)
        {
            bool ok = false;

            try
            {
                // Validate the position and size.
                if (x < -32768 || x > 32767 ||
                    y < -32768 || y > 32767)
                {
                    throw new XException(S._("X_InvalidPosition"));
                }
                if (width < 1 || width > 32767 ||
                    height < 1 || height > 32767 ||
                    !ValidateSize(width, height))
                {
                    throw new XException(S._("X_InvalidSize"));
                }

                // Set the initial position and size of the widget.
                this.x         = x;
                this.y         = y;
                this.width     = width;
                this.height    = height;
                this.focusable = true;

                // Lock down the display and create the window handle.
                try
                {
                    IntPtr  display            = dpy.Lock();
                    XWindow pwindow            = parent.GetWidgetHandle();
                    XSetWindowAttributes attrs = new XSetWindowAttributes();
                    attrs.override_redirect = overrideRedirect;
                    XWindow window = Xlib.XCreateWindow
                                         (display, pwindow,
                                         x, y, (uint)width, (uint)height, (uint)0,
                                         screen.DefaultDepth, 1 /* InputOutput */,
                                         screen.DefaultVisual,
                                         (uint)(CreateWindowMask.CWOverrideRedirect),
                                         ref attrs);
                    SetWidgetHandle(window);
                    if (background.Index == StandardColor.Inherit)
                    {
                        Xlib.XSetWindowBackgroundPixmap
                            (display, window, XPixmap.ParentRelative);
                    }
                    else
                    {
                        Xlib.XSetWindowBackground(display, window,
                                                  ToPixel(background));
                    }
                    if (parent.AutoMapChildren)
                    {
                        Xlib.XMapWindow(display, window);
                        mapped = true;
                    }
                }
                finally
                {
                    dpy.Unlock();
                }

                // Push the widget down to the default layer.
                layer = 0x7FFFFFFF;
                Layer = 0;
                ok    = true;

                // Select for mouse events.
                SelectInput(EventMask.ButtonPressMask |
                            EventMask.ButtonReleaseMask |
                            EventMask.EnterWindowMask |
                            EventMask.LeaveWindowMask |
                            EventMask.PointerMotionMask);
            }
            finally
            {
                if (!ok)
                {
                    // Creation failed, so detach ourselves from
                    // the parent's widget tree.
                    Detach(false);
                }
            }
        }
コード例 #11
0
ファイル: Glx.cs プロジェクト: MagmaiKH/OpenGL.Net
		public extern static IntPtr XCreateWindow(IntPtr display, IntPtr parent, int x, int y, int width, int height, int border_width, int depth, int xclass, IntPtr visual, UIntPtr valuemask, ref XSetWindowAttributes attributes);
コード例 #12
0
ファイル: lib.cs プロジェクト: RoseLeBlood/libral
 extern public static IntPtr XCreateWindow(IntPtr x11display, IntPtr x11window, TInt x, TInt y, TUint width, TUint height, TUint outsideBorderWidth,
                                           TInt depth, TUint cls, IntPtr x11visual, WindowAttributeMask valueMask, ref XSetWindowAttributes attributes);
コード例 #13
0
ファイル: X11Window.cs プロジェクト: mcjt/Avalonia
        public X11Window(AvaloniaX11Platform platform, bool popup)
        {
            _platform = platform;
            _popup    = popup;
            _x11      = platform.Info;
            _mouse    = platform.MouseDevice;
            _keyboard = platform.KeyboardDevice;
            _xic      = XCreateIC(_x11.Xim, XNames.XNInputStyle, XIMProperties.XIMPreeditNothing | XIMProperties.XIMStatusNothing,
                                  XNames.XNClientWindow, _handle, IntPtr.Zero);

            XSetWindowAttributes attr = new XSetWindowAttributes();
            var valueMask             = default(SetWindowValuemask);

            attr.backing_store = 1;
            attr.bit_gravity   = Gravity.NorthWestGravity;
            attr.win_gravity   = Gravity.NorthWestGravity;
            valueMask         |= SetWindowValuemask.BackPixel | SetWindowValuemask.BorderPixel
                                 | SetWindowValuemask.BackPixmap | SetWindowValuemask.BackingStore
                                 | SetWindowValuemask.BitGravity | SetWindowValuemask.WinGravity;

            if (popup)
            {
                attr.override_redirect = true;
                valueMask |= SetWindowValuemask.OverrideRedirect;
            }

            _handle = XCreateWindow(_x11.Display, _x11.RootWindow, 10, 10, 300, 200, 0,
                                    24,
                                    (int)CreateWindowArgs.InputOutput, IntPtr.Zero,
                                    new UIntPtr((uint)valueMask), ref attr);
            _renderHandle = XCreateWindow(_x11.Display, _handle, 0, 0, 300, 200, 0, 24,
                                          (int)CreateWindowArgs.InputOutput,
                                          IntPtr.Zero,
                                          new UIntPtr((uint)(SetWindowValuemask.BorderPixel | SetWindowValuemask.BitGravity |
                                                             SetWindowValuemask.WinGravity | SetWindowValuemask.BackingStore)), ref attr);

            Handle    = new PlatformHandle(_handle, "XID");
            _realSize = new PixelSize(300, 200);
            platform.Windows[_handle] = OnEvent;
            XEventMask ignoredMask = XEventMask.SubstructureRedirectMask
                                     | XEventMask.ResizeRedirectMask
                                     | XEventMask.PointerMotionHintMask;

            if (platform.XI2 != null)
            {
                ignoredMask |= platform.XI2.AddWindow(_handle, this);
            }
            var mask = new IntPtr(0xffffff ^ (int)ignoredMask);

            XSelectInput(_x11.Display, _handle, mask);
            var protocols = new[]
            {
                _x11.Atoms.WM_DELETE_WINDOW
            };

            XSetWMProtocols(_x11.Display, _handle, protocols, protocols.Length);
            XChangeProperty(_x11.Display, _handle, _x11.Atoms._NET_WM_WINDOW_TYPE, _x11.Atoms.XA_ATOM,
                            32, PropertyMode.Replace, new[] { _x11.Atoms._NET_WM_WINDOW_TYPE_NORMAL }, 1);

            var feature  = (EglGlPlatformFeature)AvaloniaLocator.Current.GetService <IWindowingPlatformGlFeature>();
            var surfaces = new List <object>
            {
                new X11FramebufferSurface(_x11.DeferredDisplay, _renderHandle, () => Scaling)
            };

            if (feature != null)
            {
                surfaces.Insert(0,
                                new EglGlPlatformSurface((EglDisplay)feature.Display, feature.DeferredContext,
                                                         new SurfaceInfo(this, _x11.DeferredDisplay, _handle, _renderHandle)));
            }
            Surfaces = surfaces.ToArray();
            UpdateMotifHints();
            XFlush(_x11.Display);
        }
コード例 #14
0
 internal static extern WINDOW XCreateWindow(PDISPLAY display, WINDOW parent, int x, int y, uint width, uint height, uint borderWidth,
                                             int depth, uint @class, PVISUAL visual, ULONG valuemask, ref XSetWindowAttributes attributes);