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 789218 - gtk_gesture_get_last_event() missing (nullable) annotation for GDKEventSequence arg
gtk_gesture_get_last_event() missing (nullable) annotation for GDKEventSequen...
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Class: GtkGesture
3.22.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 709605
 
 
Reported: 2017-10-19 19:50 UTC by Marcus Lundblad
Modified: 2018-05-02 19:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GtkGesture: Add (nullable) on argument for _get_last_event() (932 bytes, patch)
2017-10-19 19:50 UTC, Marcus Lundblad
none Details | Review

Description Marcus Lundblad 2017-10-19 19:50:20 UTC
In Maps I've tried to implement support for bringing up the context menu on long-press on the view on touch screens with the following code:

this._longPressGesture = new Gtk.GestureLongPress({ widget: this._mapView });
this._longPressGesture.connect('pressed', (function(gesture, x, y) {
    Mainloop.idle_add((function() {
        let sequence = gesture.get_last_updated_sequence();

        this.popup_at_pointer(gesture.get_last_event(sequence));
    }).bind(this));
}).bind(this));

(the idle_add call is to avoid event lock-ups in Clutter).

This currently gives a GIR error as the @sequence argument for gtk_gesture_get_last_event() is not annotated with null, even though gtk_gesture_get_last_updated_sequence() can return null.

Adding the correct GIR annotation in gtkgesture.c fixes this.
Comment 1 Marcus Lundblad 2017-10-19 19:50:53 UTC
Created attachment 361902 [details] [review]
GtkGesture: Add (nullable) on argument for _get_last_event()

gtk_gesture_get_last_event() lacks a (nullable) annotation for
the sequence parameter, even though it can in some circumstances
be null.
Comment 2 Timm Bäder 2017-10-20 07:12:32 UTC
If the parameter is nullable, the docs should say what a NULL value means.
Comment 3 Marcus Lundblad 2017-10-20 07:19:34 UTC
(In reply to Timm Bäder from comment #2)
> If the parameter is nullable, the docs should say what a NULL value means.

Good point. I guess the return of gtk_gesture_get_last_updated_sequence() should also mention the possible null return and what it implies.
Comment 4 Daniel Boles 2018-01-17 19:03:54 UTC
Are we sure that the given use case is supported, i.e. that we want to formally make @sequence nullable - rather than requiring the user to check whether get_last_updated_sequence() returns NULL and not call get_last_event() if so?
Comment 5 Marcus Lundblad 2018-01-17 19:20:21 UTC
(In reply to Daniel Boles from comment #4)
> Are we sure that the given use case is supported, i.e. that we want to
> formally make @sequence nullable - rather than requiring the user to check
> whether get_last_updated_sequence() returns NULL and not call
> get_last_event() if so?

OK, maybe not. But in that case, is the code-snippet above the wrong approach? Or how would I get hold of the event triggering the gesture. Or hmm, maybe .popup_at_pointer() should be called with null as the event in that case (the docs says "NULL if it's the current event".
Comment 6 Matthias Clasen 2018-01-18 21:15:48 UTC
if get_last_updated_sequence returns NULL, that certainly means there is no event sequence to get the last event from...
Comment 7 Daniel Colascione 2018-03-08 20:44:05 UTC
Matthias, not true, at least in the case of GtkGestureDrag, which returns a perfectly good event from gtk_gesture_get_last_event inside the drag-begin handler even though the current sequence is NULL. Without a nullable annotation on functions that accept GDKEventSequence arguments, there is no way for language bindings to use the gesture facility correctly.
Comment 8 Daniel Colascione 2018-03-08 20:57:01 UTC
And FWIW, in this context, gtk_gesture_get_sequences() returns a list with a single NULL element. Either NULL needs to be acknowledged as a valid sequence identifier or the gesture code needs to be modified to return some non-NULL sentinel in this context.
Comment 9 GNOME Infrastructure Team 2018-05-02 19:20:58 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/955.