Merge lp:~evfool/pantheon-photos/lp1274815 into lp:~pantheon-photos/pantheon-photos/trunk

Proposed by Robert Roth
Status: Superseded
Proposed branch: lp:~evfool/pantheon-photos/lp1274815
Merge into: lp:~pantheon-photos/pantheon-photos/trunk
Diff against target: 37 lines (+18/-2)
1 file modified
src/Page.vala (+18/-2)
To merge this branch: bzr merge lp:~evfool/pantheon-photos/lp1274815
Reviewer Review Type Date Requested Status
Victor Martinez (community) Needs Fixing
Corentin Noël Approve
Review via email: mp+220611@code.launchpad.net

This proposal has been superseded by a proposal from 2014-05-29.

Commit message

Handle the SMOOTH_SCROLL events to enable smooth scrolling.

Description of the change

Handle the SMOOTH_SCROLL events to enable smooth scrolling.

As the per-direction mousewheel events have been propagated to subclasses, and the smooth scroll (since 3.4) can have multiple directions (see [1]), check the delta values and propagate for all directions (at most two, one vertical and one horizontal scroll).

[1] https://developer.gnome.org/gdk3/stable/gdk3-Event-Structures.html#GdkScrollDirection

To post a comment you must log in.
Revision history for this message
Corentin Noël (tintou) wrote :

Nice work, it's working as expected!

review: Approve
Revision history for this message
Victor Martinez (victored) wrote :

I'd really love to see a second iteration of this patch. This wasn't ready for merging.

1. Coding style is inconsistent with the rest of the file. Notice the space after 'get_scroll_deltas' and the unnecessary split of 'on_mousewheel_left' and 'on_mousewheel_up' to a second line. This surely looks cool in the diff, but not when you read the code as part of the whole file.

2. This patch could be smaller. Notice how the variables 'horizontal' and 'vertical' are not needed. They could have been returned right away from within their respective 'if' clauses.

PLEASE DON'T RUSH REVIEWS!

review: Needs Fixing
lp:~evfool/pantheon-photos/lp1274815 updated
2521. By Robert Roth

Fixed code style issues

Revision history for this message
Robert Roth (evfool) wrote :

Thanks Victor for your review.
I agree with point 1, have fixed it, and pushed it, spaces after function names removed, unnecessary line split removed.

With point 2. though, I'm not sure I agree or I can follow you:
In my opinion we can't return from the if cases, as we have to make sure to execute both the horizontal and the vertical scrolling (this won't happen in case of a mouse, but happens in case of a laptop touchpad in cases where we have both horizontal and vertical scrollbar). If we would return from the first if clause, we would ignore the vertical movement.

Revision history for this message
Corentin Noël (tintou) wrote :

I disagree with you Victor, new code should now follow the elementary code
style.
Le 29 mai 2014 08:24, "Robert Roth" <email address hidden> a écrit :

> Thanks Victor for your review.
> I agree with point 1, have fixed it, and pushed it, spaces after function
> names removed, unnecessary line split removed.
>
> With point 2. though, I'm not sure I agree or I can follow you:
> In my opinion we can't return from the if cases, as we have to make sure
> to execute both the horizontal and the vertical scrolling (this won't
> happen in case of a mouse, but happens in case of a laptop touchpad in
> cases where we have both horizontal and vertical scrollbar). If we would
> return from the first if clause, we would ignore the vertical movement.
> --
> https://code.launchpad.net/~evfool/pantheon-photos/lp1274815/+merge/220611
> You are reviewing the proposed merge of
> lp:~evfool/pantheon-photos/lp1274815 into lp:pantheon-photos.
>

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Page.vala'
2--- src/Page.vala 2014-04-06 11:22:49 +0000
3+++ src/Page.vala 2014-05-22 10:45:31 +0000
4@@ -174,7 +174,7 @@
5 event_source.add_events(Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK
6 | Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.POINTER_MOTION_HINT_MASK
7 | Gdk.EventMask.BUTTON_MOTION_MASK | Gdk.EventMask.LEAVE_NOTIFY_MASK
8- | Gdk.EventMask.SCROLL_MASK);
9+ | Gdk.EventMask.SCROLL_MASK | Gdk.EventMask.SMOOTH_SCROLL_MASK);
10 event_source.button_press_event.connect(on_button_pressed_internal);
11 event_source.button_release_event.connect(on_button_released_internal);
12 event_source.motion_notify_event.connect(on_motion_internal);
13@@ -1039,7 +1039,23 @@
14
15 case Gdk.ScrollDirection.RIGHT:
16 return on_mousewheel_right(event);
17-
18+
19+ case Gdk.ScrollDirection.SMOOTH:
20+ double dx, dy;
21+ bool vertical = false;
22+ bool horizontal = false;
23+ if (event.get_scroll_deltas (out dx, out dy)) {
24+ if (dx != 0) {
25+ horizontal = dx > 0 ? on_mousewheel_right (event)
26+ : on_mousewheel_left (event);
27+ }
28+ if (dy != 0) {
29+ vertical = dy > 0 ? on_mousewheel_down (event)
30+ : on_mousewheel_up (event);
31+ }
32+ return horizontal || vertical;
33+ }
34+ return false;
35 default:
36 return false;
37 }

Subscribers

People subscribed via source and target branches

to all changes: