示例#1
0
文件: GLwDrawA.c 项目: iquiw/xsrc
static void Realize(Widget w,Mask *valueMask,XSetWindowAttributes *attributes) {
    register GLwDrawingAreaWidget glw=(GLwDrawingAreaWidget)w;
    GLwDrawingAreaCallbackStruct cb;
    Widget parentShell;
    Status status;
    Window windows[2],*windowsReturn,*windowList;
    int countReturn,i;

    /* if we haven't requested that the background be both installed and
     * allocated, don't install it.
     */
    if(!(glw->glwDrawingArea.installBackground && glw->glwDrawingArea.allocateBackground)) {
        *valueMask&=~CWBackPixel;
    }

    XtCreateWindow(w,(unsigned int)InputOutput,glw->glwDrawingArea.visualInfo->visual,*valueMask,attributes);

    /* if appropriate, call XSetWMColormapWindows to install the colormap */
    if(glw->glwDrawingArea.installColormap) {

        /* Get parent shell */
        for(parentShell=XtParent(w); parentShell&&!XtIsShell(parentShell); parentShell=XtParent(parentShell));

        if(parentShell && XtWindow(parentShell)) {

            /* check to see if there is already a property */
            status=XGetWMColormapWindows(XtDisplay(parentShell),XtWindow(parentShell),&windowsReturn,&countReturn);

            /* if no property, just create one */
            if(!status) {
                windows[0]=XtWindow(w);
                windows[1]=XtWindow(parentShell);
                XSetWMColormapWindows(XtDisplay(parentShell),XtWindow(parentShell),windows,2);
            }

            /* there was a property, add myself to the beginning */
            else {
                windowList=(Window *)XtMalloc((sizeof(Window))*(countReturn+1));
                windowList[0]=XtWindow(w);
                for(i=0; i<countReturn; i++) windowList[i+1]=windowsReturn[i];
                XSetWMColormapWindows(XtDisplay(parentShell),XtWindow(parentShell),windowList,countReturn+1);
                XtFree((char*)windowList);
                XtFree((char*)windowsReturn);
            }
        }
        else {
            warning(w,"Could not set colormap property on parent shell");
        }
    }

    /* Invoke callbacks */
    cb.reason=GLwCR_GINIT;
    cb.event=NULL;
    cb.width=glw->core.width;
    cb.height=glw->core.height;
    XtCallCallbackList((Widget)glw,glw->glwDrawingArea.ginitCallback,&cb);
}
示例#2
0
/***********************************************************************
 * Add window to the WM_COLORMAP_WINDOWS property on the Netscape
 * toplevel widget if necessary
 ***********************************************************************/
static void
SetWMColormap(PluginInstance* This, Window win)
{
    int i;
    Colormap top_cmap;
    Arg arg;

    /* get window's record */
    for (i = 0; i < This->nclient_windows; i++)
	if ((This->client_windows[i].win = win))
	    break;

    if (i == This->nclient_windows)
	return;

    /* if window's colormap is different from toplevel's one set property */
    XtSetArg(arg, XtNcolormap, &top_cmap);
    XtGetValues(This->toplevel_widget, &arg, 1);
    if (This->client_windows[i].colormap != top_cmap) {
	Window *cur_list;
	int cur_count = 0;

	/* if there is already a non empty list we need to update it */
	if (XGetWMColormapWindows(RxGlobal.dpy, XtWindow(This->toplevel_widget),
				  &cur_list, &cur_count) == True &&
	    cur_count != 0) {

	    if (IsInWinList(cur_list, cur_count, win)) {
		/* window is already in the list just move it in first place */
		SetFirstWinList(cur_list, cur_count, win);
		XSetWMColormapWindows(RxGlobal.dpy,
				      XtWindow(This->toplevel_widget),
				      cur_list, cur_count);
	    } else {
		/* window is not in the list add it in first place */
		Window *new_list;
		int new_count;

		PrependToWinList(&new_list, &new_count,
				 cur_list, cur_count, win);
		XSetWMColormapWindows(RxGlobal.dpy,
				      XtWindow(This->toplevel_widget),
				      new_list, new_count);
		free(new_list);
	    }
	} else {		/* no list yet so lets make one */
	    Window list[2];

	    list[0] = win;
	    list[1] = XtWindow(This->toplevel_widget);
	    XSetWMColormapWindows(RxGlobal.dpy, XtWindow(This->toplevel_widget),
				  list, 2);
	}
	if (cur_count != 0)
	    XFree(cur_list);
    }
}
示例#3
0
void _Fl_Overlay::create()
{
    Fl_X::create(this, fl_overlay_visual, fl_overlay_colormap, int(fl_transparent_pixel));
    // find the outermost window to tell wm about the colormap:
    Fl_Window *w = window();
    for (;;) {Fl_Window *w1 = w->window(); if (!w1) break; w = w1;}
    XSetWMColormapWindows(fl_display, fl_xid(w), &(Fl_X::i(this)->xid), 1);
}
示例#4
0
static void
BegWMColormap( FLI_CANVAS_SPEC * sp )
{

    /* Set WM_COLORMAP property. Seems some versions of tvtwm have problems
       with setting this property. This check simply works around the problem
       (for most cases). */

    if (    sp->colormap != fli_colormap( fl_vmode )
         && ! XSetWMColormapWindows( flx->display, sp->parent,
                                     &sp->window, 1 ) )
        M_err( "BegWMColormap", "WM choked" );
}
示例#5
0
/***********************************************************************
 * Move window at the end of the WM_COLORMAP_WINDOWS property list on
 * the Netscape toplevel widget
 ***********************************************************************/
static void
UnsetWMColormap(PluginInstance* This, Window win)
{
    Window *list;
    int count = 0;

    if (XGetWMColormapWindows(RxGlobal.dpy, XtWindow(This->toplevel_widget),
			      &list, &count) == True && count != 0) {
	SetLastWinList(list, count, win);
	XSetWMColormapWindows(RxGlobal.dpy, XtWindow(This->toplevel_widget),
			      list, count);
    }
    if (count != 0)
	XFree(list);
}
示例#6
0
static void
Destroy(
  SoXtGLAreaWidget glw)
{
  Window * windowsReturn;
  Widget parentShell;
  Status status;
  int countReturn;
  register int i;

  if (glw->soxtGLArea.myList && glw->soxtGLArea.attribList)
    XtFree((char *) glw->soxtGLArea.attribList);

  if (glw->soxtGLArea.myVisual && glw->soxtGLArea.visualInfo)
    XtFree((char *) glw->soxtGLArea.visualInfo);

  // if my colormap was installed, remove it
  if (glw->soxtGLArea.installColormap) {
    // Get parent shell
    for (parentShell = XtParent(glw);
          parentShell && ! XtIsShell(parentShell);
          parentShell = XtParent(parentShell)) { }

    if (parentShell && XtWindow(parentShell)) {
      // make sure there is a property
      status = XGetWMColormapWindows(XtDisplay(parentShell),
                                      XtWindow(parentShell),
                                      &windowsReturn, &countReturn);
            
      // if no property, just return.  If there was a property, continue
      if (status) {
        // search for a match
        for (i = 0; i < countReturn; i++) {
          if (windowsReturn[i] == XtWindow(glw)) {
            // we found a match, now copy the rest down
            for (i++; i < countReturn; i++)
              windowsReturn[i-1] = windowsReturn[i];

            XSetWMColormapWindows(XtDisplay(parentShell),
              XtWindow(parentShell), windowsReturn, countReturn-1);
            break; 
          }
        }
        XtFree((char *) windowsReturn);
      }
    }
  }
} // Destroy()
示例#7
0
文件: GLwDrawA.c 项目: iquiw/xsrc
static void Destroy(GLwDrawingAreaWidget glw) {
    Window *windowsReturn;
    Widget parentShell;
    Status status;
    int countReturn;
    register int i;

    if(glw->glwDrawingArea.myList && glw->glwDrawingArea.attribList) {
        XtFree((XtPointer)glw->glwDrawingArea.attribList);
    }

    if(glw->glwDrawingArea.myVisual && glw->glwDrawingArea.visualInfo) {
        XtFree((XtPointer)glw->glwDrawingArea.visualInfo);
    }

    /* if my colormap was installed, remove it */
    if(glw->glwDrawingArea.installColormap) {

        /* Get parent shell */
        for(parentShell=XtParent(glw); parentShell&&!XtIsShell(parentShell); parentShell=XtParent(parentShell));

        if(parentShell && XtWindow(parentShell)) {

            /* make sure there is a property */
            status=XGetWMColormapWindows(XtDisplay(parentShell),XtWindow(parentShell),&windowsReturn,&countReturn);

            /* if no property, just return.  If there was a property, continue */
            if(status) {

                /* search for a match */
                for(i=0; i<countReturn; i++) {
                    if(windowsReturn[i]==XtWindow(glw)) {

                        /* we found a match, now copy the rest down */
                        for(i++; i<countReturn; i++) {
                            windowsReturn[i-1]=windowsReturn[i];
                        }

                        XSetWMColormapWindows(XtDisplay(parentShell),XtWindow(parentShell),windowsReturn,countReturn-1);
                        break;
                    }
                }
                XtFree((char *)windowsReturn);
            }
        }
    }
}
示例#8
0
/***********************************************************************
 * Remove window from the WM_COLORMAP_WINDOWS property on the Netscape
 * toplevel widget
 ***********************************************************************/
static void
ResetWMColormap(PluginInstance* This, Window win)
{
    Window *list;
    int count = 0;

    if (XGetWMColormapWindows(RxGlobal.dpy, XtWindow(This->toplevel_widget),
			      &list, &count) == True && count != 0) {
	RemoveFromWinList(&list, &count, win);

	if (count > 1)
	    XSetWMColormapWindows(RxGlobal.dpy, XtWindow(This->toplevel_widget),
				  list, count);
	else {			/* remove list when it becomes useless */
	    Atom prop;

	    prop = XInternAtom (RxGlobal.dpy, "WM_COLORMAP_WINDOWS", False);
	    XDeleteProperty(RxGlobal.dpy, XtWindow(This->toplevel_widget), prop);
	}
    }
    if (count != 0)
	XFree(list);
}
示例#9
0
/*!***********************************************************************
 @Function		OpenX11Window
 @Return		true on success
 @Description	Opens an X11 window. This must be called after
				SelectEGLConfiguration() for gEglConfig to be valid
*************************************************************************/
int PVRShellInitOS::OpenX11Window(const PVRShell &shell)
{
    XSetWindowAttributes	WinAttibutes;
    XSizeHints				sh;
    XEvent					event;
    unsigned long			mask;

#ifdef BUILD_OGL
    XF86VidModeModeInfo **modes;       // modes of display
    int numModes;                      // number of modes of display
    int chosenMode;
    int edimx,edimy;                   //established width and height of the chosen modeline
    int i;
#endif

	int depth = DefaultDepth(m_X11Display, m_X11Screen);
	m_X11Visual = new XVisualInfo;
	XMatchVisualInfo( m_X11Display, m_X11Screen, depth, TrueColor, m_X11Visual);

    if( !m_X11Visual )
    {
    	shell.PVRShellOutputDebug( "Unable to acquire visual" );
    	return false;
    }

    m_X11ColorMap = XCreateColormap( m_X11Display, RootWindow(m_X11Display, m_X11Screen), m_X11Visual->visual, AllocNone );

#ifdef BUILD_OGL
    m_i32OriginalModeDotClock = XF86VidModeBadClock;
    if(shell.m_pShellData->bFullScreen)
    {
        // Get mode lines to see if there is requested modeline
        XF86VidModeGetAllModeLines(m_X11Display, m_X11Screen, &numModes, &modes);

        // look for mode with requested resolution
        chosenMode = -1;
        i=0;
        while((chosenMode == -1)&&(i<numModes))
        {
            if ((modes[i]->hdisplay == shell.m_pShellData->nShellDimX) && (modes[i]->vdisplay == shell.m_pShellData->nShellDimY))
            {
                chosenMode = i;
            }
            ++i;
        }

        // If there is no requested resolution among modelines then terminate
        if(chosenMode == -1)
        {
            shell.PVRShellOutputDebug( "Chosen resolution for full screen mode does not match any modeline available.\n" );
            return false;
        }

        // save desktop-resolution before switching modes
        XF86VidModeGetModeLine(m_X11Display,m_X11Screen, &m_i32OriginalModeDotClock, &m_OriginalMode );

        XF86VidModeSwitchToMode(m_X11Display, m_X11Screen, modes[chosenMode]);
        XF86VidModeSetViewPort(m_X11Display, m_X11Screen, 0, 0);
        edimx = modes[chosenMode]->hdisplay;
        edimy = modes[chosenMode]->vdisplay;
        printf("Fullscreen Resolution %dx%d (chosen mode = %d)\n", edimx, edimy,chosenMode);
        XFree(modes);

		WinAttibutes.colormap = m_X11ColorMap;
		WinAttibutes.background_pixel = 0xFFFFFFFF;
		WinAttibutes.border_pixel = 0;
        WinAttibutes.override_redirect = true;

		// add to these for handling other events
		WinAttibutes.event_mask = StructureNotifyMask | ExposureMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask | KeyPressMask | KeyReleaseMask;

        // The diffrence is that we want to ignore influence of window manager for our fullscreen window
        mask = CWBackPixel | CWBorderPixel | CWEventMask | CWColormap | CWOverrideRedirect;

        m_X11Window = XCreateWindow( m_X11Display, RootWindow(m_X11Display, m_X11Screen), 0, 0, edimx, edimy, 0,
                                    CopyFromParent, InputOutput, CopyFromParent, mask, &WinAttibutes);

        // keeping the pointer of mouse and keyboard in window to prevent from scrolling the virtual screen
        XWarpPointer(m_X11Display, None ,m_X11Window, 0, 0, 0, 0, 0, 0);

        // Map and then wait till mapped, grabbing should be after mapping the window
        XMapWindow( m_X11Display, m_X11Window );
        XGrabKeyboard(m_X11Display, m_X11Window, True, GrabModeAsync, GrabModeAsync, CurrentTime);
        XGrabPointer(m_X11Display, m_X11Window, True, ButtonPressMask, GrabModeAsync, GrabModeAsync, m_X11Window, None, CurrentTime);
        XIfEvent( m_X11Display, &event, WaitForMapNotify, (char*)m_X11Window );

    }
    else
#endif
    {
        // For OGLES we assume that chaning of video mode is not available (freedesktop does not allow to do it)
        // so if requested resolution differs from the display dims then we quit
        #ifndef BUILD_OGL
        int display_width  = XDisplayWidth(m_X11Display,m_X11Screen);
        int display_height = XDisplayHeight(m_X11Display,m_X11Screen);
        if((shell.m_pShellData->bFullScreen)&&((shell.m_pShellData->nShellDimX != display_width)||(shell.m_pShellData->nShellDimY != display_height)) ) {
            shell.PVRShellOutputDebug( "Chosen resolution for full screen mode does not match available modeline.\n" );
            return false;
        }
        #endif


		WinAttibutes.colormap = m_X11ColorMap;
		WinAttibutes.background_pixel = 0xFFFFFFFF;
		WinAttibutes.border_pixel = 0;

		// add to these for handling other events
		WinAttibutes.event_mask = StructureNotifyMask | ExposureMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask | KeyPressMask | KeyReleaseMask;

		// The attribute mask
        mask = CWBackPixel | CWBorderPixel | CWEventMask | CWColormap ;

        m_X11Window = XCreateWindow(  m_X11Display, 						// Display
									RootWindow(m_X11Display, m_X11Screen), 	// Parent
									shell.m_pShellData->nShellPosX, 	// X position of window
									shell.m_pShellData->nShellPosY,		// Y position of window
									shell.m_pShellData->nShellDimX,		// Window width
									shell.m_pShellData->nShellDimY,		// Window height
									0,									// Border width
									CopyFromParent, 					// Depth (taken from parent)
									InputOutput, 						// Window class
									CopyFromParent, 					// Visual type (taken from parent)
									mask, 								// Attributes mask
									&WinAttibutes);						// Attributes

		// Set the window position
        sh.flags = USPosition;
        sh.x = shell.m_pShellData->nShellPosX;
        sh.y = shell.m_pShellData->nShellPosY;
        XSetStandardProperties( m_X11Display, m_X11Window, shell.m_pShellData->pszAppName, shell.m_pShellData->pszAppName, None, 0, 0, &sh );

        // Map and then wait till mapped
        XMapWindow( m_X11Display, m_X11Window );
        XIfEvent( m_X11Display, &event, WaitForMapNotify, (char*)m_X11Window );

        // An attempt to hide a border for fullscreen on non OGL apis (OGLES,OGLES2)
        if(shell.m_pShellData->bFullScreen)
        {
			XEvent xev;
			Atom wmState = XInternAtom(m_X11Display, "_NET_WM_STATE", False);
			Atom wmStateFullscreen = XInternAtom(m_X11Display, "_NET_WM_STATE_FULLSCREEN", False);

			memset(&xev, 0, sizeof(XEvent));
			xev.type = ClientMessage;
			xev.xclient.window = m_X11Window;
			xev.xclient.message_type = wmState;
			xev.xclient.format = 32;
			xev.xclient.data.l[0] = 1;
			xev.xclient.data.l[1] = wmStateFullscreen;
			xev.xclient.data.l[2] = 0;
			XSendEvent(m_X11Display, RootWindow(m_X11Display, m_X11Screen), False, SubstructureNotifyMask, &xev);
        }

        Atom wmDelete = XInternAtom(m_X11Display, "WM_DELETE_WINDOW", True);
        XSetWMProtocols(m_X11Display, m_X11Window, &wmDelete, 1);
        XSetWMColormapWindows( m_X11Display, m_X11Window, &m_X11Window, 1 );
    }

    XFlush( m_X11Display );

    return true;
}
示例#10
0
// needs to be run after SelectEGLConfiguration()
// for gEglConfig to be valid
int PVRShellInitOS::OpenX11Window(const PVRShell &shell)
{
    XSetWindowAttributes	wa;
    XSizeHints				sh;
    XEvent					event;
    unsigned long			mask;
    #ifdef BUILD_OGL
    XF86VidModeModeInfo **modes;       // modes of display
    int numModes;                      // number of modes of display
    int chosenMode;
    int edimx,edimy;                   //established width and height of the chosen modeline
    int i;
    #endif
    MyHints mwmhints;
    Atom prop;

	int depth = DefaultDepth(x11display, x11screen);
	x11visual = new XVisualInfo;
	XMatchVisualInfo( x11display, x11screen, depth, TrueColor, x11visual);

    if( !x11visual )
    {
    	shell.PVRShellOutputDebug( "Unable to acquire visual" );
    	return false;
    }

    x11colormap = XCreateColormap( x11display, RootWindow(x11display, x11screen), x11visual->visual, AllocNone );

    #ifdef BUILD_OGL
    originalMode_dotclock = XF86VidModeBadClock;
    if(shell.m_pShellData->bFullScreen) {

        // Get mode lines to see if there is requested modeline
        XF86VidModeGetAllModeLines(x11display, x11screen, &numModes, &modes);
        /* look for mode with requested resolution */
        chosenMode = -1;
        i=0;
        while((chosenMode == -1)&&(i<numModes))
        {
            if ((modes[i]->hdisplay == shell.m_pShellData->nShellDimX) && (modes[i]->vdisplay == shell.m_pShellData->nShellDimY))
            {
                chosenMode = i;
            }
            ++i;
        }

        // If there is no requested resolution among modelines then terminate
        if(chosenMode == -1)
        {
            shell.PVRShellOutputDebug( "Chosen resolution for full screen mode does not match any modeline available.\n" );
            return false;
        }

        /* save desktop-resolution before switching modes */
        XF86VidModeGetModeLine(x11display,x11screen, &originalMode_dotclock, &originalMode );

        XF86VidModeSwitchToMode(x11display, x11screen, modes[chosenMode]);
        XF86VidModeSetViewPort(x11display, x11screen, 0, 0);
        edimx = modes[chosenMode]->hdisplay;
        edimy = modes[chosenMode]->vdisplay;
        printf("Fullscreen Resolution %dx%d (chosen mode = %d)\n", edimx, edimy,chosenMode);
        XFree(modes);       //to musi byc globalne

        wa.colormap = x11colormap;
        wa.background_pixel = 0xFFFFFFFF;
        wa.border_pixel = 0;
        wa.override_redirect = true;

        // add to these for handling other events
        wa.event_mask = StructureNotifyMask | ExposureMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask;

        // The diffrence is that we want to ignore influence of window manager for outr fullscreen window
        mask = CWBackPixel | CWBorderPixel | CWEventMask | CWColormap | CWOverrideRedirect;

        x11window = XCreateWindow( x11display, RootWindow(x11display, x11screen), 0, 0, edimx, edimy, 0,
                                    CopyFromParent, InputOutput, CopyFromParent, mask, &wa);
        // keeping the pointer of mouse and keyboard in window to prevent from scrolling the virtual screen
        XWarpPointer(x11display, None ,x11window, 0, 0, 0, 0, 0, 0);
        // Map and then wait till mapped, grabbing should be after mapping the window
        XMapWindow( x11display, x11window );
        XGrabKeyboard(x11display, x11window, True, GrabModeAsync, GrabModeAsync, CurrentTime);
        XGrabPointer(x11display, x11window, True, ButtonPressMask, GrabModeAsync, GrabModeAsync, x11window, None, CurrentTime);
        XIfEvent( x11display, &event, WaitForMapNotify, (char*)x11window );

    } else {
    #endif
        wa.colormap = x11colormap;
        wa.background_pixel = 0xFFFFFFFF;
        wa.border_pixel = 0;

        // add to these for handling other events
        wa.event_mask = StructureNotifyMask | ExposureMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask;

        mask = CWBackPixel | CWBorderPixel | CWEventMask | CWColormap ;

        x11window = XCreateWindow( x11display, RootWindow(x11display, x11screen), shell.m_pShellData->nShellPosX, shell.m_pShellData->nShellPosY,
                                    shell.m_pShellData->nShellDimX, shell.m_pShellData->nShellDimY, 0,
                                    CopyFromParent, InputOutput, CopyFromParent, mask, &wa);
        // todo:meh remove this?
        sh.flags = USPosition;
        sh.x = shell.m_pShellData->nShellPosX;
        sh.y = shell.m_pShellData->nShellPosY;
        XSetStandardProperties( x11display, x11window, szTitle, szTitle, None, 0, 0, &sh );
        // Map and then wait till mapped
        XMapWindow( x11display, x11window );
        XIfEvent( x11display, &event, WaitForMapNotify, (char*)x11window );
        // An attempt to hide a border for fullscreen on non OGL apis (OGLES,OGLES2)
        if(shell.m_pShellData->bFullScreen) {
            memset(&mwmhints, 0, sizeof(mwmhints));
            prop = XInternAtom(x11display, "_MOTIF_WM_HINTS", False);
            mwmhints.flags = 2;//MWM_HINTS_DECORATIONS;
            mwmhints.decorations = 0;
            XChangeProperty(x11display, x11window, prop, prop, 32, PropModeReplace,
            (unsigned char *) &mwmhints,5);
        }
        //
        Atom wmDelete = XInternAtom(x11display, "WM_DELETE_WINDOW", True);
        XSetWMProtocols(x11display, x11window, &wmDelete, 1);
        XSetWMColormapWindows( x11display, x11window, &x11window, 1 );
    #ifdef BUILD_OGL
    }
    #endif

    XFlush( x11display );

    return true;
}
示例#11
0
文件: OGLwin.c 项目: alown/chromium
void OGLwin_Open_Window(int x, int y, int width, int height, char *name,
			WINTYPE t, Window parent_win)
{
    XSetWindowAttributes swa;
    XEvent event;
    unsigned long attr_mask;
    Window parent;
    Window root_win;

    if (!Dsp) {
	if (global_display != NULL) {
	    Dsp = global_display;
	} else {
	    Dsp = XOpenDisplay(0);
	}
    }

    if (getenv("OGLWIN_USE12")) {
	attributes[RGBA_SINGLE] = rgba12_att;
	attributes[RGBA_DOUBLE] = rgba12_datt;
    }

    Vi = glXChooseVisual(Dsp, DefaultScreen(Dsp), attributes[t]);
    Cmap = getColormap(Dsp, Vi, t);

    swa.border_pixel = 0;
    swa.colormap = Cmap;
    swa.event_mask =
	ExposureMask | StructureNotifyMask | VisibilityChangeMask |
	PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
	KeyPressMask | KeyReleaseMask;
    swa.override_redirect = OGLwin_override_redirect;
    attr_mask =
	CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect;

    parent = parent_win;
    root_win = RootWindow(Dsp, Vi->screen);

    if (!parent)
	parent = root_win;

    if (parent_border) {
	parent = XCreateSimpleWindow(Dsp, parent, x, y, width, height,
				     0, 0, 0);
	XSelectInput(Dsp, parent, StructureNotifyMask);
	x = y = parent_border;
	width -= parent_border;
	height -= parent_border;
    }

    XWindow = XCreateWindow(Dsp, parent, x, y,
			    width, height,
			    0, Vi->depth, InputOutput, Vi->visual,
			    attr_mask, &swa);

    if (parent_win == root_win) {
	Window top_win = (parent_border ? parent : XWindow);

	/*
	 * fix size/position/aspect of new swWindow  
	 */
	{
	    XSizeHints *size_hints;

	    size_hints = XAllocSizeHints();
	    size_hints->flags = USSize | PSize | USPosition | PPosition;
	    XSetWMNormalHints(Dsp, top_win, size_hints);
	    XFree(size_hints);
	}

	XSetWMColormapWindows(Dsp, XWindow, &XWindow, 1);
	XStoreName(Dsp, top_win, name);
	XMapSubwindows(Dsp, top_win);
	XMapWindow(Dsp, top_win);
	XIfEvent(Dsp, &event, WaitForMapNotify, (char *) top_win);
    } else {
	XMapWindow(Dsp, XWindow);
	XIfEvent(Dsp, &event, WaitForMapNotify, (char *) XWindow);
    }

    Cxt = glXCreateContext(Dsp, Vi, 0, direct_context);

    //SetWin();

    fontBase = -1;
}