I'm trying to compare text.value to a string to catch when certain windows are open. It would be easy to use the XFetchName to do this, but it doesn't catch all the windows as XGetWMName does.

focused:
Code:
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <string.h>

// gcc -Wall focused.c -o focused -lX11 && focused

XTextProperty text;

Window get_toplevel_parent(Display * display, Window window) {

     Window parent;
     Window root;
     Window * children;
     unsigned int num_children;

     while (1) {

         if (XQueryTree(display, window, &root,
                   &parent, &children, &num_children) == 0) {
             printf("XQueryTree error\n");
         }

         if (children)
             XFree(children);
         
         if (window == root || parent == root)
            return window;
         else {
            XGetWMName(display, window, &text);
            window = parent;
         } 
     }
}

int main(int argc, char *argv[]) {

   Display *display;
   display = XOpenDisplay(NULL);
   Window focus, toplevel_parent_of_focus;
   XWindowAttributes attr;
   int revert;
    
   while (1) {

      XGetInputFocus(display, &focus, &revert);
      toplevel_parent_of_focus = get_toplevel_parent(display, focus);
      XGetWindowAttributes(display, toplevel_parent_of_focus, &attr);

      // Can check for null
      if (text.value == NULL)
         printf("NULL\n");

      // Cannot do this (error below):
      if (strcmp(text.value, "xterm") != 0)
         printf("xterm found\n");

      printf("Text: %s\n", text.value);

      // .5 sec
      usleep(500000); // .5 sec
   }

   return 0;
}
Resulting error:
Code:
focused.c:58:22: warning: pointer targets in passing argument 1 of ‘strcmp’ differ in signedness [-Wpointer-sign]
   58 |       if (strcmp(text.value, "xterm") != 0)
      |                  ~~~~^~~~~~
      |                      |
      |                      unsigned char *
In file included from focused.c:7:
/usr/include/string.h:140:32: note: expected ‘const char *’ but argument is of type ‘unsigned char *’
  140 | extern int strcmp (const char *__s1, const char *__s2)
      |                    ~~~~~~~~~~~~^~~~
There is this command: Xlib Programming Manual: XTextPropertyToStringList

... but I cannot figure out how to use it or if it would even be suitable to compare such strings.

Any ideas?