Advertisement

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

Started by September 03, 2007 08:16 PM
0 comments, last by Null and Void 17 years, 1 month 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
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