1.添加下面代码
g_signal_connect(G_OBJECT(window), "button-press-event", G_CALLBACK(window_drag), NULL);
2.回调如下
gboolean window_drag(GtkWidget *widget, GdkEventButton *event, GdkWindowEdge edge)
{
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 FALSE;
}