当前位置: 首页>>代码示例>>C#>>正文


C# X11.XEvent类代码示例

本文整理汇总了C#中OpenTK.Platform.X11.XEvent的典型用法代码示例。如果您正苦于以下问题:C# XEvent类的具体用法?C# XEvent怎么用?C# XEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XEvent类属于OpenTK.Platform.X11命名空间,在下文中一共展示了XEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: X11GLNative

        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;
        }
开发者ID:Chameleonherman,项目名称:ClassicalSharp,代码行数:71,代码来源:X11GLNative.cs

示例2: XCheckTypedWindowEvent

 public extern static Bool XCheckTypedWindowEvent(Display display, Window w, XEventName event_type, ref XEvent event_return);
开发者ID:White-Wolf,项目名称:Minesharp,代码行数:1,代码来源:Functions.cs

示例3: IsEventValid

        static bool IsEventValid(IntPtr display, ref XEvent e, IntPtr arg)
        {
            bool valid = false;
            switch (e.type)
            {
                case XEventName.GenericEvent:
                {
                    long extension = (long)e.GenericEventCookie.extension;
                    valid =
                        extension == arg.ToInt64() &&
                        (e.GenericEventCookie.evtype == (int)XIEventType.RawKeyPress ||
                        e.GenericEventCookie.evtype == (int)XIEventType.RawKeyRelease ||
                        e.GenericEventCookie.evtype == (int)XIEventType.RawMotion ||
                        e.GenericEventCookie.evtype == (int)XIEventType.RawButtonPress ||
                        e.GenericEventCookie.evtype == (int)XIEventType.RawButtonRelease ||
                        e.GenericEventCookie.evtype == (int)XIEventType.DeviceChanged);
                    valid |= extension == 0;
                    break;
                }

                case XEventName.ClientMessage:
                    valid =
                        e.ClientMessageEvent.ptr1 == ExitAtom;
                    break;
            }

            return valid;
        }
开发者ID:RockyTV,项目名称:opentk,代码行数:28,代码来源:XI2MouseKeyboard.cs

示例4: SendNetWMMessage

        public static void SendNetWMMessage(X11WindowInfo window, IntPtr message_type, IntPtr l0, IntPtr l1, IntPtr l2)
        {
            XEvent xev;

            xev = new XEvent();
            xev.ClientMessageEvent.type = XEventName.ClientMessage;
            xev.ClientMessageEvent.send_event = true;
            xev.ClientMessageEvent.window = window.WindowHandle;
            xev.ClientMessageEvent.message_type = message_type;
            xev.ClientMessageEvent.format = 32;
            xev.ClientMessageEvent.ptr1 = l0;
            xev.ClientMessageEvent.ptr2 = l1;
            xev.ClientMessageEvent.ptr3 = l2;

            XSendEvent(window.Display, window.RootWindow, false,
                       new IntPtr((int)(EventMask.SubstructureRedirectMask | EventMask.SubstructureNotifyMask)),
                       ref xev);
        }
开发者ID:White-Wolf,项目名称:Minesharp,代码行数:18,代码来源:Functions.cs

示例5: XNextEvent

 public extern static IntPtr XNextEvent(IntPtr display, ref XEvent xevent);
开发者ID:White-Wolf,项目名称:Minesharp,代码行数:1,代码来源:Functions.cs

示例6: XSendEvent

 public extern static int XSendEvent(IntPtr display, IntPtr window, bool propagate, IntPtr event_mask, ref XEvent send_event);
开发者ID:White-Wolf,项目名称:Minesharp,代码行数:1,代码来源:Functions.cs

示例7: XFilterEvent

 public extern static bool XFilterEvent(ref XEvent xevent, IntPtr window);
开发者ID:White-Wolf,项目名称:Minesharp,代码行数:1,代码来源:Functions.cs

示例8: SendEvent

 extern public static bool SendEvent(Display display, Window window, bool propagate,
     [MarshalAs(UnmanagedType.SysInt)]EventMask event_mask, ref XEvent event_send);
开发者ID:White-Wolf,项目名称:Minesharp,代码行数:2,代码来源:API.cs

示例9: IfEvent

 public static extern bool IfEvent(Display display, ref XEvent event_return,
     /*[MarshalAs(UnmanagedType.FunctionPtr)] */ CheckEventPredicate predicate, /*XPointer*/ IntPtr arg);
开发者ID:White-Wolf,项目名称:Minesharp,代码行数:2,代码来源:API.cs

示例10: XPutBackEvent

 public static extern void XPutBackEvent(IntPtr display, ref XEvent @event);
开发者ID:White-Wolf,项目名称:Minesharp,代码行数:1,代码来源:API.cs

示例11: XRRUpdateConfiguration

 public static extern int XRRUpdateConfiguration(ref XEvent @event);
开发者ID:White-Wolf,项目名称:Minesharp,代码行数:1,代码来源:API.cs

示例12: XMaskEvent

 extern public static void XMaskEvent(IntPtr display, EventMask event_mask, ref XEvent e);
开发者ID:White-Wolf,项目名称:Minesharp,代码行数:1,代码来源:API.cs

示例13: RefreshWindowBounds

        void RefreshWindowBounds(ref XEvent e)
        {
            RefreshWindowBorders();

            Point new_location = new Point(
                e.ConfigureEvent.x - border_left,
                e.ConfigureEvent.y - border_top);
            if (Location != new_location)
            {
                bounds.Location = new_location;
                if (Move != null)
                    Move(this, EventArgs.Empty);
            }

            // Note: width and height denote the internal (client) size.
            // To get the external (window) size, we need to add the border size.
            Size new_size = new Size(
                e.ConfigureEvent.width + border_left + border_right,
                e.ConfigureEvent.height + border_top + border_bottom);
            if (Bounds.Size != new_size)
            {
                bounds.Size = new_size;
                client_rectangle.Size = new Size(e.ConfigureEvent.width, e.ConfigureEvent.height);

                if (this.Resize != null)
                {
                    //Debug.WriteLine(new System.Diagnostics.StackTrace());
                    Resize(this, EventArgs.Empty);
                }
            }
        }
开发者ID:White-Wolf,项目名称:Minesharp,代码行数:31,代码来源:X11GLNative.cs

示例14: X11GLNative

        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)
                    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.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 = 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).");

                if (title != null)
                    Functions.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);
            using (new XLock(window.Display))
            {
                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);
            }

            // 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);

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

            exists = true;
        }
开发者ID:White-Wolf,项目名称:Minesharp,代码行数:83,代码来源:X11GLNative.cs

示例15: Exit

        public void Exit()
        {
            Debug.Print("[X11] Sending exit message window {0:X} on display {1:X}", window.Handle, window.Display);

            XEvent ev = new XEvent();
            ev.type = XEventName.ClientMessage;
            ev.ClientMessageEvent.format = 32;
            ev.ClientMessageEvent.display = window.Display;
            ev.ClientMessageEvent.window = window.Handle;
            ev.ClientMessageEvent.ptr1 = _atom_wm_destroy;
            using (new XLock(window.Display))
            {
                Functions.XSendEvent(window.Display, window.Handle, false,
                    EventMask.NoEventMask, ref ev);
                Functions.XFlush(window.Display);
            }
        }
开发者ID:chantsunman,项目名称:opentk,代码行数:17,代码来源:X11GLNative.cs


注:本文中的OpenTK.Platform.X11.XEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。