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 755547 - Polari won’t load more history when keyboard buttons are used
Polari won’t load more history when keyboard buttons are used
Status: RESOLVED FIXED
Product: polari
Classification: Applications
Component: general
3.16.x
Other Linux
: Normal normal
: ---
Assigned To: Polari maintainers
Polari maintainers
Depends on:
Blocks:
 
 
Reported: 2015-09-24 14:31 UTC by Simonas Kazlauskas
Modified: 2015-12-21 15:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Load more history (backlog) through keyboard keys (1.76 KB, patch)
2015-12-18 20:20 UTC, Isabella Ribeiro
reviewed Details | Review
chatView: Also load history when scrolling via keyboard (2.04 KB, patch)
2015-12-21 14:28 UTC, Isabella Ribeiro
committed Details | Review

Description Simonas Kazlauskas 2015-09-24 14:31:52 UTC
If you use PgUp/PgDown buttons to scroll up and down the message list, there’s no way to load more history (e.g. by clicking PgUp once more when at the top of the message window)
Comment 1 Isabella Ribeiro 2015-11-09 19:59:56 UTC
I'm working on this bug.
Comment 2 Isabella Ribeiro 2015-12-18 20:20:46 UTC
Created attachment 317650 [details] [review]
Load more history (backlog) through keyboard keys

Should be able to fetch backlog even when keyboard navigation keys (PageUp or Up) are used.

This fix enables backlog fetching through key-press events.
Comment 3 Florian Müllner 2015-12-19 22:55:55 UTC
Review of attachment 317650 [details] [review]:

Minor style nits apart, the code looks good to me.

The commit message could be improved though. May I suggest something along the lines of:

chatView: Also load history when scrolling via keyboard                         
                                                                                
When available, we fetch more messages from the history when scrolling          
past the top of the view. However as we currently only consider scroll          
events, this will only work when scrolling with a pointer device; also          
handle appropriate key events to make the functionality available via
keyboard as well.

::: src/chatView.js
@@ +313,3 @@
         this.widget.vadjustment.connect('changed',
                                  Lang.bind(this, this._updateScroll));
+        this._view.connect('key-press-event', Lang.bind(this ,this._onKeyPress));

Style nit:
space between parameters should follow the comma, not precede it.

@@ +459,3 @@
+        let [, keyval] = event.get_keyval();
+        if (keyval != Gdk.KEY_Up && keyval != Gdk.KEY_KP_Up && 
+            keyval != Gdk.KEY_Page_Up && keyval != Gdk.KEY_KP_Page_Up)

This is a checking one variable for any of the values we intend to handle, i.e. the operands are completely commutative (unlike a condition like "if (foo != null && foo.matches('bar'))"). In those cases I consider each condition on a separate line more readable:
  if (keyval != Gdk.KEY_Up &&
      keyval != Gdk.KEY_UP_Up &&
      keyval != ...
Comment 4 Simonas Kazlauskas 2015-12-19 23:09:03 UTC
Review of attachment 317650 [details] [review]:

::: src/chatView.js
@@ +459,3 @@
+        let [, keyval] = event.get_keyval();
+        if (keyval != Gdk.KEY_Up && keyval != Gdk.KEY_KP_Up && 
+            keyval != Gdk.KEY_Page_Up && keyval != Gdk.KEY_KP_Page_Up)

I do not think this is a good approach. E.g. I immediately can think of another button (Home) that also scrolls up but isn’t handled here. Who knows how many more are there? 

Maybe you should just connect to scroll position change event and see if it is near-top instead? Or rather, exactly why

    this.widget.vadjustment.connect('changed',

doesn’t fire/work for keyboard scroll?
Comment 5 Florian Müllner 2015-12-19 23:32:37 UTC
(In reply to Simonas Kazlauskas from comment #4)
> I do not think this is a good approach. E.g. I immediately can think of
> another button (Home) that also scrolls up but isn’t handled here.

We are interested in scrolling *past* the top, not *to* the top (which is what Home does). 


> Who knows how many more are there?

GTK+ is free software, so anyone who takes a good look at the code[0].


> exactly why
> 
>     this.widget.vadjustment.connect('changed',
> 
> doesn’t fire/work for keyboard scroll?

Because scrolling changes the adjustment's value, which is the one property not covered by the GtkAdjustment::changed signal[1]. You are probably thinking of GtkAdjustment::value-changed, which we could indeed use to detect scrolling to the top, but not past that. While that difference isn't too important by itself, we do need to handle the corresponding scroll-events anyway to suppress GTK's overshoot indication while there's more history to load. And while less obvious, there's a similar indication for keyboard scrolling as well - trying to arrow-up past the top ends in a call to gtk_widget_keynav_failed() and gtk_widget_error_bell() ...



[0] https://git.gnome.org/browse/gtk+/tree/gtk/gtktextview.c#n1440
[1] https://developer.gnome.org/gtk3/stable/GtkAdjustment.html#GtkAdjustment-changed
Comment 6 Florian Müllner 2015-12-19 23:35:05 UTC
(In reply to Florian Müllner from comment #5)
> (In reply to Simonas Kazlauskas from comment #4)
> > I do not think this is a good approach. E.g. I immediately can think of
> > another button (Home) that also scrolls up but isn’t handled here.
> 
> We are interested in scrolling *past* the top, not *to* the top (which is
> what Home does).

The analog pointer operation is grabbing the scrollbar and dragging it all the way to the top - no history loading either
Comment 7 Simonas Kazlauskas 2015-12-19 23:46:16 UTC
(In reply to Florian Müllner from comment #5)
> We are interested in scrolling *past* the top, not *to* the top (which is
> what Home does). 

(In reply to Florian Müllner from comment #6)
> The analog pointer operation is grabbing the scrollbar and dragging it all
> the way to the top - no history loading either

I guess all this really demonstrates is that touchscreen/phone interactions don’t really work on desktop. What about repeatedly mashing Home while it is already at top? You could argue this also could count as scrolling “past the top” even if technically it isn’t (just like PgUp and ↑).
Comment 8 Florian Müllner 2015-12-20 00:06:37 UTC
(In reply to Simonas Kazlauskas from comment #7)
> (In reply to Florian Müllner from comment #6)
> > The analog pointer operation is grabbing the scrollbar and dragging it all
> > the way to the top - no history loading either
> 
> I guess all this really demonstrates is that touchscreen/phone interactions
> don’t really work on desktop.

Touchscreen/phone interactions like grabbing and dragging a scrollbar?


> What about repeatedly mashing Home while it is already at top?

Doesn't make sense to me. Consider room list navigation: You can use <alt>up/down to switch channels, and you could make a point that hitting <alt>up when at the top of the list should wrap around to the end. However when using <alt>1 to jump to the top room directly, I don't see how any other action would make sense no matter how often the shortcut is repeated.
Comment 9 Simonas Kazlauskas 2015-12-20 00:13:45 UTC
(In reply to Florian Müllner from comment #8)
> Touchscreen/phone interactions like grabbing and dragging a scrollbar?

No, the scrolling past the top to reload. The kind of thing you see in almost every Android application.

> Doesn't make sense to me. Consider room list navigation: You can use
> <alt>up/down to switch channels, and you could make a point that hitting
> <alt>up when at the top of the list should wrap around to the end. However
> when using <alt>1 to jump to the top room directly, I don't see how any
> other action would make sense no matter how often the shortcut is repeated.

That’s true. However, (hypothetically, since I don’t really want do do that) in this case I could also argue that Home should/could show the very first message in the history available rather than the oldest already loaded message.
Comment 10 Florian Müllner 2015-12-20 00:20:54 UTC
(In reply to Simonas Kazlauskas from comment #9)
> That’s true. However, (hypothetically)

Well, the whole Home-key issue is completely hypothetical anyway, given that Home will jump to the beginning of the line and <ctrl>Home (which would jump to the start of the buffer) is overloaded by the shortcut to switch to the first room ...
Comment 11 Isabella Ribeiro 2015-12-21 14:28:40 UTC
Created attachment 317739 [details] [review]
chatView: Also load history when scrolling via keyboard

Should be able to fetch backlog even when keyboard navigation keys (PageUp or Up) are used.

When available, we fetch more messages from the history when scrolling past the top of the view. However as we currently only consider scroll events, this will only work when scrolling with a pointer device; This fix adds appropriate key events handling to make the functionality also available via keyboard.
Comment 12 Florian Müllner 2015-12-21 15:45:41 UTC
Review of attachment 317739 [details] [review]:

Thanks!

Note that git-log doesn't do automatic line-wrapping, so the commit message should be wrapped manually at around 80 characters. And semicolons don't start a new sentence, so no capitalization there - I don't think it's worth doing another revision there though, so I'll just fix those up and push.

::: src/chatView.js
@@ +458,3 @@
+    _onKeyPress: function(w, event) {
+        let [, keyval] = event.get_keyval();
+        if (keyval != Gdk.KEY_Up && 

Nit: trailing whitespace
Comment 13 Florian Müllner 2015-12-21 15:50:42 UTC
Attachment 317739 [details] pushed as 4520171 - chatView: Also load history when scrolling via keyboard