static void DeleteIconPixmaps(IntPtr display, IntPtr window) { IntPtr wmHints_ptr = API.XGetWMHints(display, window); if (wmHints_ptr != IntPtr.Zero) { XWMHints wmHints = (XWMHints)Marshal.PtrToStructure(wmHints_ptr, typeof(XWMHints)); XWMHintsFlags flags = (XWMHintsFlags)wmHints.flags.ToInt32(); if ((flags & XWMHintsFlags.IconPixmapHint) != 0) { wmHints.flags = new IntPtr((int)(flags & ~XWMHintsFlags.IconPixmapHint)); API.XFreePixmap(display, wmHints.icon_pixmap); } if ((flags & XWMHintsFlags.IconMaskHint) != 0) { wmHints.flags = new IntPtr((int)(flags & ~XWMHintsFlags.IconMaskHint)); API.XFreePixmap(display, wmHints.icon_mask); } API.XSetWMHints(display, window, ref wmHints); API.XFree(wmHints_ptr); } }
private static void DeleteIconPixmaps(IntPtr display, IntPtr window) { using (new XLock(display)) { IntPtr num = Functions.XGetWMHints(display, window); if (!(num != IntPtr.Zero)) { return; } XWMHints wmhints = (XWMHints)Marshal.PtrToStructure(num, typeof(XWMHints)); XWMHintsFlags xwmHintsFlags = (XWMHintsFlags)wmhints.flags.ToInt32(); if ((xwmHintsFlags & XWMHintsFlags.IconPixmapHint) != (XWMHintsFlags)0) { wmhints.flags = new IntPtr((int)(xwmHintsFlags & ~XWMHintsFlags.IconPixmapHint)); Functions.XFreePixmap(display, wmhints.icon_pixmap); } if ((xwmHintsFlags & XWMHintsFlags.IconMaskHint) != (XWMHintsFlags)0) { wmhints.flags = new IntPtr((int)(xwmHintsFlags & ~XWMHintsFlags.IconMaskHint)); Functions.XFreePixmap(display, wmhints.icon_mask); } Functions.XSetWMHints(display, window, ref wmhints); Functions.XFree(num); } }
public static extern void XSetWMHints(Display display, Window w, ref XWMHints wmhints);
/// <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; }
public static void XSetWMHints(IntPtr display, IntPtr w, ref XWMHints wmhints);
public extern static void XSetWMHints(IntPtr display, IntPtr window, ref XWMHints wmhints);