-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
35 lines (26 loc) · 1.1 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <gtk/gtk.h>
#include <stdio.h>
gboolean button_pressed(GtkWidget *widget, GdkEvent *event, gpointer data) {
printf("Button pressed\n");
return FALSE;
}
gboolean button_released(GtkWidget *widget, GdkEvent *event, gpointer data) {
printf("Button released\n");
return FALSE;
}
int main(int argc, char* argv[]) {
GtkWidget *window;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "Touch Test Window" );
gtk_window_set_default_size(GTK_WINDOW(window), 350, 350);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_widget_add_events(GTK_WIDGET(window), GDK_BUTTON_PRESS_MASK);
gtk_widget_add_events(GTK_WIDGET(window), GDK_BUTTON_RELEASE_MASK);
g_signal_connect(G_OBJECT(window), "button-press-event", G_CALLBACK(button_pressed), NULL);
g_signal_connect(G_OBJECT(window), "button-release-event", G_CALLBACK(button_released), NULL);
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
gtk_widget_show(window);
gtk_main();
return 0;
}