interesting basic X-event-derived signal behaviour
- From: Paul Barton-Davis <pbd op net>
- To: gtk-list gnome org
- Subject: interesting basic X-event-derived signal behaviour
- Date: Thu, 11 Jan 2001 15:32:40 -0500
Consider the following simple program:
----------------------------------------------------------------------
#include <gtk/gtk.h>
gboolean eventAddition(GtkWidget* myWindow, GdkEvent* eventData,
gpointer eventString)
{
switch(eventData->type)
{
case GDK_BUTTON_PRESS:
g_print("You pressed mouse button.\n");
break;
case GDK_ENTER_NOTIFY:
g_print("You are moving mouse into window.\n");
break;
case GDK_LEAVE_NOTIFY:
g_print("You are moving mouse outside window.\n");
break;
case GDK_FOCUS_CHANGE:
g_print("The focus changed.\n");
break;
default:
break;
}
return FALSE;
}
int main(gint argc, gchar** argv)
{
GtkWidget* myWindow;
gtk_init(&argc,&argv);
myWindow=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_signal_connect(GTK_OBJECT(myWindow),"event",
GTK_SIGNAL_FUNC(eventAddition),NULL);
gtk_widget_set_events (myWindow,
gtk_widget_get_events(myWindow)|
GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK);
gtk_signal_connect(GTK_OBJECT(myWindow),"button_press_event",
GTK_SIGNAL_FUNC(button_press_event),NULL);
gtk_widget_show(myWindow);
gtk_main();
return 0;
}
----------------------------------------------------------------------
If you compile this with the gtk_widget_set_events() call commented
out, the window still receives certain kinds of events but with the
wrong type associated with them. For example, button press events
will be received as enter/leave notify events. This seems wrong. Is
there an error in the code above, or is it within GDK/GTK ?
--p
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]