WM: add preference for wayland to force the scroll direction on Wayland #120563
|
@ -1788,6 +1788,10 @@ class USERPREF_PT_input_touchpad(InputPanel, CenterAlignMixIn, Panel):
|
|||
col = layout.column()
|
||||
col.prop(inputs, "use_multitouch_gestures")
|
||||
|
||||
from _bpy import _ghost_backend
|
||||
if _ghost_backend() == 'WAYLAND':
|
||||
col.prop(inputs, "touchpad_scroll_direction", text="Scroll Direction")
|
||||
|
||||
|
||||
class USERPREF_PT_input_tablet(InputPanel, CenterAlignMixIn, Panel):
|
||||
bl_label = "Tablet"
|
||||
|
|
|
@ -775,7 +775,12 @@ typedef struct UserDef {
|
|||
char pref_flag;
|
||||
char savetime;
|
||||
char mouse_emulate_3_button_modifier;
|
||||
char _pad4[1];
|
||||
/**
|
||||
* Workaround for WAYLAND (at time of writing compositors don't support this info).
|
||||
* #eUserpref_TrackpadScrollDir type
|
||||
* TODO: Remove this once this API is better supported by Wayland compositors, see #107676.
|
||||
*/
|
||||
char trackpad_scroll_direction;
|
||||
/** FILE_MAXDIR length. */
|
||||
char tempdir[768];
|
||||
char fontdir[768];
|
||||
|
@ -1519,6 +1524,12 @@ typedef enum eUserpref_EmulateMMBMod {
|
|||
USER_EMU_MMB_MOD_OSKEY = 1,
|
||||
} eUserpref_EmulateMMBMod;
|
||||
|
||||
typedef enum eUserpref_TrackpadScrollDir {
|
||||
USER_TRACKPAD_SCROLL_DIR_AUTO = 0,
|
||||
USER_TRACKPAD_SCROLL_DIR_TRADITIONAL = 1,
|
||||
USER_TRACKPAD_SCROLL_DIR_NATURAL = 2,
|
||||
} eUserpref_TrackpadScrollDir;
|
||||
|
||||
typedef enum eUserpref_DiskCacheCompression {
|
||||
USER_SEQ_DISK_CACHE_COMPRESSION_NONE = 0,
|
||||
USER_SEQ_DISK_CACHE_COMPRESSION_LOW = 1,
|
||||
|
|
|
@ -6546,6 +6546,25 @@ static void rna_def_userdef_input(BlenderRNA *brna)
|
|||
prop = RNA_def_property(srna, "invert_zoom_wheel", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "uiflag", USER_WHEELZOOMDIR);
|
||||
RNA_def_property_ui_text(prop, "Wheel Invert Zoom", "Swap the Mouse Wheel zoom direction");
|
||||
|
||||
static const EnumPropertyItem touchpad_scroll_direction_items[] = {
|
||||
{USER_TRACKPAD_SCROLL_DIR_AUTO,
|
||||
"AUTO",
|
||||
0,
|
||||
"Automatic",
|
||||
"Rely on the systems scroll directly (when supported)"},
|
||||
{USER_TRACKPAD_SCROLL_DIR_TRADITIONAL,
|
||||
"TRADITIONAL",
|
||||
0,
|
||||
"Traditional",
|
||||
"Traditional scroll direction"},
|
||||
{USER_TRACKPAD_SCROLL_DIR_NATURAL, "NATURAL", 0, "Natural", "Natural scroll direction"},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
prop = RNA_def_property(srna, "touchpad_scroll_direction", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, nullptr, "trackpad_scroll_direction");
|
||||
RNA_def_property_enum_items(prop, touchpad_scroll_direction_items);
|
||||
RNA_def_property_ui_text(prop, "Touchpad Scroll Direction", "Scroll direction (Wayland only)");
|
||||
}
|
||||
|
||||
static void rna_def_userdef_keymap(BlenderRNA *brna)
|
||||
|
|
|
@ -5632,6 +5632,22 @@ void wm_event_add_ghostevent(wmWindowManager *wm,
|
|||
event.flag |= WM_EVENT_SCROLL_INVERT;
|
||||
}
|
||||
|
||||
#if !defined(WIN32) && !defined(__APPLE__)
|
||||
switch (eUserpref_TrackpadScrollDir(U.trackpad_scroll_direction)) {
|
||||
case USER_TRACKPAD_SCROLL_DIR_TRADITIONAL: {
|
||||
event.flag &= ~WM_EVENT_SCROLL_INVERT;
|
||||
break;
|
||||
}
|
||||
case USER_TRACKPAD_SCROLL_DIR_NATURAL: {
|
||||
event.flag |= WM_EVENT_SCROLL_INVERT;
|
||||
break;
|
||||
}
|
||||
case USER_TRACKPAD_SCROLL_DIR_AUTO: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
wm_event_add_trackpad(win, &event, delta[0], delta[1]);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue