summaryrefslogtreecommitdiff
path: root/xcb02.cpp
diff options
context:
space:
mode:
authorFlorian Jung <florian.a.jung@web.de>2012-10-03 23:14:04 +0200
committerFlorian Jung <florian.a.jung@web.de>2012-10-03 23:14:04 +0200
commita1e44a83c5fcd1e39b006df65ae1ff9a0ea423e4 (patch)
tree0a52d6334f999cad7d14c2264336e45532aea4d7 /xcb02.cpp
parent4468f577991cd86e844c3a5929e3b0d6e1ff3b45 (diff)
meh
Diffstat (limited to 'xcb02.cpp')
-rw-r--r--xcb02.cpp48
1 files changed, 27 insertions, 21 deletions
diff --git a/xcb02.cpp b/xcb02.cpp
index 29c0bd6..bd5bf1b 100644
--- a/xcb02.cpp
+++ b/xcb02.cpp
@@ -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);
}