Bug 443404 - Mousewheel scroll does not work in full page size and non-continous mode for some mouses
Summary: Mousewheel scroll does not work in full page size and non-continous mode for ...
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: general (show other bugs)
Version: 21.12.3
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
: 455830 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-10-06 16:28 UTC by Rafa Gallego
Modified: 2024-10-24 22:57 UTC (History)
11 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rafa Gallego 2021-10-06 16:28:48 UTC
SUMMARY

I've noticed that mousewheel scroll does not work properly in full page view and non-continous mode for some moused (at least Logitech M705, M720).

STEPS TO REPRODUCE
1. Open a multipage document in full page view and non-continous mode
2. Scroll with the mousewheel
3. 

OBSERVED RESULT

Page is not changed

EXPECTED RESULT

Move throughout the different document pages 


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.22.5
KDE Frameworks Version: 5.86.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Comment 1 Albert Astals Cid 2021-10-06 21:43:26 UTC
I don't think this is a bug, as far as I remember we never had scrollwheel changing the page, because if we do, then people complain about it because they never can read properly the end of the page because a bit more of scrollwheel changes the page.

In my opinion, at most this would be a wish, but would need some real thinking on how to implement it properly so that it's not horrible to use.
Comment 2 Laura David Hurka 2021-10-07 12:34:49 UTC
Here, scroll wheel always changed the page in non-continuous mode. If the end of the page is nearer than one scroll step, it scrolls only to the end, and the next scroll step goes to the next page.

The problem is with continuous (stepless, non-discrete) scrolling. Scrolling on one page works as expected (per-pixel scrolling), and scrolling from the end of one page to the next page requires at least 15° in one wheel event, which is awkward with continuous scrolling devices.

@Rafa: Are the mentioned mice such continuously scrolling ones?
Comment 3 Rafa Gallego 2021-10-08 09:01:14 UTC
The problem arises for both, continuous and discrete scrolling. I've been using this functionality for many years without issues. It's very useful to deal for example with PDF files with many page transitions such as the ones generated by latex and the beamer class.

Actually, the scroll takes place (full page view and continuous view) if the mousewheel is rotated very fast, but this is useless for me since I cannot control how many pages move forward or backward.
Comment 4 Laura David Hurka 2021-10-08 15:12:41 UTC
As I understand these mice, you can add/remove some part or flip a lever that makes the mouse wheel physically spin continuously or in steps. If you change only the mouse wheel to spin in steps, that is maybe not be enough, because the mouse could still sends events for every sub-step.

To check if there is confusion in this area, you can try to use the up/down arrow keys. These are handled the same way as purely discrete mouse wheel events.
Comment 5 Rafa Gallego 2021-10-08 15:16:53 UTC
(In reply to David Hurka from comment #4)
> As I understand these mice, you can add/remove some part or flip a lever
> that makes the mouse wheel physically spin continuously or in steps. If you
> change only the mouse wheel to spin in steps, that is maybe not be enough,
> because the mouse could still sends events for every sub-step.
> 
> To check if there is confusion in this area, you can try to use the up/down
> arrow keys. These are handled the same way as purely discrete mouse wheel
> events.

Up and down arrow keys work as expected so the problem might be related to my distro (Manjaro).
Comment 6 kioftes 2022-06-24 09:53:40 UTC
Same problem here  in a recent upgrade to Kubuntu jammy.
Comment 7 kioftes 2022-06-24 11:31:41 UTC
(In reply to kioftes from comment #6)
> Same problem here  in a recent upgrade to Kubuntu jammy.

Btw, I am using a wireless Logitech mouse running Okular v21.12.3. But the same happens with the touchpad of my laptop. And there is also a strange issue: if I scroll really fast (which is easier with two-finger scrolling on the touchpad) then the document scrolls, but it is not possible to control the speed of scrolling (have to scroll really fast).

Is it possible to change the category of the bug to clear the case that it affects multiple distributions and not only manjaro?
Comment 8 Laura David Hurka 2022-06-25 17:09:00 UTC
*** Bug 455830 has been marked as a duplicate of this bug. ***
Comment 9 Mark Fraser 2022-06-26 06:51:33 UTC
I tried going back to 21.12.3 in Kubuntu 22.04 from 22.04.2 and that still has issues with the mousewheel scrolling, so could something else be causing this?
Comment 10 Zack 2022-07-06 12:27:04 UTC
Same problem on my machine using Kubuntu 22.04 stock version or latest flatpak 22.04.02 version of Okula on my M720 and MX Master 3
The problem happens if the mouse is configured using libinput. And I could scroll pages if I scroll the mouse wheel really fast, but impossible to control like kioftes described.
If the mouse is configured using evdev, the scroll works as expected. It scrolls one page per one mouse scroll click. But by switching to evdev I lost the high resolution scroll capability for the whole desktop environment.
I guess this problem may be related to high resolution scroll handling.

Here is how I switch the mouse to use evdev.
Add the following lines to /etc/X11/xorg.conf
----- start here -----
Section "InputClass"
    Identifier "evdev-mouse"
    MatchIsPointer "yes"
    Driver "evdev"
EndSection
------ end here -----
Comment 11 Zack 2022-07-18 16:23:22 UTC
I looked into the source code and added few lines to the pageview.cpp to handle the small "delta" value reported in the PageView::wheelEvent for my mice. And now I could scroll in pages in full page view and non-continous mode. (only tested on libinput mode but not in evdev mode)

I don't know how I should request code change. Here's the few lines that I added. Maybe the developers see this and test it or possibly merge into the main branch.

--- okular-21.12.3/part/pageview_orig.cpp	2022-02-28 02:11:02.000000000 +0800
+++ okular-21.12.3/part/pageview.cpp	2022-07-19 00:07:04.332931401 +0800
@@ -3170,22 +3170,32 @@
     if ((e->modifiers() & Qt::ControlModifier) == Qt::ControlModifier) {
         d->controlWheelAccumulatedDelta += delta;
         if (d->controlWheelAccumulatedDelta <= -QWheelEvent::DefaultDeltasPerStep) {
             slotZoomOut();
             d->controlWheelAccumulatedDelta = 0;
         } else if (d->controlWheelAccumulatedDelta >= QWheelEvent::DefaultDeltasPerStep) {
             slotZoomIn();
             d->controlWheelAccumulatedDelta = 0;
         }
     } else {
-        d->controlWheelAccumulatedDelta = 0;
-
+        if (d->controlWheelAccumulatedDelta * delta < 0) {
+            d->controlWheelAccumulatedDelta = 0;
+        }
+        d->controlWheelAccumulatedDelta += delta;
+        if (abs(d->controlWheelAccumulatedDelta) >= QWheelEvent::DefaultDeltasPerStep){
+            delta = d->controlWheelAccumulatedDelta > 0 ? QWheelEvent::DefaultDeltasPerStep : -QWheelEvent::DefaultDeltasPerStep;
+            d->controlWheelAccumulatedDelta = 0;
+        }
+        else {
+            delta = 0;
+        }
+        
         if (delta <= -QWheelEvent::DefaultDeltasPerStep && !getContinuousMode() && vScroll == verticalScrollBar()->maximum()) {
             // go to next page
             if ((int)d->document->currentPage() < d->items.count() - 1) {
                 // more optimized than document->setNextPage and then move view to top
                 Okular::DocumentViewport newViewport = d->document->viewport();
                 newViewport.pageNumber += viewColumns();
                 if (newViewport.pageNumber >= (int)d->items.count())
                     newViewport.pageNumber = d->items.count() - 1;
                 newViewport.rePos.enabled = true;
                 newViewport.rePos.normalizedY = 0.0;
Comment 12 Albert Astals Cid 2022-07-18 20:40:42 UTC
> I don't know how I should request code change

https://community.kde.org/Infrastructure/GitLab#Submitting_a_Merge_Request
Comment 13 Bug Janitor Service 2022-07-19 07:53:11 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/okular/-/merge_requests/632
Comment 14 Bug Janitor Service 2022-09-23 15:33:53 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/okular/-/merge_requests/658
Comment 15 Martin Fernau 2022-12-21 07:48:54 UTC
I've the same problem since switching to kubuntu 22.04 (coming from 20.04)
My mouse is a logitech M720
Comment 16 Sammy Bresel 2023-01-16 20:15:19 UTC
I have the same problem using a Logitech M720.

-----
Kubuntu 22.04
KDE-Plasma-Version: 5.24.7
KDE-Frameworks-Version: 5.92.0
Qt-Version: 5.15.3
Kernel-Version: 5.15.0-58-generic (64-bit)
Comment 17 an.inbox 2023-09-07 13:56:55 UTC
Hi all, the issue is related to the use of the Logitech dongle. When using Bluetooth there is no problem.

I use the same mouse (Logitech M2S) on two machines. The laptop came first, using BT: never had a problem.
Then I installed a PC, same OS (Debian Bookworm) but I got this same issue. This PC has no BT so I used the dongle and this is when the scrolling issue in okular appeared.
If I use the dongle on the laptop, there's a problem there too.
So those you can use BT, use BT as a work-around.

So I don't know the reason for this, but the issue only comes when using the mouse with its dongle. And it's only okular having this issue, only in page mode. Okular in continuous mode or all other applications are OK.
Comment 18 Martin Fernau 2023-09-07 14:24:02 UTC
(In reply to an.inbox from comment #17)
> Hi all, the issue is related to the use of the Logitech dongle. When using
> Bluetooth there is no problem.
> 
> I use the same mouse (Logitech M2S) on two machines. The laptop came first,
> using BT: never had a problem.
> Then I installed a PC, same OS (Debian Bookworm) but I got this same issue.
> This PC has no BT so I used the dongle and this is when the scrolling issue
> in okular appeared.
> If I use the dongle on the laptop, there's a problem there too.
> So those you can use BT, use BT as a work-around.
> 
> So I don't know the reason for this, but the issue only comes when using the
> mouse with its dongle. And it's only okular having this issue, only in page
> mode. Okular in continuous mode or all other applications are OK.

That's great! I've switched to BT (never did that because of laziness) and now this annoying "bug" is gone.
Thanks for this hint!
Comment 19 Mark Fraser 2023-09-07 17:31:17 UTC
(In reply to an.inbox from comment #17)
> Hi all, the issue is related to the use of the Logitech dongle. When using
> Bluetooth there is no problem.
> 
> I use the same mouse (Logitech M2S) on two machines. The laptop came first,
> using BT: never had a problem.
> Then I installed a PC, same OS (Debian Bookworm) but I got this same issue.
> This PC has no BT so I used the dongle and this is when the scrolling issue
> in okular appeared.
> If I use the dongle on the laptop, there's a problem there too.
> So those you can use BT, use BT as a work-around.
> 
> So I don't know the reason for this, but the issue only comes when using the
> mouse with its dongle. And it's only okular having this issue, only in page
> mode. Okular in continuous mode or all other applications are OK.

Still not working properly here even with Bluetooth. I have to scroll the wheel quite a bit to get it to move to the next page.
Comment 20 an.inbox 2023-09-08 07:51:14 UTC
Hi Mark,

I bought a basic USB BT dongle before I saw your comment, and I've been lucky: okular now scrolls fine for me in page mode.

The issue is okular specific, and at the application level how the mouse is connected should not matter: the only thing the application should see are the mouse wheel events. I don't know much in this area, but I fired `xev`, a small application showing X11 events (I'm using KDE with X11). The very weird thing is that I can't see a difference: the same set of events with similar content show up when I scroll the wheel by one click, whether the mouse is connected in BT or through the Logitech dongle. But when I scroll in okular in page mode, it's completely different: perfect with BT, but mostly nothing with the dongle expect a weird jump once in a while when I scroll like mad.

I also checked the output of `xinput list-props` for both cases and except for the device name, node and product id all the other settings are the exact same.

So I'm very puzzled... Not being an expert in GUI and mouse events I don't know what to check. But I have a set-up where it's very easy to switch between OK and KO: I just need to toggle the mouse between two sources. So if someone as suggestions on what to check to understand the difference and help fix this issue, as long as it's not too complex I'll try it.
Comment 21 alexis.gm 2023-11-05 20:13:17 UTC
(In reply to an.inbox from comment #17)

Thank you for noticing that the problem seemed to be related to the mouse itself.  This okular bug has been driving me crazy for the past year or so.  I never associated the start of the issue with my purchase of a new mouse.  I currently use a Logitech MX Master 3, while before I used a MX Master 2.  

As per the suggestions in some previous comments, I tried using my new mouse with bluetooth only instead of the usb wireless dongle.  That did not fix the problem.  I still cannot scroll through a multi-page pdf document with the mousewheel when the okular view option are "single page, non-continuous".  If I scroll a lot, sometime the page will jerk forward to a new one, most of the times not.  

I also have another mouse I use for my laptop.  This is a Logitech Anywhere 2.  I tried this mouse via bluetooth and everything works perfectly.  I can scroll through the document with the mouse wheel.  In fact, I now have both mice connected via bluetooth at the same time and can test both at the same time.  I find that the mx master 3 doesn't scroll while the anywhere 2 does.
Comment 22 Marcel Oliver 2023-12-07 15:15:18 UTC
I can confirm that this is mouse-related.  Logitech Anywhere 2S works, Logitech Anywhere 3 does not, even though it worked for years.  I am using okular on Fedora Cinnamon, an update last week broke it.  As far as I can tell, the breakage was between okular 23.04.3 and 23.08.3. The issue is annoying, and specific to okular.  So even though the issue is hardware-related, it seems to me that it is okular which is buggy.
Comment 23 David Campbell 2024-04-22 07:01:34 UTC
This has just started happening for me, so it's not mouse hardware related. When on fit page the mousewheel took me to the next page; now it does not.
Comment 24 Albert Astals Cid 2024-10-24 22:57:58 UTC
Git commit 267b955b96b5f65b7259e3150f3bc7a91831da39 by Albert Astals Cid.
Committed on 24/10/2024 at 22:57.
Pushed by aacid into branch 'master'.

Fix changing between pages on SinglePage mode with "high frenequency wheel" mouses
Related: bug 494881

M  +10   -4    part/pageview.cpp

https://invent.kde.org/graphics/okular/-/commit/267b955b96b5f65b7259e3150f3bc7a91831da39