window always on top using xlib

411 views Asked by At

I'm in the process of creating a gtk2 application which I would like drawn over all other apps at all times, I would rather use xlib to do that if it is possible

here's my code so far:

#include <gtk/gtk.h>

int main(int argc, char **argv)
{
        gtk_init(&argc, &argv);
        GtkWidget     *mainwin;
        mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        gtk_widget_show_all (mainwin);
        gtk_main ();
        return 0;
}

I'd like to do this in the simplest manner possible thanks

1

There are 1 answers

2
Filip Bulovic On BEST ANSWER

Yes it is possible and not complicated

#include <gtk/gtk.h>

int main(int argc, char **argv)
{
  gtk_init(&argc, &argv);
  GtkWidget     *mainwin;
  mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_keep_above ( (GtkWindow *) mainwin, TRUE);
  gtk_widget_show_all (mainwin);
  gtk_main ();
  return 0;
}

gtk_window_set_keep_above does trick if window manager is cooperative.