mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
input-settings: Wire up middle-emulation
This allows emulating middle click via simultaneous left and right click. Fixes #238. https://gitlab.gnome.org/GNOME/mutter/merge_requests/256
This commit is contained in:
parent
23da6c2426
commit
0487e6f11f
@ -114,6 +114,17 @@ struct _MetaInputSettingsClass
|
|||||||
GDesktopStylusButtonAction primary,
|
GDesktopStylusButtonAction primary,
|
||||||
GDesktopStylusButtonAction secondary,
|
GDesktopStylusButtonAction secondary,
|
||||||
GDesktopStylusButtonAction tertiary);
|
GDesktopStylusButtonAction tertiary);
|
||||||
|
|
||||||
|
void (* set_mouse_middle_click_emulation) (MetaInputSettings *settings,
|
||||||
|
ClutterInputDevice *device,
|
||||||
|
gboolean enabled);
|
||||||
|
void (* set_touchpad_middle_click_emulation) (MetaInputSettings *settings,
|
||||||
|
ClutterInputDevice *device,
|
||||||
|
gboolean enabled);
|
||||||
|
void (* set_trackball_middle_click_emulation) (MetaInputSettings *settings,
|
||||||
|
ClutterInputDevice *device,
|
||||||
|
gboolean enabled);
|
||||||
|
|
||||||
gboolean (* has_two_finger_scroll) (MetaInputSettings *settings,
|
gboolean (* has_two_finger_scroll) (MetaInputSettings *settings,
|
||||||
ClutterInputDevice *device);
|
ClutterInputDevice *device);
|
||||||
gboolean (* is_trackball_device) (MetaInputSettings *settings,
|
gboolean (* is_trackball_device) (MetaInputSettings *settings,
|
||||||
|
@ -418,6 +418,39 @@ get_settings_for_device_type (MetaInputSettings *input_settings,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_middle_click_emulation (MetaInputSettings *input_settings,
|
||||||
|
GSettings *settings,
|
||||||
|
ClutterInputDevice *device)
|
||||||
|
{
|
||||||
|
ConfigBoolFunc func;
|
||||||
|
const gchar *key = "emulate-middle";
|
||||||
|
MetaInputSettingsPrivate *priv = meta_input_settings_get_instance_private (input_settings);
|
||||||
|
|
||||||
|
if (!settings)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (settings == priv->mouse_settings)
|
||||||
|
func = META_INPUT_SETTINGS_GET_CLASS (input_settings)->set_mouse_middle_click_emulation;
|
||||||
|
else if (settings == priv->touchpad_settings)
|
||||||
|
func = META_INPUT_SETTINGS_GET_CLASS (input_settings)->set_touchpad_middle_click_emulation;
|
||||||
|
else if (settings == priv->trackball_settings)
|
||||||
|
func = META_INPUT_SETTINGS_GET_CLASS (input_settings)->set_trackball_middle_click_emulation;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (device)
|
||||||
|
{
|
||||||
|
settings_device_set_bool_setting (input_settings, device, func,
|
||||||
|
g_settings_get_boolean (settings, key));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
settings_set_bool_setting (input_settings, CLUTTER_POINTER_DEVICE, func,
|
||||||
|
g_settings_get_boolean (settings, key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_device_speed (MetaInputSettings *input_settings,
|
update_device_speed (MetaInputSettings *input_settings,
|
||||||
ClutterInputDevice *device)
|
ClutterInputDevice *device)
|
||||||
@ -1141,6 +1174,8 @@ meta_input_settings_changed_cb (GSettings *settings,
|
|||||||
update_device_natural_scroll (input_settings, NULL);
|
update_device_natural_scroll (input_settings, NULL);
|
||||||
else if (strcmp (key, "accel-profile") == 0)
|
else if (strcmp (key, "accel-profile") == 0)
|
||||||
update_pointer_accel_profile (input_settings, settings, NULL);
|
update_pointer_accel_profile (input_settings, settings, NULL);
|
||||||
|
else if (strcmp (key, "middle-click-emulation") == 0)
|
||||||
|
update_middle_click_emulation (input_settings, settings, NULL);
|
||||||
}
|
}
|
||||||
else if (settings == priv->touchpad_settings)
|
else if (settings == priv->touchpad_settings)
|
||||||
{
|
{
|
||||||
@ -1164,6 +1199,8 @@ meta_input_settings_changed_cb (GSettings *settings,
|
|||||||
update_touchpad_two_finger_scroll (input_settings, NULL);
|
update_touchpad_two_finger_scroll (input_settings, NULL);
|
||||||
else if (strcmp (key, "click-method") == 0)
|
else if (strcmp (key, "click-method") == 0)
|
||||||
update_touchpad_click_method (input_settings, NULL);
|
update_touchpad_click_method (input_settings, NULL);
|
||||||
|
else if (strcmp (key, "middle-click-emulation") == 0)
|
||||||
|
update_middle_click_emulation (input_settings, settings, NULL);
|
||||||
}
|
}
|
||||||
else if (settings == priv->trackball_settings)
|
else if (settings == priv->trackball_settings)
|
||||||
{
|
{
|
||||||
@ -1171,6 +1208,8 @@ meta_input_settings_changed_cb (GSettings *settings,
|
|||||||
update_trackball_scroll_button (input_settings, NULL);
|
update_trackball_scroll_button (input_settings, NULL);
|
||||||
else if (strcmp (key, "accel-profile") == 0)
|
else if (strcmp (key, "accel-profile") == 0)
|
||||||
update_pointer_accel_profile (input_settings, settings, NULL);
|
update_pointer_accel_profile (input_settings, settings, NULL);
|
||||||
|
else if (strcmp (key, "middle-click-emulation") == 0)
|
||||||
|
update_middle_click_emulation (input_settings, settings, NULL);
|
||||||
}
|
}
|
||||||
else if (settings == priv->keyboard_settings)
|
else if (settings == priv->keyboard_settings)
|
||||||
{
|
{
|
||||||
@ -1687,6 +1726,10 @@ apply_device_settings (MetaInputSettings *input_settings,
|
|||||||
device);
|
device);
|
||||||
load_keyboard_a11y_settings (input_settings, device);
|
load_keyboard_a11y_settings (input_settings, device);
|
||||||
load_pointer_a11y_settings (input_settings, device);
|
load_pointer_a11y_settings (input_settings, device);
|
||||||
|
|
||||||
|
update_middle_click_emulation (input_settings, priv->mouse_settings, device);
|
||||||
|
update_middle_click_emulation (input_settings, priv->touchpad_settings, device);
|
||||||
|
update_middle_click_emulation (input_settings, priv->trackball_settings, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -400,6 +400,13 @@ is_mouse_device (ClutterInputDevice *device)
|
|||||||
!has_udev_property (device, "ID_INPUT_POINTINGSTICK"));
|
!has_udev_property (device, "ID_INPUT_POINTINGSTICK"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
meta_input_settings_native_is_touchpad_device (MetaInputSettings *settings,
|
||||||
|
ClutterInputDevice *device)
|
||||||
|
{
|
||||||
|
return has_udev_property (device, "ID_INPUT_TOUCHPAD");
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
meta_input_settings_native_is_trackball_device (MetaInputSettings *settings,
|
meta_input_settings_native_is_trackball_device (MetaInputSettings *settings,
|
||||||
ClutterInputDevice *device)
|
ClutterInputDevice *device)
|
||||||
@ -562,6 +569,60 @@ meta_input_settings_native_set_stylus_button_map (MetaInputSettings *se
|
|||||||
action_to_evcode (tertiary));
|
action_to_evcode (tertiary));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_input_settings_native_set_mouse_middle_click_emulation (MetaInputSettings *settings,
|
||||||
|
ClutterInputDevice *device,
|
||||||
|
gboolean enabled)
|
||||||
|
{
|
||||||
|
struct libinput_device *libinput_device;
|
||||||
|
|
||||||
|
if (!is_mouse_device (device))
|
||||||
|
return;
|
||||||
|
|
||||||
|
libinput_device = meta_input_device_native_get_libinput_device (device);
|
||||||
|
if (!libinput_device)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (libinput_device_config_middle_emulation_is_available (libinput_device))
|
||||||
|
libinput_device_config_middle_emulation_set_enabled (libinput_device, enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_input_settings_native_set_touchpad_middle_click_emulation (MetaInputSettings *settings,
|
||||||
|
ClutterInputDevice *device,
|
||||||
|
gboolean enabled)
|
||||||
|
{
|
||||||
|
struct libinput_device *libinput_device;
|
||||||
|
|
||||||
|
if (!meta_input_settings_native_is_touchpad_device (settings, device))
|
||||||
|
return;
|
||||||
|
|
||||||
|
libinput_device = meta_input_device_native_get_libinput_device (device);
|
||||||
|
if (!libinput_device)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (libinput_device_config_middle_emulation_is_available (libinput_device))
|
||||||
|
libinput_device_config_middle_emulation_set_enabled (libinput_device, enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_input_settings_native_set_trackball_middle_click_emulation (MetaInputSettings *settings,
|
||||||
|
ClutterInputDevice *device,
|
||||||
|
gboolean enabled)
|
||||||
|
{
|
||||||
|
struct libinput_device *libinput_device;
|
||||||
|
|
||||||
|
if (!meta_input_settings_native_is_trackball_device (settings, device))
|
||||||
|
return;
|
||||||
|
|
||||||
|
libinput_device = meta_input_device_native_get_libinput_device (device);
|
||||||
|
if (!libinput_device)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (libinput_device_config_middle_emulation_is_available (libinput_device))
|
||||||
|
libinput_device_config_middle_emulation_set_enabled (libinput_device, enabled);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_input_settings_native_class_init (MetaInputSettingsNativeClass *klass)
|
meta_input_settings_native_class_init (MetaInputSettingsNativeClass *klass)
|
||||||
{
|
{
|
||||||
@ -591,6 +652,10 @@ meta_input_settings_native_class_init (MetaInputSettingsNativeClass *klass)
|
|||||||
input_settings_class->set_stylus_pressure = meta_input_settings_native_set_stylus_pressure;
|
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;
|
input_settings_class->set_stylus_button_map = meta_input_settings_native_set_stylus_button_map;
|
||||||
|
|
||||||
|
input_settings_class->set_mouse_middle_click_emulation = meta_input_settings_native_set_mouse_middle_click_emulation;
|
||||||
|
input_settings_class->set_touchpad_middle_click_emulation = meta_input_settings_native_set_touchpad_middle_click_emulation;
|
||||||
|
input_settings_class->set_trackball_middle_click_emulation = meta_input_settings_native_set_trackball_middle_click_emulation;
|
||||||
|
|
||||||
input_settings_class->has_two_finger_scroll = meta_input_settings_native_has_two_finger_scroll;
|
input_settings_class->has_two_finger_scroll = meta_input_settings_native_has_two_finger_scroll;
|
||||||
input_settings_class->is_trackball_device = meta_input_settings_native_is_trackball_device;
|
input_settings_class->is_trackball_device = meta_input_settings_native_is_trackball_device;
|
||||||
}
|
}
|
||||||
|
@ -512,6 +512,13 @@ is_mouse (MetaInputSettings *settings,
|
|||||||
!has_udev_property (settings, device, "ID_INPUT_POINTINGSTICK"));
|
!has_udev_property (settings, device, "ID_INPUT_POINTINGSTICK"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
meta_input_settings_x11_is_touchpad_device (MetaInputSettings *settings,
|
||||||
|
ClutterInputDevice *device)
|
||||||
|
{
|
||||||
|
return has_udev_property (settings, device, "ID_INPUT_TOUCHPAD");
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
meta_input_settings_x11_is_trackball_device (MetaInputSettings *settings,
|
meta_input_settings_x11_is_trackball_device (MetaInputSettings *settings,
|
||||||
ClutterInputDevice *device)
|
ClutterInputDevice *device)
|
||||||
@ -820,6 +827,48 @@ meta_input_settings_x11_set_stylus_button_map (MetaInputSettings *setti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_input_settings_x11_set_mouse_middle_click_emulation (MetaInputSettings *settings,
|
||||||
|
ClutterInputDevice *device,
|
||||||
|
gboolean enabled)
|
||||||
|
{
|
||||||
|
guchar value = enabled ? 1 : 0;
|
||||||
|
|
||||||
|
if (!is_mouse (settings, device))
|
||||||
|
return;
|
||||||
|
|
||||||
|
change_property (device, "libinput Middle Click Emulation Enabled",
|
||||||
|
XA_INTEGER, 8, &value, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_input_settings_x11_set_touchpad_middle_click_emulation (MetaInputSettings *settings,
|
||||||
|
ClutterInputDevice *device,
|
||||||
|
gboolean enabled)
|
||||||
|
{
|
||||||
|
guchar value = enabled ? 1 : 0;
|
||||||
|
|
||||||
|
if (!meta_input_settings_x11_is_touchpad_device (settings, device))
|
||||||
|
return;
|
||||||
|
|
||||||
|
change_property (device, "libinput Middle Click Emulation Enabled",
|
||||||
|
XA_INTEGER, 8, &value, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_input_settings_x11_set_trackball_middle_click_emulation (MetaInputSettings *settings,
|
||||||
|
ClutterInputDevice *device,
|
||||||
|
gboolean enabled)
|
||||||
|
{
|
||||||
|
guchar value = enabled ? 1 : 0;
|
||||||
|
|
||||||
|
if (!meta_input_settings_x11_is_trackball_device (settings, device))
|
||||||
|
return;
|
||||||
|
|
||||||
|
change_property (device, "libinput Middle Click Emulation Enabled",
|
||||||
|
XA_INTEGER, 8, &value, 1);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_input_settings_x11_set_stylus_pressure (MetaInputSettings *settings,
|
meta_input_settings_x11_set_stylus_pressure (MetaInputSettings *settings,
|
||||||
ClutterInputDevice *device,
|
ClutterInputDevice *device,
|
||||||
@ -864,6 +913,10 @@ meta_input_settings_x11_class_init (MetaInputSettingsX11Class *klass)
|
|||||||
input_settings_class->set_stylus_pressure = meta_input_settings_x11_set_stylus_pressure;
|
input_settings_class->set_stylus_pressure = meta_input_settings_x11_set_stylus_pressure;
|
||||||
input_settings_class->set_stylus_button_map = meta_input_settings_x11_set_stylus_button_map;
|
input_settings_class->set_stylus_button_map = meta_input_settings_x11_set_stylus_button_map;
|
||||||
|
|
||||||
|
input_settings_class->set_mouse_middle_click_emulation = meta_input_settings_x11_set_mouse_middle_click_emulation;
|
||||||
|
input_settings_class->set_touchpad_middle_click_emulation = meta_input_settings_x11_set_touchpad_middle_click_emulation;
|
||||||
|
input_settings_class->set_trackball_middle_click_emulation = meta_input_settings_x11_set_trackball_middle_click_emulation;
|
||||||
|
|
||||||
input_settings_class->has_two_finger_scroll = meta_input_settings_x11_has_two_finger_scroll;
|
input_settings_class->has_two_finger_scroll = meta_input_settings_x11_has_two_finger_scroll;
|
||||||
input_settings_class->is_trackball_device = meta_input_settings_x11_is_trackball_device;
|
input_settings_class->is_trackball_device = meta_input_settings_x11_is_trackball_device;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user