[comp.windows.x] X protocol error?

jxf@sppy00.UUCP (Jonathan Fausey) (12/13/90)

I have encountered an Xlib programming problem that I am unable to resolve.
Namely, the code below compiles on a Sparcstation 1 (R3), a NeXT (R3), a Mac
IIx (A/UX & R4), a DG AViiON (R3), and a Sun 3/50 (R3), runs (as a client on
any of these machines) under the X servers on the NeXT, Mac, and Sun 3/50, but
generates an X protocol error on the others' X servers as well as on a PC X
server.  The X protocol error I get is:

X Protocol error:  BadMatch, invalid parameter attributes
  Major opcode of failed request:  1 (X_CreateWindow)
  Minor opcode of failed request:  1
  Resource id in failed request:  0x8006c
  Serial number of failed request:  82
  Current serial number in output stream:  85

Here's (portions of) the code:

  Display              *wndw_disp;
  int                   wndw_screen;
  Visual               *visual;
  XSetWindowAttributes  WinAttr;
  unsigned long         WinAttrMask = CWBackPixmap;
  Window                win;
  Window                wndw_hndl;
  Pixmap                pix;
  .
  .
  .
  if (!(wndw_disp = XOpenDisplay("")))
  {
     printf("Can't connect to X server %s\n", XDisplayName(""));
     exit(-1);
  }

  wndw_screen = DefaultScreen(wndw_disp);
  wndw_hndl = XCreateSimpleWindow(wndw_disp,
                               DefaultRootWindow(wndw_disp),
                               wndw_hint.x, wndw_hint.y, wndw_hint.width,
                               wndw_hint.height,
                               border_w, wndw_foregrnd, wndw_backgrnd);
  XSetStandardProperties(wndw_disp, *wndw_hndl, test_str, cur_title_str,
                         None, argv, argc, &wndw_hint);
  .
  .
  .
  pix = XCreateBitmapFromData(wndw_disp, wndw_hndl,
                              RawBitmapData, NumBitsPerBitmapLine,
                              NumLinesInBitmap);
  WinAttr.background_pixmap = pix;
  win = XCreateWindow(wndw_disp, DefaultRootWindow(wndw_disp),
                           ulx, uly, width, height, 4, 1, InputOutput,
                           DefaultVisual(wndw_disp,wndw_screen), WinAttrMask,
                           &WinAttr);

I get a similar X protocol error message when I use XCreateSimpleWindow and
XSetBackgroundPixmap instead of XCreateWindow etc.  Can some kind soul help?

etaylor@wilkins.iaims.bcm.tmc.edu (Eric Taylor) (12/15/90)

In article <1050@sppy00.UUCP>, jxf@sppy00.UUCP (Jonathan Fausey) writes:
|> 
|> I have encountered an Xlib programming problem that I am unable to resolve.
|> Namely, the code below compiles on a Sparcstation 1 (R3), a NeXT (R3), a Mac
|> IIx (A/UX & R4), a DG AViiON (R3), and a Sun 3/50 (R3), runs (as a client on
|> any of these machines) under the X servers on the NeXT, Mac, and Sun 3/50, but
|> generates an X protocol error on the others' X servers as well as on a PC X
|> server.  The X protocol error I get is:
|> 
|> X Protocol error:  BadMatch, invalid parameter attributes
|>   Major opcode of failed request:  1 (X_CreateWindow)
|> XSetErrorHandle  Minor opcode of failed request:  1
|>   Resource id in failed request:  0x8006c
|>   Serial number of failed request:  82
|>   Current serial number in output stream:  85
|> 
|> Here's (portions of) the code:
|> 
|>   Display              *wndw_disp;
|>   int                   wndw_screen;
|>   Visual               *visual;
|>   XSetWindowAttributes  WinAttr;
|>   unsigned long         WinAttrMask = CWBackPixmap;
|>   Window                win;
|>   Window                wndw_hndl;
|>   Pixmap                pix;
|>   .
|>   .
|>   .
|>   if (!(wndw_disp = XOpenDisplay("")))
|>   {
|>      printf("Can't connect to X server %s\n", XDisplayName(""));
|>      exit(-1);
|>   }
|> 
|>   wndw_screen = DefaultScreen(wndw_disp);
|>   wndw_hndl = XCreateSimpleWindow(wndw_disp,
|>                                DefaultRootWindow(wndw_disp),
|>                                wndw_hint.x, wndw_hint.y, wndw_hint.width,
|>                                wndw_hint.height,
|>                                border_w, wndw_foregrnd, wndw_backgrnd);
|>   XSetStandardProperties(wndw_disp, *wndw_hndl, test_str, cur_title_str,
|>                          None, argv, argc, &wndw_hint);
|>   .
|>   .
|>   .
|>   pix = XCreateBitmapFromData(wndw_disp, wndw_hndl,
|>                               RawBitmapData, NumBitsPerBitmapLine,
|>                               NumLinesInBitmap);
|>   WinAttr.background_pixmap = pix;
|>   win = XCreateWindow(wndw_disp, DefaultRootWindow(wndw_disp),
|>                            ulx, uly, width, height, 4, 1, InputOutput,
|>                            DefaultVisual(wndw_disp,wndw_screen), WinAttrMask,
|>                            &WinAttr);
|> 
|> I get a similar X protocol error message when I use XCreateSimpleWindow and
|> XSetBackgroundPixmap instead of XCreateWindow etc.  Can some kind soul help?


One glaring error is that you are assuming 1 bit deep display.
You specify depth 1 for your window depth.  Use DefaultDepth(wndw_disp,wndw_screen)
instead.

Another error:  You are using XCreateBitmapFromData.  You should be
using XCreatePixmapFromBitmapData.  As a rule, bitmaps are not
suitable as background pixmaps.  (There are situations where you want
them, but this is not one)
--
					Eric Taylor
					Baylor College of Medicine
					etaylor@wilkins.bcm.tmc.edu
					(713) 798-3776

klee@wsl.dec.com (Ken Lee) (12/15/90)

In article <1050@sppy00.UUCP>, jxf@sppy00.UUCP (Jonathan Fausey) writes:
|>   pix = XCreateBitmapFromData(wndw_disp, wndw_hndl,
|>                               RawBitmapData, NumBitsPerBitmapLine,
|>                               NumLinesInBitmap);
|>   WinAttr.background_pixmap = pix;
|>   win = XCreateWindow(wndw_disp, DefaultRootWindow(wndw_disp),
|>                            ulx, uly, width, height, 4, 1, InputOutput,
|>                            DefaultVisual(wndw_disp,wndw_screen), WinAttrMask,
|>                            &WinAttr);

This is poor programming style.  XCreateBitmapFromData creates a
bitmap, which always has a depth of 1.  You're then using this bitmap
as a window background pixmap without checking the depth in your
visual.  If the window has a depth other than 1, you will get a
protocol error.  You must make sure that window background pixmaps have
the same depths as the windows.

-- 
Ken Lee
DEC Western Software Laboratory, Palo Alto, Calif.
Internet: klee@wsl.dec.com
uucp: uunet!decwrl!klee

jff@denali.ee.uidaho.edu (James F. Frenzel) (05/23/91)

Help!

I am trying to run Mathematica remotely on an IBM RT and have 
the graphics sent to my machine.  I know that my DISPLAY variable
is set properly because xclock and xterm will both appear on my display.
However, when I try to plot inside Mathematica I get an X protocol
error.  Please e-mail your suggestions and I will post a summary.

********************

cheetah [32] math
IBM RT PC AIX Mathematica 1.1 (September 29, 1988) [With pre-loaded data]
by S. Wolfram, D. Grayson, R. Maeder, H. Cejtin,
   S. Omohundro, D. Ballman and J. Keiper
Copyright 1988 Wolfram Research Inc.
-- X11 windows graphics initialized --

In[1]:= Plot[Sin[x], {x, 0, 1}]

Out[1]= -Graphics-

In[2]:= X Protocol error detected by server: integer parameter out of range
  Failed request major op code 1 X_CreateWindow
  Failed request minor op code 0
  ResourceID 0x22a03d in failed request
  Serial number of failed request 3
  Current serial number in output stream 5
  
In[2]:= 


-- 

  Jim Frenzel             Electrical Engineering
  University of Idaho     Moscow, ID 83843
  208-885-7888            jfrenzel@groucho.mrc.uidaho.edu