mirror of
https://github.com/brl/mutter.git
synced 2024-11-24 17:10:40 -05:00
backends/x11: Add enum for scroll methods
This way the "libinput Scroll Method Enabled" property manipulation is made clearer.
This commit is contained in:
parent
36cd7177fd
commit
cfe5d7429a
@ -36,6 +36,13 @@
|
||||
|
||||
G_DEFINE_TYPE (MetaInputSettingsX11, meta_input_settings_x11, META_TYPE_INPUT_SETTINGS)
|
||||
|
||||
enum {
|
||||
SCROLL_METHOD_FIELD_2FG,
|
||||
SCROLL_METHOD_FIELD_EDGE,
|
||||
SCROLL_METHOD_FIELD_BUTTON,
|
||||
SCROLL_METHOD_NUM_FIELDS
|
||||
};
|
||||
|
||||
static void *
|
||||
get_property (ClutterInputDevice *device,
|
||||
const gchar *property,
|
||||
@ -203,25 +210,26 @@ meta_input_settings_x11_set_edge_scroll (MetaInputSettings *settings,
|
||||
ClutterInputDevice *device,
|
||||
gboolean edge_scroll_enabled)
|
||||
{
|
||||
guchar values[3] = { 0 }; /* 2fg, edge, button. The last value is unused */
|
||||
guchar values[SCROLL_METHOD_NUM_FIELDS] = { 0 }; /* 2fg, edge, button. The last value is unused */
|
||||
guchar *defaults;
|
||||
guchar *available;
|
||||
|
||||
available = get_property (device, "libinput Scroll Methods Available",
|
||||
XA_INTEGER, 8, 3);
|
||||
XA_INTEGER, 8, SCROLL_METHOD_NUM_FIELDS);
|
||||
defaults = get_property (device, "libinput Scroll Method Enabled",
|
||||
XA_INTEGER, 8, 3);
|
||||
XA_INTEGER, 8, SCROLL_METHOD_NUM_FIELDS);
|
||||
if (!available || !defaults)
|
||||
goto out;
|
||||
|
||||
memcpy (values, defaults, 3);
|
||||
memcpy (values, defaults, SCROLL_METHOD_NUM_FIELDS);
|
||||
|
||||
/* Don't set edge scrolling if two-finger scrolling is enabled and available */
|
||||
if (available[1] && !(available[0] && values[0]))
|
||||
if (available[SCROLL_METHOD_FIELD_EDGE] &&
|
||||
!(available[SCROLL_METHOD_FIELD_2FG] && values[SCROLL_METHOD_FIELD_2FG]))
|
||||
{
|
||||
values[1] = !!edge_scroll_enabled;
|
||||
change_property (device, "libinput Scroll Method Enabled",
|
||||
XA_INTEGER, 8, &values, 3);
|
||||
XA_INTEGER, 8, &values, SCROLL_METHOD_NUM_FIELDS);
|
||||
}
|
||||
|
||||
out:
|
||||
@ -236,38 +244,38 @@ meta_input_settings_x11_set_two_finger_scroll (MetaInputSettings *set
|
||||
ClutterInputDevice *device,
|
||||
gboolean two_finger_scroll_enabled)
|
||||
{
|
||||
guchar values[3] = { 0 }; /* 2fg, edge, button. The last value is unused */
|
||||
guchar values[SCROLL_METHOD_NUM_FIELDS] = { 0 }; /* 2fg, edge, button. The last value is unused */
|
||||
guchar *defaults;
|
||||
guchar *available;
|
||||
gboolean changed;
|
||||
|
||||
available = get_property (device, "libinput Scroll Methods Available",
|
||||
XA_INTEGER, 8, 3);
|
||||
XA_INTEGER, 8, SCROLL_METHOD_NUM_FIELDS);
|
||||
defaults = get_property (device, "libinput Scroll Method Enabled",
|
||||
XA_INTEGER, 8, 3);
|
||||
XA_INTEGER, 8, SCROLL_METHOD_NUM_FIELDS);
|
||||
if (!available || !defaults)
|
||||
goto out;
|
||||
|
||||
memcpy (values, defaults, 3);
|
||||
memcpy (values, defaults, SCROLL_METHOD_NUM_FIELDS);
|
||||
changed = FALSE;
|
||||
|
||||
if (available[0])
|
||||
if (available[SCROLL_METHOD_FIELD_2FG])
|
||||
{
|
||||
values[0] = !!two_finger_scroll_enabled;
|
||||
values[SCROLL_METHOD_FIELD_2FG] = !!two_finger_scroll_enabled;
|
||||
changed = TRUE;
|
||||
}
|
||||
|
||||
/* Disable edge scrolling when two-finger scrolling is enabled */
|
||||
if (values[0] && values[1])
|
||||
if (values[SCROLL_METHOD_FIELD_2FG] && values[SCROLL_METHOD_FIELD_EDGE])
|
||||
{
|
||||
values[1] = 0;
|
||||
values[SCROLL_METHOD_FIELD_EDGE] = 0;
|
||||
changed = TRUE;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
{
|
||||
change_property (device, "libinput Scroll Method Enabled",
|
||||
XA_INTEGER, 8, &values, 3);
|
||||
XA_INTEGER, 8, &values, SCROLL_METHOD_NUM_FIELDS);
|
||||
}
|
||||
|
||||
out:
|
||||
|
Loading…
Reference in New Issue
Block a user