Exemplo n.º 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();
        }
Exemplo n.º 2
0
        #pragma warning restore 414

        #endregion

        #region Constructors

        public X11GLNative(int x, int y, int width, int height, string title,
            GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
            : this()
        {
            if (width <= 0)
                throw new ArgumentOutOfRangeException("width", "Must be higher than zero.");
            if (height <= 0)
                throw new ArgumentOutOfRangeException("height", "Must be higher than zero.");

            Debug.Indent();

            using (new XLock(window.Display))
            {
                IntPtr visual;
                IntPtr fbconfig;
                window.GraphicsMode = new X11GraphicsMode()
                    .SelectGraphicsMode(mode, out visual, out fbconfig);

                window.Visual = visual;
                window.FBConfig = fbconfig;

                // Create a window on this display using the visual above
                Debug.Write("Opening render window... ");

                XSetWindowAttributes attributes = new XSetWindowAttributes();
                attributes.background_pixel = IntPtr.Zero;
                attributes.border_pixel = IntPtr.Zero;
                attributes.colormap = Functions.XCreateColormap(window.Display, window.RootWindow, window.VisualInfo.Visual, 0/*AllocNone*/);
                window.EventMask = EventMask.StructureNotifyMask /*| EventMask.SubstructureNotifyMask*/ | EventMask.ExposureMask |
                                   EventMask.KeyReleaseMask | EventMask.KeyPressMask | EventMask.KeymapStateMask |
                                   EventMask.PointerMotionMask | EventMask.FocusChangeMask |
                                   EventMask.ButtonPressMask | EventMask.ButtonReleaseMask |
                                   EventMask.EnterWindowMask | EventMask.LeaveWindowMask |
                                   EventMask.PropertyChangeMask;
                attributes.event_mask = (IntPtr)window.EventMask;

                SetWindowValuemask mask =
                    SetWindowValuemask.ColorMap | SetWindowValuemask.EventMask |
                    SetWindowValuemask.BackPixel | SetWindowValuemask.BorderPixel;

                window.Handle = Functions.XCreateWindow(window.Display, window.RootWindow,
                    x, y, width, height, 0, window.VisualInfo.Depth/*(int)CreateWindowArgs.CopyFromParent*/,
                    CreateWindowArgs.InputOutput, window.VisualInfo.Visual, mask, attributes);

                if (window.Handle == IntPtr.Zero)
                    throw new ApplicationException("XCreateWindow call failed (returned 0).");

                if (title != null)
                    Functions.XStoreName(window.Display, window.Handle, title);
            }

            XSizeHints hints = new XSizeHints();
            hints.base_width = width;
            hints.base_height = height;
            hints.flags = (IntPtr)(XSizeHintsFlags.PSize | XSizeHintsFlags.PPosition);

            XClassHint class_hint = new XClassHint();
            class_hint.Name = Assembly.GetEntryAssembly().GetName().Name.ToLower();
            class_hint.Class = Assembly.GetEntryAssembly().GetName().Name;

            using (new XLock(window.Display))
            {
                Functions.XSetWMNormalHints(window.Display, window.Handle, ref hints);

                // Register for window destroy notification
                Functions.XSetWMProtocols(window.Display, window.Handle, new IntPtr[] { _atom_wm_destroy }, 1);

                // Set the window class hints
                Functions.XSetClassHint(window.Display, window.Handle, ref class_hint);
            }

            SetWindowMinMax(_min_width, _min_height, -1, -1);

            // Set the initial window size to ensure X, Y, Width, Height and the rest
            // return the correct values inside the constructor and the Load event.
            XEvent e = new XEvent();
            e.ConfigureEvent.x = x;
            e.ConfigureEvent.y = y;
            e.ConfigureEvent.width = width;
            e.ConfigureEvent.height = height;
            RefreshWindowBounds(ref e);

            EmptyCursor = CreateEmptyCursor(window);

            Debug.WriteLine(String.Format("X11GLNative window created successfully (id: {0}).", Handle));
            Debug.Unindent();

            using (new XLock(window.Display))
            {
                // Request that auto-repeat is only set on devices that support it physically.
                // This typically means that it's turned off for keyboards (which is what we want).
                // We prefer this method over XAutoRepeatOff/On, because the latter needs to
                // be reset before the program exits.
                if (Xkb.IsSupported(window.Display))
                {
                    bool supported;
                    Xkb.SetDetectableAutoRepeat(window.Display, true, out supported);
                }
            }

            // The XInput2 extension makes keyboard and mouse handling much easier.
            // Check whether it is available.
            xi2_supported = XI2MouseKeyboard.IsSupported(window.Display);
            if (xi2_supported)
            {
                xi2_opcode = XI2MouseKeyboard.XIOpCode;
                xi2_version = XI2MouseKeyboard.XIVersion;
            }

            exists = true;
        }
Exemplo n.º 3
0
 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, IntPtr valuemask, ref XSetWindowAttributes attributes);
Exemplo n.º 4
0
 internal static void XChangeWindowAttributes(Display display, Window w, SetWindowValuemask valuemask, ref XSetWindowAttributes attributes)
 {
     XChangeWindowAttributes(display, w, (UIntPtr)valuemask, ref attributes);
 }
Exemplo n.º 5
0
        public X11GLNative(int x, int y, int width, int height, string title,
            GraphicsMode mode,GameWindowFlags options, DisplayDevice device)
            : this()
        {
            if (width <= 0)
                throw new ArgumentOutOfRangeException("width", "Must be higher than zero.");
            if (height <= 0)
                throw new ArgumentOutOfRangeException("height", "Must be higher than zero.");

            XVisualInfo info = new XVisualInfo();

            Debug.Indent();

            lock (API.Lock)
            {
                if (!mode.Index.HasValue)
                    throw new GraphicsModeException("Invalid or unsupported GraphicsMode.");

                info.VisualID = mode.Index.Value;
                int dummy;
                window.VisualInfo = (XVisualInfo)Marshal.PtrToStructure(
                    Functions.XGetVisualInfo(window.Display, XVisualInfoMask.ID, ref info, out dummy), typeof(XVisualInfo));

                // Create a window on this display using the visual above
                Debug.Write("Opening render window... ");

                XSetWindowAttributes attributes = new XSetWindowAttributes();
                attributes.background_pixel = IntPtr.Zero;
                attributes.border_pixel = IntPtr.Zero;
                attributes.colormap = Functions.XCreateColormap(window.Display, window.RootWindow, window.VisualInfo.Visual, 0/*AllocNone*/);
                window.EventMask = EventMask.StructureNotifyMask | EventMask.SubstructureNotifyMask | EventMask.ExposureMask |
                                   EventMask.KeyReleaseMask | EventMask.KeyPressMask |
                                   EventMask.PointerMotionMask | EventMask.FocusChangeMask |
                                   EventMask.ButtonPressMask | EventMask.ButtonReleaseMask;
                attributes.event_mask = (IntPtr)window.EventMask;

                uint mask = (uint)SetWindowValuemask.ColorMap | (uint)SetWindowValuemask.EventMask |
                    (uint)SetWindowValuemask.BackPixel | (uint)SetWindowValuemask.BorderPixel;

                window.WindowHandle = Functions.XCreateWindow(window.Display, window.RootWindow,
                    x, y, width, height, 0, window.VisualInfo.Depth/*(int)CreateWindowArgs.CopyFromParent*/,
                    (int)CreateWindowArgs.InputOutput, window.VisualInfo.Visual, (UIntPtr)mask, ref attributes);

                if (window.WindowHandle == IntPtr.Zero)
                    throw new ApplicationException("XCreateWindow call failed (returned 0).");
            }

            // Set the window hints
            SetWindowMinMax(_min_width, _min_height, -1, -1);

            XSizeHints hints = new XSizeHints();
            hints.base_width = width;
            hints.base_height = height;
            hints.flags = (IntPtr)(XSizeHintsFlags.PSize | XSizeHintsFlags.PPosition);
            lock (API.Lock)
            {
                Functions.XSetWMNormalHints(window.Display, window.WindowHandle, ref hints);

                // Register for window destroy notification
                Functions.XSetWMProtocols(window.Display, window.WindowHandle, new IntPtr[] { _atom_wm_destroy }, 1);

                API.MapRaised(window.Display, window.WindowHandle);
            }

            driver = new X11Input(window);

            Debug.WriteLine(String.Format("X11GLNative window created successfully (id: {0}).", Handle));
            Debug.Unindent();

            exists = true;
        }
Exemplo n.º 6
0
 [DllImport(X11Library, EntryPoint = "XCreateWindow")]//, CLSCompliant(false)]
 public extern static Window XCreateWindow(Display display, Window parent,
     int x, int y, int width, int height, int border_width, int depth,
     int @class, IntPtr visual, UIntPtr valuemask, ref XSetWindowAttributes attributes);
Exemplo n.º 7
0
 internal static extern void XChangeWindowAttributes(Display display, Window w, UIntPtr valuemask, ref XSetWindowAttributes attributes);
Exemplo n.º 8
0
        public X11GLNative(int x, int y, int width, int height, string title,
            GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
        {
            if (width <= 0)
                throw new ArgumentOutOfRangeException("width", "Must be higher than zero.");
            if (height <= 0)
                throw new ArgumentOutOfRangeException("height", "Must be higher than zero.");

            Debug.Print("Creating X11GLNative window.");
            // Open a display connection to the X server, and obtain the screen and root window.
            window.Display = API.DefaultDisplay;
            window.Screen = API.XDefaultScreen(window.Display); //API.DefaultScreen;
            window.RootWindow = API.XRootWindow(window.Display, window.Screen); // API.RootWindow;

            Debug.Print("Display: {0}, Screen {1}, Root window: {2}", window.Display, window.Screen, window.RootWindow);
            RegisterAtoms(window);
            XVisualInfo info = new XVisualInfo();
            mode = X11GLContext.SelectGraphicsMode( mode, out info );
            window.VisualInfo = info;
            // Create a window on this display using the visual above
            Debug.Print("Opening render window... ");

            XSetWindowAttributes attributes = new XSetWindowAttributes();
            attributes.background_pixel = IntPtr.Zero;
            attributes.border_pixel = IntPtr.Zero;
            attributes.colormap = API.XCreateColormap(window.Display, window.RootWindow, window.VisualInfo.Visual, 0/*AllocNone*/);
            window.EventMask = EventMask.StructureNotifyMask /*| EventMask.SubstructureNotifyMask*/ | EventMask.ExposureMask |
                EventMask.KeyReleaseMask | EventMask.KeyPressMask | EventMask.KeymapStateMask |
                EventMask.PointerMotionMask | EventMask.FocusChangeMask |
                EventMask.ButtonPressMask | EventMask.ButtonReleaseMask |
                EventMask.EnterWindowMask | EventMask.LeaveWindowMask |
                EventMask.PropertyChangeMask;
            attributes.event_mask = (IntPtr)window.EventMask;

            uint mask = (uint)SetWindowValuemask.ColorMap | (uint)SetWindowValuemask.EventMask |
                (uint)SetWindowValuemask.BackPixel | (uint)SetWindowValuemask.BorderPixel;

            window.WindowHandle = API.XCreateWindow(window.Display, window.RootWindow,
                                                    x, y, width, height, 0, window.VisualInfo.Depth/*(int)CreateWindowArgs.CopyFromParent*/,
                                                    (int)CreateWindowArgs.InputOutput, window.VisualInfo.Visual, (IntPtr)mask, ref attributes);

            if (window.WindowHandle == IntPtr.Zero)
                throw new ApplicationException("XCreateWindow call failed (returned 0).");

            if (title != null)
                API.XStoreName(window.Display, window.WindowHandle, title);

            // Set the window hints
            SetWindowMinMax(_min_width, _min_height, -1, -1);

            XSizeHints hints = new XSizeHints();
            hints.base_width = width;
            hints.base_height = height;
            hints.flags = (IntPtr)(XSizeHintsFlags.PSize | XSizeHintsFlags.PPosition);
            API.XSetWMNormalHints(window.Display, window.WindowHandle, ref hints);
            // Register for window destroy notification
            API.XSetWMProtocols(window.Display, window.WindowHandle, new IntPtr[] { wm_destroy }, 1);

            // Set the initial window size to ensure X, Y, Width, Height and the rest
            // return the correct values inside the constructor and the Load event.
            XEvent e = new XEvent();
            e.ConfigureEvent.x = x;
            e.ConfigureEvent.y = y;
            e.ConfigureEvent.width = width;
            e.ConfigureEvent.height = height;
            RefreshWindowBounds(ref e);

            Debug.Print("X11GLNative window created successfully (id: {0}).", Handle);
            SetupInput();
            exists = true;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Opens a new render window with the given DisplayMode.
        /// </summary>
        /// <param name="mode">The DisplayMode of the render window.</param>
        /// <remarks>
        /// Creates the window visual and colormap. Associates the colormap/visual
        /// with the window and raises the window on top of the window stack.
        /// <para>
        /// Colormap creation is currently disabled.
        /// </para>
        /// </remarks>
        public void CreateWindow(DisplayMode mode, out IGLContext glContext)
        {
            if (exists)
                throw new ApplicationException("Render window already exists!");

            Debug.Print("Creating GameWindow with mode: {0}", mode != null ? mode.ToString() : "default");
            Debug.Indent();

            glContext = new X11GLContext();
            (glContext as IGLContextCreationHack).SelectDisplayMode(mode, window);
            if (glContext == null)
                throw new ApplicationException("Could not create GLContext");
            Debug.Print("Created GLContext");
            window.VisualInfo = ((X11.WindowInfo)((IGLContextInternal)glContext).Info).VisualInfo;
            //window.VisualInfo = Marshal.PtrToStructure(Glx.ChooseVisual(window.Display, window.Screen, 

            // Create a window on this display using the visual above
            Debug.Write("Opening render window... ");

            XSetWindowAttributes attributes = new XSetWindowAttributes();
            attributes.background_pixel = IntPtr.Zero;
            attributes.border_pixel = IntPtr.Zero;
            attributes.colormap =
                API.CreateColormap(window.Display, window.RootWindow, window.VisualInfo.visual, 0/*AllocNone*/);
            window.EventMask =
                EventMask.StructureNotifyMask | EventMask.SubstructureNotifyMask | EventMask.ExposureMask |
                EventMask.KeyReleaseMask | EventMask.KeyPressMask |
                    EventMask.PointerMotionMask | /* Bad! EventMask.PointerMotionHintMask | */
                    EventMask.ButtonPressMask | EventMask.ButtonReleaseMask;
            attributes.event_mask = (IntPtr)window.EventMask;

            uint mask = (uint)SetWindowValuemask.ColorMap | (uint)SetWindowValuemask.EventMask |
                (uint)SetWindowValuemask.BackPixel | (uint)SetWindowValuemask.BorderPixel;

            window.Handle = Functions.XCreateWindow(window.Display, window.RootWindow,
                0, 0, mode.Width, mode.Height, 0, window.VisualInfo.depth/*(int)CreateWindowArgs.CopyFromParent*/,
                (int)CreateWindowArgs.InputOutput, window.VisualInfo.visual, (UIntPtr)mask, ref attributes);

            if (window.Handle == IntPtr.Zero)
                throw new ApplicationException("XCreateWindow call failed (returned 0).");

            // Set the window hints
            XSizeHints hints = new XSizeHints();
            hints.x = 0;
            hints.y = 0;
            hints.width = mode.Width;
            hints.height = mode.Height;
            hints.flags = (IntPtr)(XSizeHintsFlags.USSize | XSizeHintsFlags.USPosition);
            Functions.XSetWMNormalHints(window.Display, window.Handle, ref hints);

            // Register for window destroy notification
            IntPtr wm_destroy_atom = Functions.XInternAtom(window.Display,
                "WM_DELETE_WINDOW", true);
            XWMHints hint = new XWMHints();
            Functions.XSetWMProtocols(window.Display, window.Handle, new IntPtr[] { wm_destroy_atom }, 1);

            Top = Left = 0;
            Right = Width;
            Bottom = Height;

            //XTextProperty text = new XTextProperty();
            //text.value = "OpenTK Game Window";
            //text.format = 8;
            //Functions.XSetWMName(window.Display, window.Handle, ref text);
            //Functions.XSetWMProperties(display, window, name, name, 0,  /*None*/ null, 0, hints);

            Debug.Print("done! (id: {0})", window.Handle);

            (glContext as IGLContextCreationHack).SetWindowHandle(window.Handle);

            API.MapRaised(window.Display, window.Handle);
            mapped = true;

            glContext.CreateContext(true, null);

            driver = new X11Input(window);

            Debug.Unindent();
            Debug.WriteLine("GameWindow creation completed successfully!");
            exists = true;
        }
Exemplo n.º 10
0
        public X11GLNative(int x, int y, int width, int height, string title,
            GraphicsMode mode,GameWindowFlags options, DisplayDevice device)
            : this()
        {
            if (width <= 0)
                throw new ArgumentOutOfRangeException("width", "Must be higher than zero.");
            if (height <= 0)
                throw new ArgumentOutOfRangeException("height", "Must be higher than zero.");

            XVisualInfo info = new XVisualInfo();

            Debug.Indent();
            
            using (new XLock(window.Display))
            {
                if (!mode.Index.HasValue)
                {
                    mode = new X11GraphicsMode().SelectGraphicsMode(
                        mode.ColorFormat, mode.Depth, mode.Stencil, mode.Samples,
                        mode.AccumulatorFormat, mode.Buffers, mode.Stereo);
                }

                info.VisualID = mode.Index.Value;
                int dummy;
                window.VisualInfo = (XVisualInfo)Marshal.PtrToStructure(
                    Functions.XGetVisualInfo(window.Display, XVisualInfoMask.ID, ref info, out dummy), typeof(XVisualInfo));

                // Create a window on this display using the visual above
                Debug.Write("Opening render window... ");

                XSetWindowAttributes attributes = new XSetWindowAttributes();
                attributes.background_pixel = IntPtr.Zero;
                attributes.border_pixel = IntPtr.Zero;
                attributes.colormap = Functions.XCreateColormap(window.Display, window.RootWindow, window.VisualInfo.Visual, 0/*AllocNone*/);
                window.EventMask = EventMask.StructureNotifyMask /*| EventMask.SubstructureNotifyMask*/ | EventMask.ExposureMask |
                                   EventMask.KeyReleaseMask | EventMask.KeyPressMask | EventMask.KeymapStateMask |
                                   EventMask.PointerMotionMask | EventMask.FocusChangeMask |
                                   EventMask.ButtonPressMask | EventMask.ButtonReleaseMask |
                                   EventMask.EnterWindowMask | EventMask.LeaveWindowMask |
                                   EventMask.PropertyChangeMask;
                attributes.event_mask = (IntPtr)window.EventMask;

                uint mask = (uint)SetWindowValuemask.ColorMap | (uint)SetWindowValuemask.EventMask |
                    (uint)SetWindowValuemask.BackPixel | (uint)SetWindowValuemask.BorderPixel;

                window.Handle = Functions.XCreateWindow(window.Display, window.RootWindow,
                    x, y, width, height, 0, window.VisualInfo.Depth/*(int)CreateWindowArgs.CopyFromParent*/,
                    (int)CreateWindowArgs.InputOutput, window.VisualInfo.Visual, (UIntPtr)mask, ref attributes);

                if (window.Handle == IntPtr.Zero)
                    throw new ApplicationException("XCreateWindow call failed (returned 0).");

                if (title != null)
                    Functions.XStoreName(window.Display, window.Handle, title);
            }

            // Set the window hints
            SetWindowMinMax(_min_width, _min_height, -1, -1);            
            
            XSizeHints hints = new XSizeHints();
            hints.base_width = width;
            hints.base_height = height;
            hints.flags = (IntPtr)(XSizeHintsFlags.PSize | XSizeHintsFlags.PPosition);
            using (new XLock(window.Display))
            {
                Functions.XSetWMNormalHints(window.Display, window.Handle, ref hints);

                // Register for window destroy notification
                Functions.XSetWMProtocols(window.Display, window.Handle, new IntPtr[] { _atom_wm_destroy }, 1);
            }

            // Set the initial window size to ensure X, Y, Width, Height and the rest
            // return the correct values inside the constructor and the Load event.
            XEvent e = new XEvent();
            e.ConfigureEvent.x = x;
            e.ConfigureEvent.y = y;
            e.ConfigureEvent.width = width;
            e.ConfigureEvent.height = height;
            RefreshWindowBounds(ref e);

            driver = new X11Input(window);
            keyboard = driver.Keyboard[0];
            mouse = driver.Mouse[0];

            EmptyCursor = CreateEmptyCursor(window);

            Debug.WriteLine(String.Format("X11GLNative window created successfully (id: {0}).", Handle));
            Debug.Unindent();

            exists = true;
        }
Exemplo n.º 11
0
 /// <summary>
 /// The XCreateWindow function creates an unmapped subwindow for a specified parent window, returns the window ID of the created window, and causes the X server to generate a CreateNotify event. The created window is placed on top in the stacking order with respect to siblings.
 /// </summary>
 /// <param name="display">Specifies the connection to the X server.</param>
 /// <param name="parent">Specifies the parent window.</param>
 /// <param name="x">Specify the x coordinates, which are the top-left outside corner of the window's borders and are relative to the inside of the parent window's borders.</param>
 /// <param name="y">Specify the y coordinates, which are the top-left outside corner of the window's borders and are relative to the inside of the parent window's borders.</param>
 /// <param name="width">Specify the width, which is the created window's inside dimensions and do not include the created window's borders.</param>
 /// <param name="height">Specify the height, which is the created window's inside dimensions and do not include the created window's borders.</param>
 /// <param name="border_width">Specifies the width of the created window's border in pixels.</param>
 /// <param name="depth">Specifies the window's depth. A depth of CopyFromParent means the depth is taken from the parent.</param>
 /// <param name="class">Specifies the created window's class. You can pass InputOutput, InputOnly, or CopyFromParent. A class of CopyFromParent means the class is taken from the parent.</param>
 /// <param name="visual">Specifies the visual type. A visual of CopyFromParent means the visual type is taken from the parent.</param>
 /// <param name="valuemask">Specifies which window attributes are defined in the attributes argument. This mask is the bitwise inclusive OR of the valid attribute mask bits. If valuemask is zero, the attributes are ignored and are not referenced.</param>
 /// <param name="attributes">Specifies the structure from which the values (as specified by the value mask) are to be taken. The value mask should have the appropriate bits set to indicate which attributes have been set in the structure.</param>
 /// <returns>The window ID of the created window.</returns>
 /// <remarks>
 /// The coordinate system has the X axis horizontal and the Y axis vertical with the origin [0, 0] at the upper-left corner. Coordinates are integral, in terms of pixels, and coincide with pixel centers. Each window and pixmap has its own coordinate system. For a window, the origin is inside the border at the inside, upper-left corner. 
 /// <para>The border_width for an InputOnly window must be zero, or a BadMatch error results. For class InputOutput, the visual type and depth must be a combination supported for the screen, or a BadMatch error results. The depth need not be the same as the parent, but the parent must not be a window of class InputOnly, or a BadMatch error results. For an InputOnly window, the depth must be zero, and the visual must be one supported by the screen. If either condition is not met, a BadMatch error results. The parent window, however, may have any depth and class. If you specify any invalid window attribute for a window, a BadMatch error results. </para>
 /// <para>The created window is not yet displayed (mapped) on the user's display. To display the window, call XMapWindow(). The new window initially uses the same cursor as its parent. A new cursor can be defined for the new window by calling XDefineCursor(). The window will not be visible on the screen unless it and all of its ancestors are mapped and it is not obscured by any of its ancestors. </para>
 /// <para>XCreateWindow can generate BadAlloc BadColor, BadCursor, BadMatch, BadPixmap, BadValue, and BadWindow errors. </para>
 /// <para>The XCreateSimpleWindow function creates an unmapped InputOutput subwindow for a specified parent window, returns the window ID of the created window, and causes the X server to generate a CreateNotify event. The created window is placed on top in the stacking order with respect to siblings. Any part of the window that extends outside its parent window is clipped. The border_width for an InputOnly window must be zero, or a BadMatch error results. XCreateSimpleWindow inherits its depth, class, and visual from its parent. All other window attributes, except background and border, have their default values. </para>
 /// <para>XCreateSimpleWindow can generate BadAlloc, BadMatch, BadValue, and BadWindow errors.</para>
 /// </remarks>
 public static Window XCreateWindow(Display display, Window parent,
     int x, int y, int width, int height, int border_width, int depth,
     CreateWindowArgs @class, IntPtr visual, SetWindowValuemask valuemask,
     XSetWindowAttributes? attributes)
 {
     unsafe
     {
         if (attributes.HasValue)
         {
             XSetWindowAttributes attr = attributes.Value;
             return XCreateWindow(display, parent, x, y, width, height, border_width, depth,
                 (int)@class, visual, (IntPtr)valuemask, &attr);
         }
         else
         {
             return XCreateWindow(display, parent, x, y, width, height, border_width, depth,
                 (int)@class, visual, (IntPtr)valuemask, null);
         }
     }
 }
Exemplo n.º 12
0
 internal static void XChangeWindowAttributes(IntPtr display, IntPtr w, SetWindowValuemask valuemask, ref XSetWindowAttributes attributes)
 {
     Functions.XChangeWindowAttributes(display, w, (UIntPtr) ((ulong) valuemask), ref attributes);
 }
Exemplo n.º 13
0
 internal static void XChangeWindowAttributes(IntPtr display, IntPtr w, UIntPtr valuemask, ref XSetWindowAttributes attributes);
Exemplo n.º 14
0
 public X11GLNative(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
   : this()
 {
   if (width <= 0)
     throw new ArgumentOutOfRangeException("width", "Must be higher than zero.");
   if (height <= 0)
     throw new ArgumentOutOfRangeException("height", "Must be higher than zero.");
   XVisualInfo template = new XVisualInfo();
   using (new XLock(this.window.Display))
   {
     if (!mode.Index.HasValue)
       throw new GraphicsModeException("Invalid or unsupported GraphicsMode.");
     template.VisualID = mode.Index.Value;
     int nitems;
     this.window.VisualInfo = (XVisualInfo) Marshal.PtrToStructure(Functions.XGetVisualInfo(this.window.Display, XVisualInfoMask.ID, ref template, out nitems), typeof (XVisualInfo));
     XSetWindowAttributes attributes = new XSetWindowAttributes();
     attributes.background_pixel = IntPtr.Zero;
     attributes.border_pixel = IntPtr.Zero;
     attributes.colormap = Functions.XCreateColormap(this.window.Display, this.window.RootWindow, this.window.VisualInfo.Visual, 0);
     this.window.EventMask = EventMask.KeyPressMask | EventMask.KeyReleaseMask | EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.EnterWindowMask | EventMask.LeaveWindowMask | EventMask.PointerMotionMask | EventMask.KeymapStateMask | EventMask.ExposureMask | EventMask.StructureNotifyMask | EventMask.FocusChangeMask | EventMask.PropertyChangeMask;
     attributes.event_mask = (IntPtr) ((long) this.window.EventMask);
     uint num = 10250U;
     this.window.WindowHandle = Functions.XCreateWindow(this.window.Display, this.window.RootWindow, x, y, width, height, 0, this.window.VisualInfo.Depth, 1, this.window.VisualInfo.Visual, (UIntPtr) num, ref attributes);
     if (this.window.WindowHandle == IntPtr.Zero)
       throw new ApplicationException("XCreateWindow call failed (returned 0).");
     if (title != null)
       Functions.XStoreName(this.window.Display, this.window.WindowHandle, title);
   }
   this.SetWindowMinMax((short) 30, (short) 30, (short) -1, (short) -1);
   XSizeHints hints = new XSizeHints();
   hints.base_width = width;
   hints.base_height = height;
   hints.flags = (IntPtr) 12L;
   using (new XLock(this.window.Display))
   {
     Functions.XSetWMNormalHints(this.window.Display, this.window.WindowHandle, ref hints);
     Functions.XSetWMProtocols(this.window.Display, this.window.WindowHandle, new IntPtr[1]
     {
       this._atom_wm_destroy
     }, 1);
   }
   this.RefreshWindowBounds(ref new XEvent()
   {
     ConfigureEvent = {
       x = x,
       y = y,
       width = width,
       height = height
     }
   });
   this.driver = new X11Input((IWindowInfo) this.window);
   this.mouse = this.driver.Mouse[0];
   this.EmptyCursor = X11GLNative.CreateEmptyCursor(this.window);
   this.exists = true;
 }