Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/interface/interface_handlers.c6
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c2
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c7
-rw-r--r--source/blender/windowmanager/WM_api.h3
-rw-r--r--source/blender/windowmanager/WM_types.h4
-rw-r--r--source/blender/windowmanager/intern/wm_event_query.c32
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c3
8 files changed, 45 insertions, 14 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index fb5844d24f3..af71306cc3b 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -504,7 +504,7 @@ bool ui_but_is_editing(const uiBut *but)
void ui_pan_to_scroll(const wmEvent *event, int *type, int *val)
{
static int lastdy = 0;
- int dy = event->prevy - event->y;
+ int dy = WM_event_absolute_delta_y(event);
/* This event should be originally from event->type,
* converting wrong event into wheel is bad, see T33803. */
@@ -518,10 +518,6 @@ void ui_pan_to_scroll(const wmEvent *event, int *type, int *val)
lastdy += dy;
if (abs(lastdy) > (int)UI_UNIT_Y) {
- if (U.uiflag2 & USER_TRACKPAD_NATURAL) {
- dy = -dy;
- }
-
*val = KM_PRESS;
if (dy > 0) {
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index c16cd94d90d..f9de462813f 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -998,7 +998,7 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, const wmEvent *event)
int event_xy[2];
if (event->type == MOUSEPAN) {
- if (U.uiflag2 & USER_TRACKPAD_NATURAL) {
+ if (event->is_direction_inverted) {
event_xy[0] = 2 * event->x - event->prevx;
event_xy[1] = 2 * event->y - event->prevy;
}
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index a9bd915ba48..f673b193a39 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -1073,7 +1073,7 @@ typedef enum eUserpref_UI_Flag {
typedef enum eUserpref_UI_Flag2 {
USER_UIFLAG2_UNUSED_0 = (1 << 0), /* cleared */
USER_REGION_OVERLAP = (1 << 1),
- USER_TRACKPAD_NATURAL = (1 << 2),
+ USER_UIFLAG2_UNUSED_2 = (1 << 2),
USER_UIFLAG2_UNUSED_3 = (1 << 3), /* dirty */
} eUserpref_UI_Flag2;
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 2ae084d5a5d..1bfa8547ca4 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -5936,13 +5936,6 @@ static void rna_def_userdef_input(BlenderRNA *brna)
RNA_def_property_range(prop, 0, 32);
RNA_def_property_ui_text(
prop, "Wheel Scroll Lines", "Number of lines scrolled at a time with the mouse wheel");
-
- prop = RNA_def_property(srna, "use_trackpad_natural", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "uiflag2", USER_TRACKPAD_NATURAL);
- RNA_def_property_ui_text(prop,
- "Trackpad Natural",
- "If your system uses 'natural' scrolling, this option keeps consistent "
- "trackpad usage throughout the UI");
}
static void rna_def_userdef_keymap(BlenderRNA *brna)
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index b81ef14f21c..fd0b99fb9ae 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -857,6 +857,9 @@ void WM_event_ndof_to_quat(const struct wmNDOFMotionData *ndof, float q[4]);
float WM_event_tablet_data(const struct wmEvent *event, int *pen_flip, float tilt[2]);
bool WM_event_is_tablet(const struct wmEvent *event);
+int WM_event_absolute_delta_x(const struct wmEvent *event);
+int WM_event_absolute_delta_y(const struct wmEvent *event);
+
#ifdef WITH_INPUT_IME
bool WM_event_is_ime_switch(const struct wmEvent *event);
#endif
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index a8d24205268..7fa2851cbf3 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -595,6 +595,10 @@ typedef struct wmEvent {
/** Ascii, unicode, mouse coords, angles, vectors, dragdrop info. */
void *customdata;
+ /* True if the operating system inverted the delta x/y values and resulting
+ * prev x/y values, for natural scroll direction. For absolute scroll direction,
+ * the delta must be negated again. */
+ char is_direction_inverted;
} wmEvent;
/**
diff --git a/source/blender/windowmanager/intern/wm_event_query.c b/source/blender/windowmanager/intern/wm_event_query.c
index db80296bdb8..a996796104b 100644
--- a/source/blender/windowmanager/intern/wm_event_query.c
+++ b/source/blender/windowmanager/intern/wm_event_query.c
@@ -423,6 +423,38 @@ bool WM_event_is_tablet(const struct wmEvent *event)
/** \} */
/* -------------------------------------------------------------------- */
+/** \name Event Scroll's Absolute Deltas
+ *
+ * User may change the scroll behavior, and the deltas are automatically inverted.
+ * These functions return the absolute direction, swipe up/right gives positive values.
+ *
+ * \{ */
+
+int WM_event_absolute_delta_x(const struct wmEvent *event)
+{
+ int dx = event->x - event->prevx;
+
+ if (!event->is_direction_inverted) {
+ dx = -dx;
+ }
+
+ return dx;
+}
+
+int WM_event_absolute_delta_y(const struct wmEvent *event)
+{
+ int dy = event->y - event->prevy;
+
+ if (!event->is_direction_inverted) {
+ dy = -dy;
+ }
+
+ return dy;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Event IME Input Access
* \{ */
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 071951abda3..bf970aa2034 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -4397,6 +4397,9 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
event.prevx = event.x - pd->deltaX;
event.prevy = event.y - (-pd->deltaY);
+ /* The direction is inverted from the device due to system preferences. */
+ event.is_direction_inverted = pd->isDirectionInverted;
+
wm_event_add(win, &event);
break;
}