Preferences: add option to set the trackpad direction for Wayland
When using a version of Wayland that doesn't support trackpad direction show an option to set the direction manually. While this is a stop-gap measure until compositors support seat version 9, the latest GNOME doesn't yet support this, so there will be users for some years without this functionality. Addresses issue raised in #107676.
This commit is contained in:
@@ -1795,6 +1795,13 @@ class USERPREF_PT_input_touchpad(InputPanel, CenterAlignMixIn, Panel):
|
||||
col = layout.column()
|
||||
col.prop(inputs, "use_multitouch_gestures")
|
||||
|
||||
from _bpy import _wm_capabilities
|
||||
capabilities = _wm_capabilities()
|
||||
if not capabilities['TRACKPAD_PHYSICAL_DIRECTION']:
|
||||
row = col.row()
|
||||
row.active = inputs.use_multitouch_gestures
|
||||
row.prop(inputs, "touchpad_scroll_direction", text="Scroll Direction")
|
||||
|
||||
|
||||
class USERPREF_PT_input_tablet(InputPanel, CenterAlignMixIn, Panel):
|
||||
bl_label = "Tablet"
|
||||
|
||||
@@ -774,7 +774,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];
|
||||
@@ -1518,6 +1523,11 @@ typedef enum eUserpref_EmulateMMBMod {
|
||||
USER_EMU_MMB_MOD_OSKEY = 1,
|
||||
} eUserpref_EmulateMMBMod;
|
||||
|
||||
typedef enum eUserpref_TrackpadScrollDir {
|
||||
USER_TRACKPAD_SCROLL_DIR_TRADITIONAL = 0,
|
||||
USER_TRACKPAD_SCROLL_DIR_NATURAL = 1,
|
||||
} eUserpref_TrackpadScrollDir;
|
||||
|
||||
typedef enum eUserpref_DiskCacheCompression {
|
||||
USER_SEQ_DISK_CACHE_COMPRESSION_NONE = 0,
|
||||
USER_SEQ_DISK_CACHE_COMPRESSION_LOW = 1,
|
||||
|
||||
@@ -6570,6 +6570,20 @@ 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_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,23 @@ void wm_event_add_ghostevent(wmWindowManager *wm,
|
||||
event.flag |= WM_EVENT_SCROLL_INVERT;
|
||||
}
|
||||
|
||||
#if !defined(WIN32) && !defined(__APPLE__)
|
||||
/* Ensure "auto" is used when supported. */
|
||||
char trackpad_scroll_direction = U.trackpad_scroll_direction;
|
||||
if ((WM_capabilities_flag() & WM_CAPABILITY_TRACKPAD_PHYSICAL_DIRECTION) == 0) {
|
||||
switch (eUserpref_TrackpadScrollDir(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
wm_event_add_trackpad(win, &event, delta[0], delta[1]);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user