Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <X11/Xlib.h>
- #include <X11/Xutil.h>
- int main (int argc, char *argv[]) {
- Display *display = XOpenDisplay(NULL);
- Window win, root, parent, *children;
- int revert = RevertToParent;
- int screen = DefaultScreen(display);
- unsigned int nchild;
- XGetInputFocus(display, &win, &revert);
- if (win != RootWindow(display, screen)) {
- parent = win;
- do {
- win = parent;
- XQueryTree(display, win, &root, &parent, &children, &nchild);
- XFree(children);
- } while(parent != RootWindow(display, screen));
- }
- char *name;
- int status = XFetchName(display, win, &name);
- std::cout << "Returned status:" << status << std::endl
- << "Active window name: " << name << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement