Re: Calling get/set_events() after realizing?
- From: Owen Taylor <otaylor gtk org>
- To: "Damon Chaplin" <DAChaplin email msn com>
- Cc: "GTK List" <gtk-list redhat com>
- Subject: Re: Calling get/set_events() after realizing?
- Date: 14 Jun 1998 17:12:37 -0400
"Damon Chaplin" <DAChaplin@email.msn.com> writes:
> Is there any reason gtk_widget_get/set_events() can't be called after
> a widget is realized? E.g. using code like this:
>
> gint
> gtk_widget_get_events (GtkWidget *widget)
> {
> gint *events;
>
> g_return_val_if_fail (widget != NULL, 0);
>
> if (GTK_WIDGET_REALIZED (widget))
> return gdk_window_get_events(widget->window);
You currently _can_ call set events on an existing widget -
but the result is not the same as what the above produces.
See below for an explanation.
> ...
>
>
> void
> gtk_widget_set_events (GtkWidget *widget,
> gint events)
> {
> gint *eventp;
>
> g_return_if_fail (widget != NULL);
> g_return_if_fail (!GTK_WIDGET_NO_WINDOW (widget));
>
> if (GTK_WIDGET_REALIZED (widget))
> gdk_window_set_events(widget->window, events);
> ...
>
>
> It would get rid of one of the annoying stumbling blocks for learners
> of GTK, though I suppose there may be a performance penalty.
The performance penalty is negligable (since before the widget is
realized, you can do things the way they are done now). More important
is the fact that it really can't be done properly without modifying
every widget. Why? Because a typical realize() function has code:
attributes.event_mask = gtk_widget_get_events (widget);
attributes.event_mask |= (GDK_EXPOSURE_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK);
Now, say later the user changes the event mask for the widget.
GTK+ has no way of knowing what events the widget needs
to always have in the event mask. So basically, that means
that it is only possible to add events to the event mask,
and never remove them. Also, widgets may have several windows,
and the GTK only knows about widget->window.
> It might even be useful for GUI builders at some point.
A GUI builder probably never needs to remove events from the
mask, so it can probably make do with calling:
GdkEventMask gdk_window_get_events (GdkWindow *window);
void gdk_window_set_events (GdkWindow *window,
GdkEventMask event_mask);
directly.
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]