#include <gtk/gtk.h>
//gcc dragdrop.c `pkg-config --cflags --libs gtk+-3.0`
//with
//gtk_window_set_type_hint(..., GDK_WINDOW_TYPE_HINT_TOOLBAR);
//and the window doesn't move via gtk_window_begin_move_drag
//with
//gtk_window_set_type_hint(..., GDK_WINDOW_TYPE_HINT_UTILITY);
//and it does

gboolean on_mouse_move(GtkWidget* widget,
  GdkEventMotion *event, GdkWindowEdge edge) {
  
  fprintf(stderr, "mouse move %d\n", event->time);
  
  return TRUE;
}

gboolean on_button_press(GtkWidget* widget,
  GdkEventButton *event, GdkWindowEdge edge) {
      
  if (event->type == GDK_BUTTON_PRESS) {
      
    if (event->button == 1) {
      gtk_window_begin_move_drag(GTK_WINDOW(gtk_widget_get_toplevel(widget)),
          event->button,
          event->x_root,
          event->y_root,
          event->time);
    }
  }
  
  return TRUE;
}

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

  GtkWidget *window;

  gtk_init(&argc, &argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size(GTK_WINDOW(window), 250, 200);
  gtk_window_set_title(GTK_WINDOW(window), "Drag & drop");
  gtk_window_set_decorated(GTK_WINDOW(window), FALSE);
  gtk_widget_add_events(window, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
                           GDK_POINTER_MOTION_MASK |
                           GDK_VISIBILITY_NOTIFY_MASK | GDK_SCROLL_MASK);

  gtk_window_set_type_hint( GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_TOOLBAR );
  //gtk_window_set_type_hint( GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_UTILITY );

  g_signal_connect(G_OBJECT(window), "button-press-event",
      G_CALLBACK(on_button_press), NULL);

  g_signal_connect(G_OBJECT(window), "motion-notify-event",
      G_CALLBACK(on_mouse_move), NULL);

  g_signal_connect(G_OBJECT(window), "destroy",
        G_CALLBACK(gtk_main_quit), G_OBJECT(window));

  gtk_widget_show_all(window);

  gtk_window_present(GTK_WINDOW(window));

  gtk_main();

  return 0;
}
