title: In linux, get window class raise "X Error of failed request: BadWindow (invalid Window parameter)"
body: <p>here is my code, I get "X Error of failed request:  BadWindow (invalid Window parameter)"</p>
  
  <pre><code>xdo_t *xdo = xdo_new(":0");
  XWindowAttributes attr;
  XClassHint classhint;
  Window window;
  XGetWindowAttributes(xdo-&gt;xdpy, window, &amp;attr);
  if (XGetClassHint(xdo-&gt;xdpy, window, &amp;classhint)) {
      classhint.res_name;
  }
  </code></pre>