diff --git a/meson.build b/meson.build index 8c5932cc6..4721b1c4c 100644 --- a/meson.build +++ b/meson.build @@ -49,7 +49,7 @@ wayland_server_req = '>= 1.23' wayland_protocols_req = '>= 1.36' # native backend version requirements -libinput_req = '>= 1.19.0' +libinput_req = '>= 1.26.0' gbm_req = '>= 21.3' libdrm_req = '>= 2.4.118' diff --git a/src/backends/meta-input-settings-dummy.c b/src/backends/meta-input-settings-dummy.c index 1fde1abfd..2abac0569 100644 --- a/src/backends/meta-input-settings-dummy.c +++ b/src/backends/meta-input-settings-dummy.c @@ -188,7 +188,8 @@ static void meta_input_settings_dummy_set_stylus_pressure (MetaInputSettings *settings, ClutterInputDevice *device, ClutterInputDeviceTool *tool, - const gint32 curve[4]) + const gint32 curve[4], + const gdouble range[2]) { } diff --git a/src/backends/meta-input-settings-private.h b/src/backends/meta-input-settings-private.h index 9dcb3816f..bb1e4bbb4 100644 --- a/src/backends/meta-input-settings-private.h +++ b/src/backends/meta-input-settings-private.h @@ -139,7 +139,8 @@ struct _MetaInputSettingsClass void (* set_stylus_pressure) (MetaInputSettings *settings, ClutterInputDevice *device, ClutterInputDeviceTool *tool, - const gint32 curve[4]); + const gint32 curve[4], + const gdouble range[2]); void (* set_stylus_button_map) (MetaInputSettings *settings, ClutterInputDevice *device, ClutterInputDeviceTool *tool, diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c index e3a1ed1f7..dd03e66b9 100644 --- a/src/backends/meta-input-settings.c +++ b/src/backends/meta-input-settings.c @@ -1562,6 +1562,8 @@ update_stylus_pressure (MetaInputSettings *input_settings, MetaInputSettingsClass *input_settings_class; GSettings *tool_settings; const gint32 *curve; + const guint32 *percent; + gdouble range[2]; GVariant *variant; gsize n_elems; @@ -1584,8 +1586,24 @@ update_stylus_pressure (MetaInputSettings *input_settings, if (n_elems != 4) return; + if (clutter_input_device_tool_get_tool_type (tool) == + CLUTTER_INPUT_DEVICE_TOOL_ERASER) + variant = g_settings_get_value (tool_settings, "eraser-pressure-range"); + else + variant = g_settings_get_value (tool_settings, "pressure-range"); + + percent = g_variant_get_fixed_array (variant, &n_elems, sizeof (guint32)); + if (n_elems != 2) + return; + + range[0] = CLAMP (percent[0] / 100.0, 0.0, 1.0); + range[1] = CLAMP (percent[1] / 100.0, 0.0, 1.0); + + if (range[0] >= range[1]) + return; + input_settings_class = META_INPUT_SETTINGS_GET_CLASS (input_settings); - input_settings_class->set_stylus_pressure (input_settings, device, tool, curve); + input_settings_class->set_stylus_pressure (input_settings, device, tool, curve, range); } static void diff --git a/src/backends/native/meta-input-device-tool-native.c b/src/backends/native/meta-input-device-tool-native.c index 3efa0b201..fe007a304 100644 --- a/src/backends/native/meta-input-device-tool-native.c +++ b/src/backends/native/meta-input-device-tool-native.c @@ -117,7 +117,8 @@ meta_input_device_tool_native_new (struct libinput_tablet_tool *tool, void meta_input_device_tool_native_set_pressure_curve_in_impl (ClutterInputDeviceTool *tool, - double curve[4]) + double curve[4], + double range[2]) { MetaInputDeviceToolNative *evdev_tool; graphene_point_t p1, p2; @@ -141,6 +142,8 @@ meta_input_device_tool_native_set_pressure_curve_in_impl (ClutterInputDeviceTool evdev_tool->pressure_curve[1] = p2; init_pressurecurve (evdev_tool); } + + libinput_tablet_tool_config_pressure_range_set (evdev_tool->tool, range[0], range[1]); } void diff --git a/src/backends/native/meta-input-device-tool-native.h b/src/backends/native/meta-input-device-tool-native.h index 72fff25ef..8b26b573a 100644 --- a/src/backends/native/meta-input-device-tool-native.h +++ b/src/backends/native/meta-input-device-tool-native.h @@ -53,7 +53,8 @@ GDesktopStylusButtonAction meta_input_device_tool_native_get_button_code_in_impl uint32_t button); void meta_input_device_tool_native_set_pressure_curve_in_impl (ClutterInputDeviceTool *tool, - double curve[4]); + double curve[4], + double range[2]); void meta_input_device_tool_native_set_button_code_in_impl (ClutterInputDeviceTool *tool, uint32_t button, GDesktopStylusButtonAction evcode); diff --git a/src/backends/native/meta-input-settings-native.c b/src/backends/native/meta-input-settings-native.c index 4e05788c1..c14175400 100644 --- a/src/backends/native/meta-input-settings-native.c +++ b/src/backends/native/meta-input-settings-native.c @@ -696,16 +696,21 @@ static void meta_input_settings_native_set_stylus_pressure (MetaInputSettings *settings, ClutterInputDevice *device, ClutterInputDeviceTool *tool, - const gint curve[4]) + const gint curve[4], + const gdouble range[2]) { gdouble pressure_curve[4]; + gdouble pressure_range[2]; pressure_curve[0] = (gdouble) curve[0] / 100; pressure_curve[1] = (gdouble) curve[1] / 100; pressure_curve[2] = (gdouble) curve[2] / 100; pressure_curve[3] = (gdouble) curve[3] / 100; - meta_input_device_tool_native_set_pressure_curve_in_impl (tool, pressure_curve); + pressure_range[0] = (gdouble) range[0]; + pressure_range[1] = (gdouble) range[1]; + + meta_input_device_tool_native_set_pressure_curve_in_impl (tool, pressure_curve, pressure_range); } static void diff --git a/src/backends/x11/meta-input-settings-x11.c b/src/backends/x11/meta-input-settings-x11.c index c845d1e5e..3225cef0c 100644 --- a/src/backends/x11/meta-input-settings-x11.c +++ b/src/backends/x11/meta-input-settings-x11.c @@ -892,12 +892,19 @@ static void meta_input_settings_x11_set_stylus_pressure (MetaInputSettings *settings, ClutterInputDevice *device, ClutterInputDeviceTool *tool, - const gint32 pressure[4]) + const gint32 pressure[4], + const gdouble range[2]) { guint32 values[4] = { pressure[0], pressure[1], pressure[2], pressure[3] }; + guint32 threshold = (guint32) MAX (2048 * range[0], 1.0); change_property (settings, device, "Wacom Pressurecurve", XA_INTEGER, 32, &values, G_N_ELEMENTS (values)); + + /* The wacom driver doesn't have a full equivalent to the pressure range. + * Threshold only applies to the tip down event but that's better than nothing */ + change_property (settings, device, "Wacom Pressure Threshold", XA_INTEGER, 32, + &threshold, 1); } static void