How and when to use GdkWindow masks?



The manual for GtkWidget signals usually mentions that an event mask should be enabled, for example for motion-notify-event: 'to receive this signal, the GdkWindow associated to the widget needs to enable the GDK_POINTER_MOTION_MASK mask'.

The quoted part above is unclear. It does not say how GdkWindow should set the mask for a widget. Is it by the user calling:?

I:
 GdkWindow * w = gtk_widget_get_parent_window ( somegtkwidget );
 gdk_window_set_events ( w, event_mask);

II:
 gtk_widget_set_events (somegtkwidget, eventmask);
 gtk_widget_add_events (somegtkwidget, eventmask);

Are set/add events in II convenience functions that call gtk_widget_get_parent_window and gdk_window_set_events?   

I have only used gtk_widget_add_events so far and observed that calling it or not calling it made no difference for basic widgets such as checkbox for the masks:

 GDK_FOCUS_CHANGE_MASK
 GDK_ENTER_NOTIFY_MASK
 GDK_LEAVE_NOTIFY_MASK
 GDK_BUTTON_PRESS_MASK
 GDK_BUTTON_RELEASE_MASK
 GDK_KEY_PRESS_MASK
 GDK_KEY_RELEASE_MASK

I am learning and experimenting and so far I have only seen one case when gtk_widget_add_events made a difference and that was for motion-notify-event signal in a dialog. Without it the signal was reported when the mouse was in the enclosing top window. Any other instances when the gtk_widget_add_events is an absolute must?

Of course I can choose always to call the gtk_widget_add_events, but I would like to understand this a bit better.

Advice and comments would be appreciated.

 


Get your new Email address!
Grab the Email name you've always wanted before someone else does!

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]