Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WId ImageGrabber::getActiveWindow()
- {
- int screenNum;
- xcb_connection_t* connection = xcb_connect (NULL, &screenNum);;
- xcb_get_input_focus_reply_t *replyFocus = xcb_get_input_focus_reply(connection, xcb_get_input_focus(connection), nullptr);
- xcb_query_tree_cookie_t cookie;
- xcb_query_tree_reply_t *replyTree;
- cookie = xcb_query_tree(connection, replyFocus->focus);
- xcb_window_t w = replyFocus->focus;
- while((replyTree = xcb_query_tree_reply(connection, cookie, NULL)) && (replyTree->parent != replyTree->root)) {
- printf("root = %d\n", replyTree->root);
- printf("parent = %d\n", replyTree->parent);
- printf("Focus = %d\n", replyFocus->focus);
- cookie = xcb_query_tree(connection, replyTree->parent);
- w = replyTree->parent;
- }
- printf("**Returned = %d\n", w);
- return w;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement