public override void Create() { using (new Xlock(Display)) { IntPtr desktop = Lib.XRootWindow(Display.RawHandle, (TInt)Display.Screen.ScreenNumber); TInt depth = Lib.XDefaultDepth(Display.RawHandle, (TInt)Display.Screen.ScreenNumber); IntPtr visual = Lib.XDefaultVisual(Display.RawHandle, (TInt)Display.Screen.ScreenNumber); m_pGame.ContextConfig.Resolution.BitsPerPixel = (int)depth; Lib.XSetWindowAttributes attributes = new Lib.XSetWindowAttributes(); attributes.event_mask = (TLong)EventMask; attributes.override_redirect = m_bFullScreen ? (TBoolean)1 : (TBoolean)0; attributes.colormap = Lib.XCreateColormap(Display.RawHandle, desktop, visual, 0 /*AllocNone*/); Rectangle.X = 0; Rectangle.Y = 0; if (m_bFullScreen) { EnableFullscreen(true, Rectangle.Size); } m_pHandle = Lib.XCreateWindow(Display.RawHandle, desktop, (TInt)0, (TInt)0, (TUint)Rectangle.Width, (TUint)Rectangle.Height, (TUint)0, (TInt)depth, (TUint)Lib.WindowClass.InputOutput, Lib.XDefaultVisual(Display.RawHandle, (TInt)Display.Screen.ScreenNumber), Lib.WindowAttributeMask.EventMask | Lib.WindowAttributeMask.Colormap | Lib.WindowAttributeMask.BackPixel | Lib.WindowAttributeMask.BorderPixel, ref attributes); if (m_pHandle == IntPtr.Zero) { throw new ApplicationException("XCreateWindow call failed (returned 0)."); } if (m_strTitle != null) { Lib.XStoreName(Display.RawHandle, m_pHandle, m_strTitle); } } Lib.XSizeHints hints = new Lib.XSizeHints(); hints.base_width = Rectangle.Width; hints.base_height = Rectangle.Height; hints.flags = Lib.XSizeHintFlags.PSize | Lib.XSizeHintFlags.PPosition; Lib.XClassHint class_hint = new Lib.XClassHint(); class_hint.res_name = Assembly.GetEntryAssembly().GetName().Name.ToLower(); class_hint.res_class = Assembly.GetEntryAssembly().GetName().Name; using (new Xlock(Display)) { Lib.XSetWMNormalHints(Display.RawHandle, m_pHandle, ref hints); var atom = Lib.XInternAtom(m_pDisplay.RawHandle, "WM_DELETE_WINDOW", false); Lib.XSetWMProtocols(Display.RawHandle, m_pHandle, ref atom, (TInt)1); Lib.XSetClassHint(Display.RawHandle, m_pHandle, ref class_hint); } if (!m_bIsResizeable) { SetWindowMinMax(Rectangle.Height, Rectangle.Width, Rectangle.Height, Rectangle.Width); } else { SetWindowMinMax(-1, -1, -1, -1); } if (m_bFullScreen) { EnableFullscreen(true, Rectangle.Size); } Register(); Application.Current.MainWindowStr = Name; OnCreate(new XEvent()); base.Create(); }
public override void Create() { int posX = m_xRectangle.X; int posY = m_xRectangle.Y; var borderPixel = m_colBorder.ToXColor(m_pDisplay); var backgroundPixel = m_colBackground.ToXColor(m_pDisplay); if (null == m_pParentWindow) { // Border width must be nil for the top-level windows! // XCreateSimpleWindow can generate BadAlloc, BadMatch, BadValue, and BadWindow errors. m_pHandle = Lib.XCreateSimpleWindow(m_pDisplay.RawHandle, Lib.XRootWindow(m_pDisplay.RawHandle, (TInt)m_pDisplay.Screen.ScreenNumber), (TInt)posX, (TInt)posY, (TUint)m_xRectangle.Width, (TUint)m_xRectangle.Height, (TUint)m_iBorderWidth, borderPixel.pixel, backgroundPixel.pixel); } else { // XCreateSimpleWindow can generate BadAlloc, BadMatch, BadValue, and BadWindow errors. m_pHandle = Lib.XCreateSimpleWindow(m_pDisplay.RawHandle, m_pParentWindow.RawHandle, (TInt)posX, (TInt)posY, (TUint)m_xRectangle.Width, (TUint)m_xRectangle.Height, (TUint)0, borderPixel.pixel, backgroundPixel.pixel); } Lib.XStoreName(m_pDisplay.RawHandle, m_pHandle, m_strTitle); // Set default window name string windowName = m_strName; Lib.XTextProperty windowNameProperty = new Lib.XTextProperty(), iconNameProperty = new Lib.XTextProperty(); if (0 == (int)Lib.XStringListToTextProperty(ref windowName, (TInt)1, ref windowNameProperty) || 0 == (int)Lib.XStringListToTextProperty(ref windowName, (TInt)1, ref iconNameProperty)) { // XDestroyWindow() can generate a BadWindow error. Lib.XDestroyWindow(m_pDisplay.RawHandle, m_pHandle); throw new XStringListToTextPropertyException(101, "Create"); } // Set Size Hints Lib.XSizeHints sizeHints = new Lib.XSizeHints(); sizeHints.flags = Lib.XSizeHintFlags.PPosition | Lib.XSizeHintFlags.PSize; sizeHints.x = m_xRectangle.X; sizeHints.y = m_xRectangle.Y; sizeHints.width = m_xRectangle.Width; sizeHints.height = m_xRectangle.Height; if (!m_bIsResizeable) { // Min and max width and height are set to prevent window's resizing. In addition, // this hides the 'restore' button on the title bar of the window. sizeHints.flags = sizeHints.flags | Lib.XSizeHintFlags.PMinSize | Lib.XSizeHintFlags.PMaxSize; sizeHints.min_width = m_xRectangle.Width; sizeHints.min_height = m_xRectangle.Height; sizeHints.max_width = m_xRectangle.Width; sizeHints.max_height = m_xRectangle.Height; } //Lib.XSetWMNormalHints(m_pDisplay.RawHandle, m_pHandle, ref sizeHints ); -- geht net ???? Execption DLL NotFound .... XSetWMNormalHints(m_pDisplay.RawHandle, m_pHandle, ref sizeHints); // Set WM Hints Lib.XWMHints wmHints = Lib.XAllocWMHints(); if (!System.IO.File.Exists(m_strIconPath)) { wmHints.flags = Lib.XWMHintMask.StateHint | Lib.XWMHintMask.InputHint; wmHints.initial_state = Lib.XWindowState.NormalState; wmHints.input = (TBoolean)1; } else { var pIcon = new Icon(m_strIconPath, Name + "_Icon", m_pDisplay.Name, m_pDisplay.Screen.Name); wmHints.flags = Lib.XWMHintMask.StateHint | Lib.XWMHintMask.IconPixmapHint | Lib.XWMHintMask.IconMaskHint | Lib.XWMHintMask.IconWindowHint | Lib.XWMHintMask.InputHint; wmHints.initial_state = Lib.XWindowState.NormalState; wmHints.input = (TBoolean)1; wmHints.icon_pixmap = pIcon.RawHandle; wmHints.icon_mask = (IntPtr)pIcon.Mask; wmHints.icon_window = m_pHandle; } Lib.XSetWMHints(m_pDisplay.RawHandle, m_pHandle, ref wmHints); // Set Class Hints Lib.XClassHint classHints = new Lib.XClassHint(); var className = m_strClassName; classHints.res_name = null; classHints.res_class = className; Lib.XSetClassHint(m_pDisplay.RawHandle, m_pHandle, ref classHints); if (null == m_pParentWindow) { var atom = Lib.XInternAtom(m_pDisplay.RawHandle, "WM_DELETE_WINDOW", false); Lib.XSetWMProtocols(m_pDisplay.RawHandle, m_pHandle, ref atom, (TInt)1); } else { Lib.XSetTransientForHint(m_pDisplay.RawHandle, m_pHandle, m_pParentWindow.RawHandle); } // If the cursor must be hidden - create the transparent cursor. if (!m_bShowCursor) { var cursorPixmap = Lib.XCreatePixmap(m_pDisplay.RawHandle, Lib.XRootWindow(m_pDisplay.RawHandle, (TInt)m_pDisplay.Screen.ScreenNumber), (TUint)1, (TUint)1, (TUint)1); Lib.XColor cursorColor = new Lib.XColor(); var cursorId = Lib.XCreatePixmapCursor(m_pDisplay.RawHandle, cursorPixmap, cursorPixmap, ref cursorColor, ref cursorColor, 0, 0); Lib.XDefineCursor(m_pDisplay.RawHandle, m_pHandle, cursorId); //Lib.XFreeCursor(m_pDisplay.RawHandle, cursorId); Lib.XFreePixmap(m_pDisplay.RawHandle, cursorPixmap); } else { // XCreateFontCursor can generate BadAlloc and BadValue errors. var cursorId = Lib.XCreateFontCursor(m_pDisplay.RawHandle, Lib.CursorFontShape.top_left_arrow); // XDefineCursor can generate BadCursor and BadWindow errors. Lib.XDefineCursor(m_pDisplay.RawHandle, m_pHandle, cursorId); // XFreeCursor can generate a BadCursor error. //::XFreeCursor(m_pDisplay.RawHandle, cursorId); } Lib.XFree(windowNameProperty.val); Lib.XFree(iconNameProperty.val); Register(); if (null != m_pParentWindow) { m_id = RegisterChild(this); } uint opacity = (uint)(((double)m_colBackground.Alpha) * 0xffffffff); Lib.XChangeProperty(m_pDisplay.RawHandle, m_pHandle, Lib.XInternAtom(m_pDisplay.RawHandle, "_NET_WM_WINDOW_OPACITY", false), Lib.AtomType.CARDINAL, (TInt)32, Lib.PropMode.Replace, ref opacity, (TInt)1); OnCreate(new XEvent()); base.Create(); }