title: X11/Xlib: Window always on top
body: <p>A window should stay on top of all other windows. Is this somehow possible with plain x11/xlib? Googling for "Always on top" and "x11" / "xlib" didn't return anything useful.</p>
  
  <p>I'd avoid toolkits like GTK+, if somehow possible.</p>
  
  <p>I'm using Ubuntu with gnome desktop. In the window menu, there's an option "Always On Top". Is this provided by the X server or the window manager? If the second is the case, is there a general function that can be called for nearly any wm? Or how to do this in an "X11-generic" way?</p>
  
  <p><hr><strong>Edit: I implemented fizzer's answer, now having following code:</strong></p>
  
  <pre><code>XSelectInput(this-&gt;display, this-&gt;window,
      ButtonPressMask |
      StructureNotifyMask |
      ExposureMask |
      KeyPressMask |
      PropertyChangeMask |
      VisibilityChangeMask ); 
  // ...
  // In a loop:
  if (XPending(this-&gt;display) &gt;= 0)
  {
      XNextEvent(this-&gt;display, &amp;ev);
      switch(ev.type) {
      // ...
      case VisibilityNotify:
          XRaiseWindow(this-&gt;display, this-&gt;window);
          XFlush(this-&gt;display);
      break;
      // ...
      }
  }
  </code></pre>
  
  <p>But the eventhandling and raising nearly never gets executed even my mask is correct?!</p>