| 6 | static Display* display = NULL; |
| 7 | |
| 8 | int getScreenShotData(unsigned char** buffer, int x, int y, unsigned int width, unsigned int height) { |
| 9 | int ret = 0; |
| 10 | if (!display) { |
| 11 | display = XOpenDisplay(NULL); |
| 12 | } |
| 13 | |
| 14 | if (!display) { |
| 15 | // MSG("Fatal: Failed to open X display"); |
| 16 | return -1; |
| 17 | } |
| 18 | |
| 19 | Window win = DefaultRootWindow(display); |
| 20 | XImage* img = XGetImage(display, win, x, y, width, height, AllPlanes, ZPixmap); |
| 21 | memcpy(*buffer, img->data, width * height * 4); |
| 22 | XDestroyImage(img); |
| 23 | return ret; |
| 24 | } |
| 25 | |
| 26 | void closeDisplayHandle() { |
| 27 | if (display) { |
no outgoing calls
no test coverage detected