Major opcode of failed request: 73 (X_GetImage) in Fedora 32 and Fedora 34

Viewed 331

I'm developing an script which can get a screenshot on linux, it should work on ubuntu ,centos and fedora. The same code ,which can work on ubuntu and centos , throw this error during work on fedora. Here is the error message:

X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  73 (X_GetImage)
  Serial number of failed request:  7
  Current serial number in output stream:  7

I have tried use XMapRaised() and update my fedora32 to fedora34 ,but it doesn't make any sense. I am searching for a long time on net. But no use. Please help or try to give some ideas how to achieve this. Here is the code :

Window desktop;
Display* dsp;
XImage* img;

int screen_width;
int screen_height;

dsp = XOpenDisplay(NULL);/* Connect to a local display */

desktop = RootWindow(dsp,0);/* Refer to the root window */

/* Retrive the width and the height of the screen */
screen_width = DisplayWidth(dsp,0);
screen_height = DisplayHeight(dsp,0);

XMapRaised(dsp,desktop);
img = XGetImage(dsp,desktop,0,0,screen_width,screen_height,~0,ZPixmap);

Now I even encountered this problem when using XWD, Can't Xlib be used in Fedora? Here is the error message.

    [user@fedora xlibshot]$ xwd -root > myscreen.xwd
  X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  73 (X_GetImage)
  Serial number of failed request:  61
  Current serial number in output stream:  61
0 Answers
Related