babluboy / bookworm

A simple ebook reader for Elementary OS
GNU General Public License v3.0
1.32k stars 100 forks source link

Feature request: touch gesture support #272

Closed mnussbaum closed 4 years ago

mnussbaum commented 5 years ago

Hi there, just wanted to start by saying how much I appreciate bookworm! It's quickly become my preferred epub reader on linux, so thank you for all your efforts!

One feature that would be really helpful for users with touchscreens is touch gesture support. I'm imagining a finger-swipe to trigger a page turn as the primary gesture to support. For context, I often use a 2-in-1 style laptop in tablet mode with the keyboard folded back behind the screen. It's possible to use the current on-screen arrow buttons to flip pages, but they're a bit too small to hit comfortably using fingers (though fine with mouse) so a touch friendly input method like gestures would be real usability win in this mode.

Thanks for your consideration!

babluboy commented 5 years ago

@mnussbaum Many thanks for your interest in bookworm and for raising this request. I had not thought about touchscreens so far but I realize with the advent of the 2-in-1 laptops, many users will have Bookworm on touchscreens.

It should be relatively simple to have an area on the middle of the left side and the middle of the right side to to go back a page or move forward respectively. This will solve the main problem of moving the pages, after which I can think of other gestures.

Since I dont have a touchscreen, it will be great if I can ask you to build from source, when I have the code ready so that we can test the change before I release the same generally on Appcenter

babluboy commented 5 years ago

Also, how does the shortcut like the forward button and backward button work on touchscreen ? Will be good to know the behaviour of shortcuts on touchscreen so that all the shortcuts I have defined (link below) can be useful for touchscreen: https://babluboy.github.io/bookworm/#shortcuts

mnussbaum commented 5 years ago

Thanks for getting back to me! I'm more than happy to compile and run bookworm on a touch screen to do some testing.

I think tap areas on the sides sounds like a really nice initial implementation. My only concern would be making sure it doesn't cause too many accidental page turns if I'm holding the side of the tablet with a thumb or something on top of the tablet on the screen. Not sure if that's a realistic concern or not but it's something I can look for during testing.

The shortcuts should be useful in tablet mode, but in my case at least would depend on having virtboard, a virtual keyboard open. In my case the virtual keyboard takes up a fair bit of screen space so I prefer to keep it closed but I'm sure I could make it easier to quickly open and close the virtual keyboard in my setup. I can confirm the shortcuts work with a virtual keyboard sometime this evening

mnussbaum commented 5 years ago

Forward and back buttons both work correctly for me in tablet mode with a virtual keyboard up, so that already makes bookworm a bit more useful for me in tablet mode, thanks for the pointer!

My virtboard installation seems to be a little buggy and doesn't handle holding down super or ctrl keys in any program at all so I can't confirm shortcuts using them work, but I would be hopeful they do on a working virtual keyboard given the arrow keys work.

If it's helpful context, I'm using bookworm on wayland with sway

babluboy commented 4 years ago

Thanks for the update, yes if the arrow keys work then the other shortcuts would be working as well. I need to work out how to capture mouse events only if they are near the left and right edges so that I can check if they are right click events and move the pages backward or forward... Will update back when I have got some code to test

babluboy commented 4 years ago

@mnussbaum I have pushed a change to navigate the pages when the screen is clicked near the left and right edges of the page. The area for clicking near the left and right edges is set to 5% of the screen width.

It will be great if you can build from source to check this fix on your touch screen

mnussbaum commented 4 years ago

Thanks for working on this! I just tested and it seems to work for mouse clicks, but for some reason not with finger taps. I added some debug logging and the web view's button press callback isn't getting triggered even if I tap in the same place a click works.

I was actually looking into this myself a couple days ago and am trying to integrate GtkGestureSwipe, might be able to get a PR out in a couple more days if that approach is interesting to you!

mnussbaum commented 4 years ago

I've opened #287 to add swipe gesture support for page flip! I've been able to test this and confirm it works as hoped