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 78513 - Scrolling by keeping Page Up/Down down is broken
Scrolling by keeping Page Up/Down down is broken
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
2.2.x
Other other
: High normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 75267 76975 82086 88957 93522 103261 105587 106198 124822 128173 137803 143122 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2002-04-12 12:48 UTC by Jeroen Zwartepoorte
Modified: 2011-02-04 16:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed solution (2.58 KB, patch)
2002-07-08 20:48 UTC, Gustavo Giráldez
none Details | Review
patch for 2.0.x branch (3.30 KB, patch)
2002-07-25 02:53 UTC, Havoc Pennington
none Details | Review
patch to avoid queuing too many scrolls (1.79 KB, patch)
2004-04-19 14:24 UTC, Matthias Clasen
none Details | Review

Description Jeroen Zwartepoorte 2002-04-12 12:48:23 UTC
In a large document, when you scroll up or down by holding down the Page
Up/Down key, the GtkTextView sometimes get's "locked" (it seems to scroll
down and then up and down again etc). Even after releasing the key, the
behavior continues for several seconds.

Happened on both my laptop and on my desktop. GTK+ version is cvs head from
a couple of days ago.
Comment 1 Matthias Clasen 2002-05-08 07:45:53 UTC
*** Bug 76975 has been marked as a duplicate of this bug. ***
Comment 2 Owen Taylor 2002-06-14 15:31:11 UTC
Move GtkTextView 2.0.4 bugs to 2.0.5
Comment 3 Gustavo Giráldez 2002-07-08 20:46:33 UTC
This happens because of incorrectly flushing a pending scroll when
already scrolling beyond.

The code path goes like this:

- user hits page key -> gtk_text_view_scroll_pages
- set_adjustment_clamped
- scrolling validation codepath
- gtk_text_view_scroll_mark_onscreen -> scroll is queued

Now if the user queues a page key press *before* the scroll is flushed
in the idle handler:

- gtk_text_view_scroll_pages
- set_adjustment_clamped
- scrolling validation codepath now begins:
  - gtk_text_view_value_changed
  - gdk_window_scroll
  - gtk_text_view_validate_online
  - process updates
    - expose handler
    - flush_first_validate
    - flush_scroll -> scrolls back, but doesn't reenter the scroll
		      validation codepath since value_changed is not
		      recursive
    - paint
- gtk_text_view_scroll_mark_onscreen -> new scroll is queued

Worst case: if *between* this last process updates and the expose
event the onscreen information is invalidated due to the layout
emitting the "invalidated" signal (e.g. an expose user signal handler
which modifies the buffer), since flush_scroll returns true,
onscreen is not revalidated, and the final assertion in
flush_first_validate fails.  This is because this code assumes
flush_scroll will produce a revalidation, which doesn't happen because
"value_changed" signal is not recursive.

Observations: even if the buffer is fully validated, I don't know why
the layout sometimes emits the "invalidated" signal, thus triggering
this behavior.  Is this expected?


Proposed solution (patch attached):

- Remove the queued scroll before changing the adjustment in
  scroll_pages and scroll_hpages.
- In flush_first_validate also validate onscreen lines if
  onscreen_validated is FALSE (this is not necessary but makes the
  code more robust imho)
Comment 4 Gustavo Giráldez 2002-07-08 20:48:21 UTC
Created attachment 9725 [details] [review]
Proposed solution
Comment 5 Havoc Pennington 2002-07-08 21:11:28 UTC
You are a brave man, and I owe you a beer, for jumping into this code.
The analysis/solution look promising.

I'll plan to look at it tonight, or as soon as possible. Please hassle
me if I don't.
Comment 6 Soren Sandmann Pedersen 2002-07-24 13:23:17 UTC
*** Bug 88957 has been marked as a duplicate of this bug. ***
Comment 7 Havoc Pennington 2002-07-25 02:53:22 UTC
Created attachment 10039 [details] [review]
patch for 2.0.x branch
Comment 8 Havoc Pennington 2002-07-25 02:54:02 UTC
I applied the patch to HEAD, with a small formatting change. 
The attached patch is for stable. Not applied to stable yet 
since Owen is working on 2.0.6.
Comment 9 Owen Taylor 2002-07-25 03:27:02 UTC
I don't understand the logic. I'm not distchecking currently...
Comment 10 Havoc Pennington 2002-07-25 03:32:50 UTC
a) I don't know when you are distchecking and b) I haven't really
tested the patch much.
Comment 11 Paolo Maggi 2002-09-17 20:58:15 UTC
*** Bug 93522 has been marked as a duplicate of this bug. ***
Comment 12 Matthias Clasen 2002-11-21 19:00:29 UTC
Moving bugs from older 2.0.x milestones to 2.0.10.
Comment 13 Luis Villa 2002-12-05 22:05:21 UTC
*** Bug 82086 has been marked as a duplicate of this bug. ***
Comment 14 Luis Villa 2002-12-05 22:05:37 UTC
There is a patch on this bug, can it be applied to stable branch?
Comment 15 Luis Villa 2002-12-05 22:54:18 UTC
Making all 'high' textview bugs 2.2.0 as per havoc's request.
Comment 16 Owen Taylor 2002-12-16 07:13:22 UTC
This was applied to the stable branch in August, actually.
Comment 17 Havoc Pennington 2003-01-13 02:19:59 UTC
*** Bug 103261 has been marked as a duplicate of this bug. ***
Comment 18 Paolo Maggi 2003-02-12 11:25:41 UTC
*** Bug 105587 has been marked as a duplicate of this bug. ***
Comment 19 Andrew Sobala 2003-02-16 11:53:59 UTC
*** Bug 106198 has been marked as a duplicate of this bug. ***
Comment 20 Paolo Maggi 2003-09-26 16:44:08 UTC
Reopening because the bug is back.

[paolo@elihost tests]$ pkg-config --modversion gtk+-2.0
2.2.4
Comment 21 Paolo Maggi 2003-09-26 16:45:24 UTC
*** Bug 93522 has been marked as a duplicate of this bug. ***
Comment 22 Arnaud Charlet 2003-10-15 15:51:28 UTC
This bug regressed with Gtk+ 2.2.2 (2.2.1 was OK, and 2.2.2, 2.2.3,
2.2.4 are not).

Arno
Comment 23 Arnaud Charlet 2003-10-15 15:53:02 UTC
*** Bug 75267 has been marked as a duplicate of this bug. ***
Comment 24 Elijah Newren 2003-10-15 15:57:50 UTC
Since it's a problem with gtk+-2.2.x for x>1 (according to the
previous comments), I'll update the version and keywords.
Comment 25 Arnaud Charlet 2003-10-15 16:13:42 UTC
More info: the culprit is the following change:

revision 1.216.2.12
date: 2003/06/05 22:59:23;  author: owen;  state: Exp;  lines: +15 -20
Thu Jun  5 16:52:54 2003  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtktextview.[ch]: Never scroll on focus in
        (#81893, Patch from Paolo Maggi)

        * gtk/gtktextview.c (gtk_text_view_scroll_[h]pages):
        Scroll to the current cursor location before handling
        the action, in case the user just tabbed in
        and the cursor is offscreen.

More specifically, the last part: remove the call to
gtk_text_view_scroll_mark_onscreen in gtk_text_view_Scroll_[h]pages
fixes this bug.

Arno
Comment 26 Paolo Maggi 2003-10-17 14:38:23 UTC
*** Bug 124822 has been marked as a duplicate of this bug. ***
Comment 27 Paolo Maggi 2003-12-29 23:19:24 UTC
*** Bug 128173 has been marked as a duplicate of this bug. ***
Comment 28 Owen Taylor 2004-02-17 22:47:18 UTC
Note that this bug probably shouldn't have been reopened,
since it's almost certainly just a different bug with
the same symptom.
Comment 29 Owen Taylor 2004-02-19 23:20:20 UTC
The current bug, as I understand it is:

 * gtk_text_view_scroll_mark_onscreen(), called twice from
   gtk_text_view_scroll_[h]pages() queues a scroll if
   anything in the view is invalid

 * the code in scroll_[h]pages assumes that scrolls take
   effect immediately.

 * But moving the cursor invalidates both the new and
   old paragraphs, so for repeated fast scrolling, we
   are always queueing scrolls that take effect later
   and yank the position of the window back.

One thing that could help, though it woudl a little
complex to implement would be the ability to say 
"scroll this mark onscreen wheever this mark is when 
the queued scroll happens" - right now scroll_mark_onscreen
creates a temporary mark at the current location of the
insertion cursor mark, which is absolutely the wrong
thing, we just want to use the insertion cursor mark.
Comment 30 Matthias Clasen 2004-03-03 23:58:40 UTC
For test purposes I ifdefed away the creation of the temp mark and
just used the mark given to scroll_mark_onscreen(). It doesn't help at
all.
Comment 31 Paolo Maggi 2004-03-27 15:57:13 UTC
*** Bug 137803 has been marked as a duplicate of this bug. ***
Comment 32 Matthias Clasen 2004-04-19 14:24:04 UTC
Created attachment 26817 [details] [review]
patch to avoid queuing too many scrolls

Here is a possible fix.
Comment 33 Paolo Maggi 2004-07-13 18:32:26 UTC
*** Bug 143122 has been marked as a duplicate of this bug. ***