Title: XGrabButton() BadAccess error

Hi Folks,

I have inherrited some old(ish) code, and am having some trouble getting it working. I am assured this code has worked in the past, but I now get a BadAccess error running the code with XFree86 in RedHat v9 Professional. As I am not an expert in X/Xt, I would appreciate some help in telling me where it is wrong, and suggestions for quickly getting it working again! Many thanks!

I have summarised the key calls of the failing code below. As you can see, the program opens a control panel via Xt, then opens a Big window (for graphics & text) via X. Mouse events in the Big window used to be read via the XtAppNextEvent() call, after an XGrabButton() call had been made, but the call to XGrabButton() is now failing with a BadAccess, so we never see the events from the Big window.

If I use the CWOverrideRedirect option (which seems a strange thing to do on a big display window like this), then the XGrabButton works OK, but (as you might expect) the Big window has no title or borders & is always on top (not what we want).

Here is the sequence of the major calls:


   toplevel = XtAppInitialize(&XControlPanel,"XB",
              options,XtNumber(options),&GlobalArgC,GlobalArgV,
              NEfallback_resources,APargs,SIX);
  
   /* open another channel to the server via the same application context -
      hence allowing the toolkit to process the mouse (etc.) events */
   if((TheXDisplay = XtOpenDisplay(XControlPanel,NULL,
                 "XB","ACompany",options,XtNumber(options),&GlobalArgC,
                 GlobalArgV)) == NULL)
   {
     // error handling & tidy up
   }

   XRootWin = DefaultRootWindow(TheXDisplay);
   ScreenNumber = XDefaultScreen(TheXDisplay);

   XBigWindowAttr.backing_store = Always;
   XBigWindowAttr.save_under = True;
   XBigWindowAttr.event_mask = ButtonReleaseMask;

   XBigWindow = XCreateWindow(TheXDisplay,XRootWin,0,0,BITMAPWIDTH,BITMAPHEIGHT,XWINBORDERWIDTH,
                              BigWindowDepth,InputOutput,(Visual *)XBigWindowVisual,
                              CWSaveUnder | CWBackingStore | CWBackPixel| CWBorderPixel | CWColormap
                                | CWEventMask,
                              &XBigWindowAttr);
   /* now let's map the window */
   if((XIntError = XMapRaised(TheXDisplay,XBigWindow)) != Success)
   {
     // error handling
   }

  if((XIntError = XGrabButton(TheXDisplay,JNSBUTTONS,JNSKMODS,XBigWindow,False,
                              Button1Mask,GrabModeAsync,GrabModeAsync,None,None)) != Success)
  {
    // error handling
  }

// Event Handling ...

   while(0 == 0)
   {
      XtAppNextEvent(XControlPanel,&TheEvent);
      // etc
   }

--------------------------------------------------------------------------

The exact error message from XGrabButton() is:

X Error of failed request:  BadAccess (attempt to access private resource denied)
Major opcode of failed request:  28 (X_GrabButton)


I'm hoping this is something simple, and I appreciate help in getting this running again.

Many thanks,

Greg

Reply via email to