/*
gcc `pkg-config --cflags --libs gtk+-2.0 gdk-2.0` metacity-hide-username-demo.c -o metacity-hide-username-demo
 */

#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>

static void
hide_username_on_window (GtkWidget *window)
{
  GdkDisplay *display = gdk_drawable_get_display (window->window);
  Window xwindow = GDK_WINDOW_XID (window->window);
  guint32 one = 1;

  XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
		   xwindow,
                   gdk_x11_get_xatom_by_name_for_display (display, "_METACITY_HIDE_USERNAME"),
                   gdk_x11_get_xatom_by_name_for_display (display, "CARDINAL"), 32,
                   PropModeReplace, (char*) &one, 1);
}

int
main(int argc, char **argv)
{
  GtkWidget *first, *second;

  gtk_init (&argc, &argv);

  first = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (first), "Doesn't have the hint");
  gtk_window_set_default_size (GTK_WINDOW (first), 800, 100);
  gtk_widget_show_all (first);

  second = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (second), "Has the hint");
  gtk_window_set_default_size (GTK_WINDOW (second), 800, 100);
  gtk_widget_show_all (second);
  hide_username_on_window (second);

  gtk_main();
}
