static Select_Info *initialize_Graph_Select_Reg(void){
    Panel panel;
    Frame	gsr_frame =  NULL;
    Canvas gsr_cvs =  NULL;
    Window gsr_win;
    Xv_Window window;
    Select_Info *ret_val = (Select_Info*)Malloc(sizeof(Select_Info));

    gsr_frame = xv_create(tracesFrame, FRAME,
			XV_HEIGHT, gsrwin_h+40, XV_WIDTH, gsrwin_w,
			NULL);		  
    gsr_cvs =  xv_create(gsr_frame, CANVAS,
		       XV_X, 0, XV_Y, 40,		  
		       CANVAS_REPAINT_PROC, redraw_gsrwin,
		       CANVAS_RESIZE_PROC, resize_gsrwin,
		       NULL);		  
    gsr_win =  xv_get(canvas_paint_window(gsr_cvs), XV_XID);

    handle_colours(gsr_win);

    window = (Xv_Window)xv_get(gsr_cvs,CANVAS_NTH_PAINT_WINDOW,0);
    xv_set(window,WIN_EVENT_PROC,gsr_event_handle,
	   WIN_CONSUME_EVENTS,WIN_MOUSE_BUTTONS,NULL,
	   NULL);
    panel =  (Panel)xv_create(gsr_frame, PANEL,
			    XV_X, 0, XV_Y, 0, XV_HEIGHT, 40,
			    NULL);
    (void)xv_create(panel, PANEL_BUTTON,
		    PANEL_LABEL_STRING, "Quit",
		    PANEL_NOTIFY_PROC, close_gsr_win,
		    PANEL_CLIENT_DATA,gsr_frame,
		    NULL);
    (void)xv_create(panel, PANEL_BUTTON,
		    PANEL_LABEL_STRING, "Select All",
		    PANEL_NOTIFY_PROC, gsr_select_all,
		    XV_KEY_DATA, PANEL_SEL_REG,ret_val,
		    NULL);
    (void)xv_create(panel, PANEL_BUTTON,
		    PANEL_LABEL_STRING, "Deselect All",
		    PANEL_NOTIFY_PROC, gsr_deselect_all,
		    XV_KEY_DATA, PANEL_SEL_REG,ret_val,
		    NULL);
    (void)xv_create(panel, PANEL_BUTTON,
		    PANEL_LABEL_STRING, "Default Selection",
		    PANEL_NOTIFY_PROC, gsr_default,
		    XV_KEY_DATA, PANEL_SEL_REG,ret_val,
		    NULL);

    init_selection_values(ret_val);
    ret_val->can = gsr_cvs;
    ret_val->board = gsr_frame;
    ret_val->wind = gsr_win;
    createGC(gsr_win, &ret_val->txtgc);
    fil_sel_reg(ret_val);
    return ret_val;
}
static void InitFpltFrame()
{
    Panel panel;
    Menu menu;
    
    fplt_frame= xv_create(tracesFrame, FRAME,
			  XV_HEIGHT, fpltwin_h+40, XV_WIDTH, fpltwin_w,
			  NULL);		  
    fplt_cvs= xv_create(fplt_frame, CANVAS,
			XV_X, 0, XV_Y, 40,		  
			CANVAS_REPAINT_PROC, redrawFplt,		  
			NULL);		  
    fplt_win= xv_get(canvas_paint_window(fplt_cvs), XV_XID);
    createGC( fplt_win, &fplt_gc);
    panel= (Panel)xv_create(fplt_frame, PANEL,
			    XV_X, 0, XV_Y, 0, XV_HEIGHT, 40,
			    NULL);
    (void)xv_create(panel, PANEL_BUTTON,
		    PANEL_LABEL_STRING, "Quit",
		    PANEL_NOTIFY_PROC, close_fplt_win,
		    NULL);
    menu= (Menu)xv_create(NULL,MENU,
			  MENU_STRINGS,
			  "taper etc.", "no taper", "shades", "no shades",
			  NULL,
			  MENU_NOTIFY_PROC,   options_menu_proc,
			  NULL);
    (void)xv_create(panel, PANEL_BUTTON,
		    PANEL_LABEL_STRING, "Options",
		    PANEL_ITEM_MENU, menu,
		    NULL);
    len_txt= (Panel_item)xv_create(panel, PANEL_TEXT,
				   PANEL_LABEL_STRING, "Length",
				   PANEL_VALUE_DISPLAY_WIDTH, 60,			  
				   NULL);
    step_txt= (Panel_item)xv_create(panel, PANEL_TEXT,
				    PANEL_LABEL_STRING, "Step",
				    PANEL_VALUE_DISPLAY_WIDTH, 60,			  
				    NULL);
    scale_txt= (Panel_item)xv_create(panel, PANEL_TEXT,
				     PANEL_LABEL_STRING, "Scale",
				     PANEL_VALUE_DISPLAY_WIDTH, 60,			  
				     NULL);
    itrc_txt= (Panel_item)xv_create(panel, PANEL_NUMERIC_TEXT,
				    PANEL_LABEL_STRING, "Trc No.",
				    PANEL_VALUE_DISPLAY_WIDTH, 60,			  
				    NULL);
    (void)xv_create(panel, PANEL_BUTTON,
		    PANEL_LABEL_STRING, "Go",
		    PANEL_NOTIFY_PROC, go_fplt,
		    NULL);
    InitStipples();
}
static void InitPmotionFrame()
{
    Panel panel;
    Menu menu;
    
    pm_frame= xv_create(tracesFrame, FRAME,
			XV_HEIGHT, pmwin_h+40, XV_WIDTH, pmwin_w,
			NULL);		  
    pm_cvs= xv_create(pm_frame, CANVAS,
		      XV_X, 0, XV_Y, 40,		  
		      CANVAS_REPAINT_PROC, redrawPmotion,
		      NULL);		  
    pm_win= xv_get(canvas_paint_window(pm_cvs), XV_XID);
    createGC(pm_win, &pm_gc);
    panel= (Panel)xv_create(pm_frame, PANEL,
			    XV_X, 0, XV_Y, 0, XV_HEIGHT, 40,
			    NULL);
    (void)xv_create(panel, PANEL_BUTTON,
		    PANEL_LABEL_STRING, "Quit",
		    PANEL_NOTIFY_PROC, close_pmotion_win,
		    NULL);
    (void)xv_create(panel, PANEL_BUTTON,
		    PANEL_LABEL_STRING, "redo",
		    PANEL_NOTIFY_PROC, handle_particle_motion,
		    NULL);
    (void)xv_create(panel, PANEL_BUTTON,
		    PANEL_LABEL_STRING, "next selection",
		    PANEL_NOTIFY_PROC, next_motion,
		    NULL);
    (void)xv_create(panel, PANEL_BUTTON,
		    PANEL_LABEL_STRING, "Z-X",
		    PANEL_NOTIFY_PROC, changeZX,
		    NULL);
    (void)xv_create(panel, PANEL_BUTTON,
		    PANEL_LABEL_STRING, "Z-Y",
		    PANEL_NOTIFY_PROC, changeZY,
		    NULL);
    (void)xv_create(panel, PANEL_BUTTON,
		    PANEL_LABEL_STRING, "X-Y",
		    PANEL_NOTIFY_PROC, changeXY,
		    NULL);
}
示例#4
0
int initZTScale(Frame frame)
{
    ztscl_top_canvas= (Canvas)xv_create(frame, CANVAS,
					XV_X, 0, XV_Y, 0,
					XV_WIDTH, ZCvsWidth+ZTrkLabWidth+4, XV_HEIGHT, ZTSHEIGHT+1,
					XV_KEY_DATA, WHICH_TS, TOP_TS,
					CANVAS_REPAINT_PROC, RedrawZTScale,
					NULL);
    ztscl_bot_canvas= (Canvas)xv_create(frame, CANVAS,
					XV_X, 0, XV_Y, ZCvsHeight+ZTSHEIGHT-1,
					XV_WIDTH, ZCvsWidth+ZTrkLabWidth+4, XV_HEIGHT, ZTSHEIGHT+1,
					XV_KEY_DATA, WHICH_TS, BOTTOM_TS,
					CANVAS_REPAINT_PROC, RedrawZTScale,
					NULL);
    ztscl_top_win= (Window)xv_get(canvas_paint_window(ztscl_top_canvas),
				  XV_XID);
    ztscl_bot_win= (Window)xv_get(canvas_paint_window(ztscl_bot_canvas),
				  XV_XID);
    createGC(ztscl_top_win, &ztscl_gc);
    if(!Mode_ZDisplayTScale || !Mode_align) {
	xv_set(ztscl_top_canvas, XV_SHOW, FALSE, NULL);
	xv_set(ztscl_bot_canvas, XV_SHOW, FALSE, NULL);
    }
}
示例#5
0
int
main() {
    Display *d;
    Window w;
    GC planetGc[NO_OF_PLANETS], rectGc, textGc, sunGc, invGc;
    XColor sunColor, rectColor, planetColor[NO_OF_PLANETS];
    XEvent e;
    KeySym key;
    int rectX = (windowWidth - rectWidth) / 2, rectY = (windowHeight - rectHeight) / 2;
    Point pt[NO_OF_PLANETS], centre = rectX + (rectWidth / 2) + I * (rectY + (rectHeight / 2));
    int prevAngle[NO_OF_PLANETS];
    int s, sunX = creal(centre) - p[0].orbitSemiMajor * p[0].orbitEccentricity - 10, sunY = cimag(centre), i;

    d = XOpenDisplay(NULL);
    s = DefaultScreen(d);
    w = XCreateSimpleWindow(d, RootWindow(d, s), 0, 0, windowWidth, windowHeight, 0, 0, WhitePixel(d, s));

    setPlanetAttributes(p);

    XStoreName(d, w, "Planetary Motion Simulator Window");
    XSelectInput(d, w, ExposureMask | KeyPressMask);
    XMapWindow(d, w);
    XMoveWindow(d, w, (DisplayWidth(d, s) - windowWidth) / 2, (DisplayHeight(d, s) - windowHeight) / 2);

    textGc = XCreateGC(d, w, 0, 0);

    createGC(d, &w, s, 2, &rectGc, rect, &rectColor);
    createGC(d, &w, s, 1, &sunGc, sun, &sunColor);
    for (i = 0; i < NO_OF_PLANETS; i++)
        createGC(d, &w, s, 1, &planetGc[i], planetColour[i], &planetColor[i]);

    invGc = XCreateGC(d, w, 0, 0);
    XSetForeground(d, invGc, WhitePixel(d, s));
    XSetFillStyle(d, invGc, FillSolid);

    for (i = 0; i < NO_OF_PLANETS; i++)
        prevAngle[i] = 90 * i;

    while (true) {
        XNextEvent(d, &e);
        switch (e.type) {
            case Expose:
                drawText(d, s, &w, &textGc, message);
                XDrawRectangle(d, w, rectGc, rectX, rectY, rectWidth, rectHeight);
                XFillArc(d, w, sunGc, sunX - sunRadius, sunY - sunRadius, sunRadius * 2, sunRadius * 2, 0, 360 * 64);
                for (i = 0; i < NO_OF_PLANETS; i++) {
                    pt[i] = pointOnEllipse(p[i].orbitSemiMajor, p[i].orbitSemiMinor, prevAngle[i], centre);
                    XDrawArc(d, w, planetGc[i], creal(centre) - p[i].orbitSemiMajor, cimag(centre) - p[i].orbitSemiMinor,
                            p[i].orbitSemiMajor * 2, p[i].orbitSemiMinor * 2, 0, 360 * 64);
                    XFillArc(d, w, planetGc[i], creal(pt[i]) - p[i].radius, cimag(pt[i]) - p[i].radius,
                            p[i].radius * 2, p[i].radius * 2, 0, 360 * 64);
                }
                break;
            case KeyPress:
                key = XLookupKeysym(&e.xkey, 0);
                if (key == XK_Return) {
                    drawText(d, s, &w, &textGc, message);
                    for (i = 0; i < NO_OF_PLANETS; i++)
                        XFillArc(d, w, invGc, creal(pt[i]) - p[i].radius, cimag(pt[i]) - p[i].radius,
                            p[i].radius * 2, p[i].radius * 2, 0, 360 * 64);
                    XDrawRectangle(d, w, rectGc, rectX, rectY, rectWidth, rectHeight);
                    XFillArc(d, w, sunGc, sunX - sunRadius, sunY - sunRadius, sunRadius * 2, sunRadius * 2, 0, 360 * 64);
                    for (i = 0; i < NO_OF_PLANETS; i++) {
                        pt[i] = pointOnEllipse(p[i].orbitSemiMajor, p[i].orbitSemiMinor, prevAngle[i], centre);
                        XDrawArc(d, w, planetGc[i], creal(centre) - p[i].orbitSemiMajor, cimag(centre) - p[i].orbitSemiMinor,
                                p[i].orbitSemiMajor * 2, p[i].orbitSemiMinor * 2, 0, 360 * 64);
                        XFillArc(d, w, planetGc[i], creal(pt[i]) - p[i].radius, cimag(pt[i]) - p[i].radius,
                                p[i].radius * 2, p[i].radius * 2, 0, 360 * 64);
                        prevAngle[i] += p[i].angVelocity * (i == 1 || i == 6 ? -1 : 1); // venus & uranus rotate clockwise
                        prevAngle[i] %= 360;
                    }
                } else exit(0);
        }
    }
    XDestroyWindow(d, w);
    XCloseDisplay(d);
    return (EXIT_SUCCESS);
}
示例#6
0
int openwindow(int swidth,int sheight)

{
    
    static int firsttime = 1;
    
    void initX(),beep();
    
    int createGC(Window,GC*);
    
    XSetWindowAttributes    theWindowAttributes;
    XSizeHints              theSizeHints;
    unsigned        long    theWindowMask;
    
    if(firsttime) {
	firsttime = 0;
	initX();
    }
    ww = swidth;
    wh = sheight;
    
    if(swidth <= 0) swidth = 10;
    if(sheight <= 0) sheight = 10;
    
    theWindowMask = CWBackPixel | CWBorderPixel | CWOverrideRedirect;
    
    theWindowAttributes.border_pixel = theBlackPixel
    = BlackPixel( theDisplay,theScreen );
    theWindowAttributes.background_pixel = theWhitePixel
    = WhitePixel( theDisplay,theScreen );
    theWindowAttributes.override_redirect = False;
    
    
    theWindow = XCreateWindow(theDisplay,
			      RootWindow(theDisplay,theScreen),
			      orgx,orgy,
			      swidth,sheight,
			      BORDER_WIDTH,
			      theDepth,
			      InputOutput,
			      CopyFromParent,
			      theWindowMask,
			      &theWindowAttributes);
    
    theSizeHints.flags      =       PPosition | PSize;
    theSizeHints.x          =       orgx;
    theSizeHints.y          =       orgy;
    theSizeHints.width      =       swidth;
    theSizeHints.height     =       sheight;
    
    XSetNormalHints( theDisplay, theWindow, &theSizeHints );
    
    if (createGC(theWindow, &theGC) == 0 ) {
	XDestroyWindow(theDisplay, theWindow);
	beep();
	return(0);
    }
    
    XMapWindow( theDisplay, theWindow );
    
    XFlush( theDisplay );
    getcolors();
    return( 1 );
}
示例#7
0
static void CreateTrk(Frame frame, int i, int height, int width, int y)
{
    Canvas canvas, txtcanvas;
    Track *trk;
    extern Display *theDisp;
    int theScrn;

    trk= tracks[i]= (Track *)Malloc(sizeof(Track));
    if (trk==NULL) return;  /* not enuff mem */
    if (Mode_noBorder) {
	txtcanvas= (Canvas)xv_create(frame, CANVAS,
				     XV_X, 0, XV_Y, y,
				     XV_WIDTH, TXTCANV_WIDTH-2,
				     XV_HEIGHT, height,
				     /*	     CANVAS_AUTO_EXPAND, FALSE,	    -- allow for resize
					     CANVAS_AUTO_SHRINK, FALSE, */
				     OPENWIN_SHOW_BORDERS, FALSE,
				     CANVAS_X_PAINT_WINDOW, TRUE,
				     CANVAS_RETAINED, FALSE,
				     CANVAS_REPAINT_PROC, repaintTrackLabs,
				     XV_KEY_DATA, TRACK_INDEX, i,  /* for identification */
				     NULL);
	canvas= (Canvas)xv_create(frame, CANVAS,
				  XV_X, TXTCANV_WIDTH, XV_Y, y,
				  XV_WIDTH, FrmWidth-TXTCANV_WIDTH-19,
				  XV_HEIGHT, height,
				  CANVAS_X_PAINT_WINDOW, TRUE,
				  OPENWIN_SHOW_BORDERS, FALSE,
				  /*	     CANVAS_AUTO_EXPAND, FALSE,
					     CANVAS_AUTO_SHRINK, FALSE,*/
				  CANVAS_RETAINED, FALSE,
				  CANVAS_REPAINT_PROC, repaintTracks,
				  XV_KEY_DATA, TRACK_INDEX, i,  /* for identification */
				  NULL);
    }else {
	/* well, guess what? OPENWIN_SHOW_BORDERS can only be used in
	   xv_create! */
	txtcanvas= (Canvas)xv_create(frame, CANVAS,
				     XV_X, 0, XV_Y, y,
				     XV_WIDTH, TXTCANV_WIDTH,
				     XV_HEIGHT, height,
				     /*	     CANVAS_AUTO_EXPAND, FALSE,	    -- allow for resize
					     CANVAS_AUTO_SHRINK, FALSE, */
				     CANVAS_X_PAINT_WINDOW, TRUE,
				     CANVAS_RETAINED, FALSE,
				     CANVAS_REPAINT_PROC, repaintTrackLabs,
				     XV_KEY_DATA, TRACK_INDEX, i,  /* for identification */
				     NULL);
	canvas= (Canvas)xv_create(frame, CANVAS,
				  XV_X, TXTCANV_WIDTH, XV_Y, y,
				  XV_WIDTH, FrmWidth-TXTCANV_WIDTH-19,
				  XV_HEIGHT, height,
				  CANVAS_X_PAINT_WINDOW, TRUE,
				  /*	     CANVAS_AUTO_EXPAND, FALSE,
					     CANVAS_AUTO_SHRINK, FALSE,*/
				  CANVAS_RETAINED, FALSE,
				  CANVAS_REPAINT_PROC, repaintTracks,
				  XV_KEY_DATA, TRACK_INDEX, i,  /* for identification */
				  NULL);

    }
    trk->height= height;
    trk->width= width-TXTCANV_WIDTH-19;
    trk->canvas= canvas;
    trk->TxtCanvas= txtcanvas;
    trk->xwin=(Window)xv_get(canvas_paint_window(canvas),XV_XID);
    trk->txtwin=(Window)xv_get(canvas_paint_window(txtcanvas),XV_XID);

    /* standard GC */
    createGC( trk->xwin, &trk->gc);
    /* xor GC */
    createGC( trk->xwin, &trk->ovrGC);
    XSetFunction(theDisp, trk->ovrGC, GXxor);
    theScrn = DefaultScreen(theDisp);
    XSetForeground(theDisp, trk->ovrGC,
		   WhitePixel(theDisp, theScrn)^BlackPixel(theDisp, theScrn));
    /* text font for track labels */
    createGC(trk->txtwin, &trk->txtgc);
    /*    XSetFunction(theDisp, trk->txtgc, GXxor); */

    xv_set(canvas_paint_window(canvas),
	   WIN_EVENT_PROC, Cvs_event_proc,
	   WIN_CONSUME_EVENTS, KBD_DONE, KBD_USE, LOC_WINENTER,
	   LOC_WINEXIT, WIN_ASCII_EVENTS, WIN_MOUSE_BUTTONS, LOC_DRAG,
	   NULL,
	   NULL);
    xv_set(canvas_paint_window(txtcanvas),
	   WIN_EVENT_PROC, TxtCvs_event_proc,
	   WIN_CONSUME_EVENTS, WIN_MOUSE_BUTTONS,
	   NULL,
	   NULL);
}
static void InitXSpctrmFrame()
{
    Panel panel;
    Menu menu;
    char dash_list[2];
    
    xspctrm_frame= xv_create(tracesFrame, FRAME,
	XV_HEIGHT, xspctrmwin_h+40, XV_WIDTH, xspctrmwin_w,
	NULL);		  
    xspctrm_cvs= xv_create(xspctrm_frame, CANVAS,
	XV_X, 0, XV_Y, 40,
	CANVAS_RETAINED, TRUE,
	CANVAS_REPAINT_PROC, redrawXSpctrm,		  
	CANVAS_RESIZE_PROC, resizeXSpctrm,		  
	NULL);		  
    xspc_win= xv_get(canvas_paint_window(xspctrm_cvs), XV_XID);
    createGC( xspc_win, &xspc_gc);
    createGC( xspc_win, &xspc_dot_gc);
    dash_list[0]= 1;
    dash_list[1]= 5;
    XSetLineAttributes(theDisp, xspc_dot_gc, 1, LineOnOffDash,
		       CapRound, JoinRound);
    createGC( xspc_win, &xspc_smdot_gc);
    XSetLineAttributes(theDisp, xspc_smdot_gc, 1, LineOnOffDash,
		       CapRound, JoinRound);
    XSetDashes(theDisp, xspc_smdot_gc,2,dash_list,2);
    panel= (Panel)xv_create(xspctrm_frame, PANEL,
	XV_X, 0, XV_Y, 0, XV_HEIGHT, 40,
	NULL);
    (void)xv_create(panel, PANEL_BUTTON,
	PANEL_LABEL_STRING, "Quit",
	PANEL_NOTIFY_PROC, close_xspctrm_win,
	NULL);
    (void)xv_create(panel, PANEL_BUTTON,
	PANEL_LABEL_STRING, "Redo",
	PANEL_NOTIFY_PROC, redo_xspctrm,
	NULL);
    (void)xv_create(panel, PANEL_BUTTON,
	PANEL_LABEL_STRING, "Next",
	PANEL_NOTIFY_PROC, next_xspctrm,
	NULL);
    menu= (Menu)xv_create(NULL,MENU,
	MENU_STRINGS,
		"Linear Scale", "Log-Linear Sc", "Log Scale",
		NULL,
	MENU_NOTIFY_PROC,   scale_menu_proc,
	NULL);
    (void)xv_create(panel, PANEL_BUTTON,
	PANEL_LABEL_STRING, "Scale",
	PANEL_ITEM_MENU, menu,
	NULL);
    menu= (Menu)xv_create(NULL,MENU,
	MENU_STRINGS,
		"trace portion", "no trace",
		"taper etc.", "no taper", "grid on", "grid off",
		NULL,
	MENU_NOTIFY_PROC,   options_menu_proc,
	NULL);
    (void)xv_create(panel, PANEL_BUTTON,
	PANEL_LABEL_STRING, "Options",
	PANEL_ITEM_MENU, menu,
	NULL);
    itrc_txt= (Panel_item)xv_create(panel, PANEL_NUMERIC_TEXT,
	PANEL_LABEL_STRING, "Trc No.",
	PANEL_VALUE_DISPLAY_WIDTH, 60,			  
	NULL);
    itrc2_txt= (Panel_item)xv_create(panel, PANEL_NUMERIC_TEXT,
	PANEL_LABEL_STRING, "Trc No.",
	PANEL_VALUE_DISPLAY_WIDTH, 60,			  
	NULL);
}
示例#9
0
QT_BEGIN_NAMESPACE

QXlibWindow::QXlibWindow(QWidget *window)
    : QPlatformWindow(window)
    , mGLContext(0)
    , mScreen(QXlibScreen::testLiteScreenForWidget(window))
{
    int x = window->x();
    int y = window->y();
    int w = window->width();
    int h = window->height();

#if !defined(QT_NO_OPENGL)
    if(window->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL
            && QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)
            || window->platformWindowFormat().alpha()) {
#if !defined(QT_OPENGL_ES_2)
        XVisualInfo *visualInfo = qglx_findVisualInfo(mScreen->display()->nativeDisplay(),mScreen->xScreenNumber(),window->platformWindowFormat());
#else
        QPlatformWindowFormat windowFormat = correctColorBuffers(window->platformWindowFormat());

        EGLDisplay eglDisplay = mScreen->eglDisplay();
        EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,windowFormat);
        VisualID id = QXlibEglIntegration::getCompatibleVisualId(mScreen->display()->nativeDisplay(), eglDisplay, eglConfig);

        XVisualInfo visualInfoTemplate;
        memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
        visualInfoTemplate.visualid = id;

        XVisualInfo *visualInfo;
        int matchingCount = 0;
        visualInfo = XGetVisualInfo(mScreen->display()->nativeDisplay(), VisualIDMask, &visualInfoTemplate, &matchingCount);
#endif //!defined(QT_OPENGL_ES_2)
        if (visualInfo) {
            mDepth = visualInfo->depth;
            mFormat = (mDepth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
            mVisual = visualInfo->visual;
            Colormap cmap = XCreateColormap(mScreen->display()->nativeDisplay(), mScreen->rootWindow(), visualInfo->visual, AllocNone);

            XSetWindowAttributes a;
            a.background_pixel = WhitePixel(mScreen->display()->nativeDisplay(), mScreen->xScreenNumber());
            a.border_pixel = BlackPixel(mScreen->display()->nativeDisplay(), mScreen->xScreenNumber());
            a.colormap = cmap;
            x_window = XCreateWindow(mScreen->display()->nativeDisplay(), mScreen->rootWindow(),x, y, w, h,
                                     0, visualInfo->depth, InputOutput, visualInfo->visual,
                                     CWBackPixel|CWBorderPixel|CWColormap, &a);
        } else {
            qFatal("no window!");
        }
    } else
#endif //!defined(QT_NO_OPENGL)
    {
        mDepth = mScreen->depth();
        mFormat = (mDepth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
        mVisual = mScreen->defaultVisual();

        x_window = XCreateSimpleWindow(mScreen->display()->nativeDisplay(), mScreen->rootWindow(),
                                       x, y, w, h, 0 /*border_width*/,
                                       mScreen->blackPixel(), mScreen->whitePixel());
    }

#ifdef MYX11_DEBUG
    qDebug() << "QTestLiteWindow::QTestLiteWindow creating" << hex << x_window << window;
#endif

    XSetWindowBackgroundPixmap(mScreen->display()->nativeDisplay(), x_window, XNone);

    XSelectInput(mScreen->display()->nativeDisplay(), x_window,
                 ExposureMask | KeyPressMask | KeyReleaseMask |
                 EnterWindowMask | LeaveWindowMask | FocusChangeMask |
                 PointerMotionMask | ButtonPressMask |  ButtonReleaseMask |
                 ButtonMotionMask | PropertyChangeMask |
                 StructureNotifyMask);

    gc = createGC();

    Atom protocols[5];
    int n = 0;
    protocols[n++] = QXlibStatic::atom(QXlibStatic::WM_DELETE_WINDOW);        // support del window protocol
    protocols[n++] = QXlibStatic::atom(QXlibStatic::WM_TAKE_FOCUS);                // support take focus window protocol
//    protocols[n++] = QXlibStatic::atom(QXlibStatic::_NET_WM_PING);                // support _NET_WM_PING protocol
#ifndef QT_NO_XSYNC
    protocols[n++] = QXlibStatic::atom(QXlibStatic::_NET_WM_SYNC_REQUEST);        // support _NET_WM_SYNC_REQUEST protocol
#endif // QT_NO_XSYNC
    if (window->windowFlags() & Qt::WindowContextHelpButtonHint)
        protocols[n++] = QXlibStatic::atom(QXlibStatic::_NET_WM_CONTEXT_HELP);
    XSetWMProtocols(mScreen->display()->nativeDisplay(), x_window, protocols, n);
}