diff options
Diffstat (limited to 'xcb02.cpp')
-rw-r--r-- | xcb02.cpp | 48 |
1 files changed, 27 insertions, 21 deletions
@@ -42,8 +42,7 @@ int main(int argc, char **argv) xcb_screen_t* grab_screen=NULL; /* Find configured screen */ - const xcb_setup_t *setup = xcb_get_setup(conn); - xcb_screen_t *scr = NULL; + const xcb_setup_t* setup = xcb_get_setup(conn); for (xcb_screen_iterator_t i = xcb_setup_roots_iterator(setup); i.rem > 0; xcb_screen_next (&i)) { @@ -73,26 +72,24 @@ int main(int argc, char **argv) cout << title << endl; if (strstr(title, "Mupen64Plus OpenGL Video")) { - grabbed_win=children[i]; - found_win=true; + xcb_get_geometry_reply_t* geo; + geo = xcb_get_geometry_reply (conn, xcb_get_geometry (conn, children[i]), NULL); + if (geo) + { + grab_width=geo->width; + grab_height=geo->height; + + free(geo); + + grabbed_win=children[i]; + found_win=true; - /* Window properties */ - xcb_get_geometry_reply_t *geo; - geo = xcb_get_geometry_reply (conn, - xcb_get_geometry (conn, grabbed_win), - NULL); - if (geo == NULL) + grab_screen=scr; + } + else { cerr << "geo==NULL!" << endl; - exit(1); } - - grab_width=geo->width; - grab_height=geo->height; - - free(geo); - - grab_screen=scr; } } @@ -103,6 +100,10 @@ int main(int argc, char **argv) free(reply); delete[] cookies; } + else + { + cout << "xcb_get_setup failed" << endl; + } } if (found_win) @@ -159,15 +160,20 @@ int main(int argc, char **argv) cout << grab_width << "x" << grab_height << endl; + free(img); + while(1) { + img = xcb_get_image_reply (conn, + xcb_get_image (conn, XCB_IMAGE_FORMAT_Z_PIXMAP, grabbed_win, + 0, 0, grab_width, grab_height, ~0), NULL); + Mat meh(grab_height, grab_width, CV_8UC4, xcb_get_image_data(img)); namedWindow("meh"); imshow("meh", meh); waitKey(50); - img = xcb_get_image_reply (conn, - xcb_get_image (conn, XCB_IMAGE_FORMAT_Z_PIXMAP, grabbed_win, - 0, 0, grab_width, grab_height, ~0), NULL); + + free(img); } |