Read the directionInvertedFromDevice property and push it to the event system.
This allows us to remove the "Trackpad Natural" use preference,
see the explanation in D8550: Trackpad: change the default of "Trackpad Natural" preference.
Differential D9402
Read the 'directionInvertedFromDevice' property and push it to the event system Authored by Yevgeny Makarov (jenkm) on Oct 31 2020, 9:54 PM. Tags Subscribers None
Details Read the directionInvertedFromDevice property and push it to the event system. This allows us to remove the "Trackpad Natural" use preference,
Diff Detail
Event TimelineComment Actions And these, I'm not sure where to put it. /** * User may change the scroll behavior, and the deltas are automatically inverted. * These functions return the absolute deltas, swipe up/right gives positive values. */ int WM_absolute_delta_x(const wmEvent *event) { int dx = event->x - event->prevx; if (!event->inverted) { dx = -dx; } return dx; } int WM_absolute_delta_y(const wmEvent *event) { int dy = event->y - event->prevy; if (!event->inverted) { dy = -dy; } return dy; } Comment Actions An automatic solution and getting rid of the preference entirely is great. These functions would go in wm_event_query.c and would have the WM_event prefix like other functions there. Comment Actions Would you prefer a different name? WM_event_absolute_scroll_delta_x(event); WM_event_absolute_delta_x(event); WM_event_abs_delta_x(event); Comment Actions The name "absolute delta" is a bit confusing, that sounds like the absolute value of a delta. I think it would be best to combine all the proposed change relates to this in one patch. This change, removal of the user preferences, and changes to operators. Because I'm confused about how it all is supposed to work together. Maybe the cleanest API would be to make wmEvent work like NSEvent. Use absolute coordinates for x, y, prevx and prevy, and then also add a deltax and deltay that may be inverted. Comment Actions Currently USER_TRACKPAD_NATURAL is only used in two places, ui_pan_to_scroll and for 3d view rotation. See in this patch. I further use it in several places in my patches, in these ways: float dx = event->prevx - event->x; if (U.uiflag2 & USER_TRACKPAD_NATURAL) { dx = -dx; } https://developer.blender.org/D8675 const int invert = (U.uiflag2 & USER_TRACKPAD_NATURAL) ? 1 : -1; const float fac = 0.005 * invert * (event->y - event->prevy); https://developer.blender.org/D8811 const bool user_zoom_invert = (U.uiflag & USER_ZOOM_INVERT) != 0; const bool user_trackpad_natural = (U.uiflag2 & USER_TRACKPAD_NATURAL) != 0; if (user_zoom_invert != user_trackpad_natural) { delta *= -1; } https://developer.blender.org/D8522
It looks good, but it will change the current behavior of the event->prevy and the delta (event->y - event->prevy), so it will need to be rechecked everywhere and replaced with event->deltay if needed. And it will break compatibility, I guess. As an alternative to the event->is_natural_direction and WM_event_natural_delta_x(), WM_event_natural_delta_y(), Comment Actions Renaming. event->is_natural_direction WM_event_natural_delta_x() WM_event_natural_delta_y() Comment Actions @Brecht Van Lommel (brecht) You might also want to take a look at how this will work for Windows. D7660 D8028 Comment Actions Ok, the current apprach is fine then if it's the simpler change overall. We can always further refactor it later. The patch looks good from a quick glance at the code, but I need to test it still. |