clutter/evdev: Take over stylus configuration

Stylus configuration (stylus buttons, pressure) was handled
at the very high level, doing the button and pressure translations
right before sending these to wayland clients.

However, it makes more sense to store these settings into the
ClutterInputDeviceTool itself, and have clutter apply the config
at the lower level so 1) the settings actually apply desktop-wide,
not just in clients and 2) X11 and wayland may share similar
configuration paths. The settings are now just applied whenever
the tool enters proximity, in reaction to
ClutterDeviceManager::tool-changed.

This commit moves all handling of these two settings to
the clutter level, and removes the wayland-specific paths

https://bugzilla.gnome.org/show_bug.cgi?id=773779
This commit is contained in:
Carlos Garnacho
2016-10-31 17:43:38 +01:00
parent 75c3f0ffba
commit b252771a8f
9 changed files with 291 additions and 157 deletions

View File

@ -24,6 +24,7 @@
#include "config.h"
#include <clutter/evdev/clutter-evdev.h>
#include <linux/input-event-codes.h>
#include <libinput.h>
#include "meta-input-settings-native.h"
@ -395,6 +396,54 @@ meta_input_settings_native_set_tablet_area (MetaInputSettings *settings,
/* FIXME: Implement */
}
static void
meta_input_settings_native_set_stylus_pressure (MetaInputSettings *settings,
ClutterInputDevice *device,
ClutterInputDeviceTool *tool,
const gint curve[4])
{
gdouble pressure_curve[4];
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;
clutter_evdev_input_device_tool_set_pressure_curve (tool, pressure_curve);
}
static guint
action_to_evcode (GDesktopStylusButtonAction action)
{
switch (action)
{
case G_DESKTOP_STYLUS_BUTTON_ACTION_MIDDLE:
return BTN_STYLUS;
case G_DESKTOP_STYLUS_BUTTON_ACTION_RIGHT:
return BTN_STYLUS2;
case G_DESKTOP_STYLUS_BUTTON_ACTION_BACK:
return BTN_BACK;
case G_DESKTOP_STYLUS_BUTTON_ACTION_FORWARD:
return BTN_FORWARD;
case G_DESKTOP_STYLUS_BUTTON_ACTION_DEFAULT:
default:
return 0;
}
}
static void
meta_input_settings_native_set_stylus_button_map (MetaInputSettings *settings,
ClutterInputDevice *device,
ClutterInputDeviceTool *tool,
GDesktopStylusButtonAction primary,
GDesktopStylusButtonAction secondary)
{
clutter_evdev_input_device_tool_set_button_code (tool, CLUTTER_BUTTON_MIDDLE,
action_to_evcode (primary));
clutter_evdev_input_device_tool_set_button_code (tool, CLUTTER_BUTTON_SECONDARY,
action_to_evcode (secondary));
}
static void
meta_input_settings_native_class_init (MetaInputSettingsNativeClass *klass)
{
@ -418,6 +467,9 @@ meta_input_settings_native_class_init (MetaInputSettingsNativeClass *klass)
input_settings_class->set_mouse_accel_profile = meta_input_settings_native_set_mouse_accel_profile;
input_settings_class->set_trackball_accel_profile = meta_input_settings_native_set_trackball_accel_profile;
input_settings_class->set_stylus_pressure = meta_input_settings_native_set_stylus_pressure;
input_settings_class->set_stylus_button_map = meta_input_settings_native_set_stylus_button_map;
}
static void