kenm@dmssyd.syd.dms.CSIRO.AU (Ken McNamara) (02/22/91)
I've written a small programme in attempt to create a widget with a window which is not of the default visual type. The code was written, compiled and run on a Sun 4/110 under SunOS 4.1. It doesn't bomb when the display is a Sun 4 running the MIT sample X server or a DECSTATION5000/200 with an 8 bit display running the DECWINDOWS DigitalEquipmentCorporation UWS2.2 server but it does bomb on a DECSTATION5000/200 running the UWS2.2 X-server with the following message X Error of failed request: BadMatch (invalid parameter attributes) Major opcode of failed request: 1 (X_CreateWindow) Minor opcode of failed request: 0 Resource id in failed request: 0x80071 Serial number of failed request: 270 Current serial number in output stream: 279 I was just wondering if anyone has experienced this problem ? The programme is : ------------------------------------------------------------------------------- #include <stdio.h> #include <X11/Xlib.h> #include <X11/Intrinsic.h> #include <X11/Xaw/Label.h> #include <X11/StringDefs.h> #include <X11/Shell.h> #include <X11/Xatom.h> #include <X11/Xmu/StdCmap.h> static char *vis_class[6]; /* A table of Visual class names */ /* Routine to display a XVisulaInfo structure */ static void show_visual(vis) XVisualInfo vis ; { int class; printf ("depth = %d\n",vis.depth); class = vis.class; if (class >= 6) exit(1); printf("Visual Id = %#x \n",vis.visualid); printf ("class = %s\n",vis_class[class]); printf ("R mask = %#x \n",vis.red_mask); printf ("G mask = %#x \n",vis.green_mask); printf ("B mask = %#x \n",vis.blue_mask); printf ("colormap size = %d\n",vis.colormap_size); printf ("bits per rgb = %d\n",vis.bits_per_rgb); printf ("\n"); } main(argc,argv) int argc; char ** argv; { Widget shell; Widget box; Colormap Col1 ; XtAppContext app_context; Display * displ ; XVisualInfo Vis; Window w; Screen * scr; XColor col; int i,count; /* Initialise table of Visual class names */ vis_class[GrayScale] = "GrayScale"; vis_class[StaticGray] = "StaticGray"; vis_class[PseudoColor] = "PseudoColor"; vis_class[StaticColor] = "StaticColor"; vis_class[DirectColor] = "DirectColor"; vis_class[TrueColor] = "TrueColor" ; /* Do Xt stuff */ XtToolkitInitialize(); app_context = XtCreateApplicationContext(); /* Get display connection */ displ = XtOpenDisplay(app_context,"","Freddy","TESTS", NULL,0,&argc,argv); scr = DefaultScreenOfDisplay(displ); w = RootWindow(displ,DefaultScreen(displ)); i =XMatchVisualInfo(displ,DefaultScreen(displ),8,GrayScale,&Vis); printf("%d \n",i); if ( !i ) exit (0); /* Failed - exit without further comment */ show_visual(Vis); /* Display the XVisualInfo returned */ Col1 = XCreateColormap(displ,w,Vis.visual, AllocAll); /* Create the colormap */ printf("%#x \n",Col1); /* This is just a bit of nonsense to check that the coloramp is installed - when we enter the window the screen changes color */ for ( count=0; count<Vis.colormap_size; count++) { col.green = 65000 ; col.red =65000 ; col.blue = 65000; col.pixel = count; col.flags = DoGreen | DoBlue | DoRed; XStoreColor(displ,Col1,&col); }; /* Create a shell using the recently created colormap and the Visual */ shell = XtVaAppCreateShell("Freddy","TESTS",topLevelShellWidgetClass, displ, XtNvisual,(XtArgVal)Vis.visual, XtNwidth,(XtArgVal)100, XtNheight,(XtArgVal)100, XtNcolormap,(XtArgVal)Col1, NULL); /* Create a label widget */ box = XtVaCreateManagedWidget("MyLabel",labelWidgetClass,shell, XtNlabel,(XtArgVal)"Hello", NULL); XtRealizeWidget(shell); /* Create the windows */ XtAppMainLoop(app_context); /* The Main Events */ } ------------------------------------------------------------------------ --------- The complete output is: 1 depth = 8 Visual Id = 0x80065 class = GrayScale R mask = 0 G mask = 0 B mask = 0 colormap size = 256 bits per rgb = 8 0x900001 X Error of failed request: BadMatch (invalid parameter attributes) Major opcode of failed request: 1 (X_CreateWindow) Minor opcode of failed request: 0 Resource id in failed request: 0x80071 Serial number of failed request: 270 Current serial number in output stream: 279 -------------------------------- Ken McNamara Phone: +61-2-4137063 (GMT+10) Fax: +61-2-4169317 Internet: kenm@syd.dms.csiro.au CSIRO Division of Mathematics & Statistics PO Box 218, Lindfield, NSW 2070, Australia.