🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How to get the exact title of the windows running in linux

Started by
0 comments, last by Null and Void 16 years, 10 months ago
Hi, I'm trying to get the exact title of the windows running in linux by using XFetchName function, as shown in the following code:

  Display *display = XOpenDisplay(NULL);
  
  int numWindows = 0;
  Window root, parent, *children;

  XQueryTree(display, RootWindow(display,0), &root, &parent, &children, &numWindows);
  
  int i = 0;
  for( i = 0 ; i < numWindows ; i++)
  {
	 char *name;
     XFetchName(display, children, &name);
         
	 if(name)
        printf("Window name: %s\n", name);
  }

The code works, but it only give me the names of the "application kinds", like console, konkeror, kwrite etc. For example: Suppose I have a doc called "ReadMe", opened with kwrite. When I run that code, it returns the "kwrite" name for this app. I would like to get the "ReadMe" name. Please, how could I do this? Thanks in advance
Advertisement
According to the ICCCM, a property named WM_NAME will be added to the window with the title. The Extended Window Manager Hints add the UTF-8 formatted _NET_WM_NAME and _NET_WM_VISIBLE_NAME properties. You can use XGetWindowProperty to get these values.

This topic is closed to new replies.

Advertisement