After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 744054 - Clarify documentation for event propagation and handling
Clarify documentation for event propagation and handling
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Documentation
3.15.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2015-02-05 16:49 UTC by Philip Withnall
Modified: 2015-02-19 12:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gtk: Remove documentation references to the GTK_NO_WINDOW flag (6.73 KB, patch)
2015-02-18 11:45 UTC, Philip Withnall
committed Details | Review
docs: Mention events in the input handling documentation title (1.53 KB, patch)
2015-02-18 11:45 UTC, Philip Withnall
committed Details | Review
docs: Expand input handling documentation to cover event masks (11.74 KB, patch)
2015-02-18 11:45 UTC, Philip Withnall
committed Details | Review
docs: Add extra symbol links to input handling documentation (6.08 KB, patch)
2015-02-18 11:45 UTC, Philip Withnall
committed Details | Review
fixup! docs: Expand input handling documentation to cover event masks (4.17 KB, patch)
2015-02-19 09:52 UTC, Philip Withnall
committed Details | Review

Description Philip Withnall 2015-02-05 16:49:04 UTC
GTK+’s documentation for how events are triggered, propagated through the widget hierarchy, and how event masks interact with them to determine which widgets receive an event, is hard to find and opaque to new developers.

It would be great if we could write a conceptual overview of event handling, using the material currently on

https://developer.gnome.org/gtk3/unstable/gtk3-General.html
https://developer.gnome.org/gtk3/unstable/GtkWidget.html#gtk-widget-set-events

and cross-link it from all the relevant places. We should make sure that it’s clear exactly when a user should call gtk_widget_add_events() — do they assume internal knowledge of what events a widget handles already, or do they just go ahead and add everything they ever expect the widget to handle (which I guess would involve calling gtk_widget_add_events(my_gtk_button, GDK_BUTTON_PRESS_MASK), which is a bit silly; but there are other cases which are less obvious).
Comment 1 Matthias Clasen 2015-02-06 07:39:05 UTC
Like this: https://developer.gnome.org/gtk3/stable/chap-input-handling.html you mean ?
Comment 2 Philip Withnall 2015-02-06 08:42:29 UTC
(In reply to comment #1)
> Like this: https://developer.gnome.org/gtk3/stable/chap-input-handling.html you
> mean ?

Yeah, pretty much. Perhaps we could:
 • Add ‘event’ to the page title to make it easier to find.
 • Add a section on event masks, since they are only briefly touched in the ‘touch events’ section.
 • Link to it from the GtkWidget event mask functions and GdkEventMask documentation.

How would you feel about that? I can try and come up with a patch if you’re happy with it.
Comment 3 Matthias Clasen 2015-02-10 16:17:14 UTC
(In reply to Philip Withnall from comment #2)
 
> How would you feel about that? I can try and come up with a patch if you’re
> happy with it.

Hard to say if I'm happy with it before seeing the patch... but lets just say I'm happy with the suggestion.
Comment 4 Philip Withnall 2015-02-18 11:45:14 UTC
Created attachment 297086 [details] [review]
gtk: Remove documentation references to the GTK_NO_WINDOW flag

It has been removed entirely, and replaced by
gtk_widget_get_has_window().
Comment 5 Philip Withnall 2015-02-18 11:45:19 UTC
Created attachment 297087 [details] [review]
docs: Mention events in the input handling documentation title

Make it a little easier to find these docs when searching for ‘event’.
Comment 6 Philip Withnall 2015-02-18 11:45:24 UTC
Created attachment 297088 [details] [review]
docs: Expand input handling documentation to cover event masks

Also try and clarify a few things about event propagation. Move
input-handling.xml into gtk-doc’s expand_content_files variable so it
automatically links to widget documentation. Add links from
gtk_widget_add_events() and friends to the new documentation.
Comment 7 Philip Withnall 2015-02-18 11:45:30 UTC
Created attachment 297089 [details] [review]
docs: Add extra symbol links to input handling documentation

Cross-reference to the API documentation more consistently.
Comment 8 Matthias Clasen 2015-02-18 15:56:44 UTC
Review of attachment 297086 [details] [review]:

sure
Comment 9 Matthias Clasen 2015-02-18 15:57:33 UTC
Review of attachment 297087 [details] [review]:

Not sure I fully agree with input and events being two separate things, but ok
Comment 10 Matthias Clasen 2015-02-18 15:57:41 UTC
Review of attachment 297087 [details] [review]:

Not sure I fully agree with input and events being two separate things, but ok
Comment 11 Matthias Clasen 2015-02-18 15:59:32 UTC
Review of attachment 297089 [details] [review]:

easy to do too much with cross-references, but I guess this is still ok
Comment 12 Carlos Garnacho 2015-02-18 17:06:13 UTC
Review of attachment 297088 [details] [review]:

Thanks Philip for tackling this :). Very nice additions overall, I've only got some minor changes/suggestions

::: docs/reference/gtk/input-handling.xml
@@ +101,3 @@
+
+    <para>
+      When a GDK backend produces an event, it is tied to a #GdkDevice and a

Probably better to clarify "input event"

@@ +116,3 @@
+      event’s #GdkWindow. If this #GtkWidget is a child of the grab widget, the
+      event is propagated to the child — this is the basis for propagating
+      events within modal dialogues.

"dialogs" for consistence? is there even a british vs american english preference? :). Feel free to ignore me.

@@ +122,3 @@
+      An event is propagated to a widget using gtk_propagate_event().
+      Propagation differs between event types: key events (%GDK_KEY_PRESS,
+      %GDK_KEY_RELEASE) are delivered to the top-level #GtkWindow; other events

It might be worth to mention gtk_window_propagate_key_event(), and how key events bubble from the focus widget.

@@ +123,3 @@
+      Propagation differs between event types: key events (%GDK_KEY_PRESS,
+      %GDK_KEY_RELEASE) are delivered to the top-level #GtkWindow; other events
+      are propagated down and up the widget hierarchy in two phases.

That's 3 phases. Conceptually, GtkWidget::event is part of the bubbling phase, might be mentioned as such on the paragraph below.

@@ +184,3 @@
+    <para>
+      If a widget is windowless (gtk_widget_get_has_window() returns %FALSE), it
+      must be placed inside a #GtkEventBox to receive events, and an appropriate

Many widgets achieve this through GDK_INPUT_ONLY windows, not sure if this is something we want to explain too much in detail here.
Comment 13 Philip Withnall 2015-02-19 09:52:51 UTC
Created attachment 297253 [details] [review]
fixup! docs: Expand input handling documentation to cover event masks
Comment 14 Carlos Garnacho 2015-02-19 11:46:20 UTC
Review of attachment 297253 [details] [review]:

Looks great! please commit together with the other patch :)
Comment 15 Philip Withnall 2015-02-19 12:49:29 UTC
Great, all merged. Thanks for the fast reviews!

Attachment 297086 [details] pushed as b397dd0 - gtk: Remove documentation references to the GTK_NO_WINDOW flag
Attachment 297087 [details] pushed as 668d5d8 - docs: Mention events in the input handling documentation title
Attachment 297088 [details] pushed as 09bb109 - docs: Expand input handling documentation to cover event masks
Attachment 297089 [details] pushed as 8b4863f - docs: Add extra symbol links to input handling documentation