GtkWindow 无装饰模式单击移动窗口

/* example.c
 * Heiher 
 * gcc -o example example.c `pkg-config --cflags --libs gtk+-3.0`
 */

#include 

static gboolean window_button_press_event_handler(GtkWidget * widget,
			GdkEvent * event, gpointer data)
{
	GdkEventButton * button = NULL;

	button = &event->button;
	if(1 == button->button) /* Left Click */
	{
		gtk_window_begin_move_drag(GTK_WINDOW(widget),
					button->button, button->x_root,
					button->y_root, button->time);
	}

	return FALSE;
}

int main(int argc, char * argv[])
{
	GtkWidget * window = NULL;

	gtk_init(&argc, &argv);

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	if(GTK_IS_WINDOW(window))
	{
		gtk_window_set_decorated(GTK_WINDOW(window), FALSE);
		gtk_widget_add_events(window, GDK_BUTTON_PRESS_MASK);
		g_signal_connect(G_OBJECT(window), "button-press-event",
					G_CALLBACK(window_button_press_event_handler), NULL);
		gtk_widget_show(window);

		gtk_main();
	}


	return 0;
}

Over!

3 thoughts on “GtkWindow 无装饰模式单击移动窗口”

Leave a Reply to bedding sets Cancel reply

Your email address will not be published. Required fields are marked *