summaryrefslogtreecommitdiff
path: root/plugins/mouse
diff options
context:
space:
mode:
authorClement Lefebvre <[email protected]>2015-09-03 14:10:10 +0100
committerClement Lefebvre <[email protected]>2015-09-03 14:10:10 +0100
commite1becf4e7b72d5ec3b915e7922b81f4e25c03f1b (patch)
tree68ead1d69b7302430c41ce1be5fa8c00153c5fd0 /plugins/mouse
parentf113d3892ea59540b5145b0346111e815a5eeb3e (diff)
downloadmate-settings-daemon-e1becf4e7b72d5ec3b915e7922b81f4e25c03f1b.tar.bz2
mate-settings-daemon-e1becf4e7b72d5ec3b915e7922b81f4e25c03f1b.tar.xz
Refactored mouse plugin a bit (tap actions used to instantiate a gsettings object for every device)
Diffstat (limited to 'plugins/mouse')
-rw-r--r--plugins/mouse/msd-mouse-manager.c65
1 files changed, 31 insertions, 34 deletions
diff --git a/plugins/mouse/msd-mouse-manager.c b/plugins/mouse/msd-mouse-manager.c
index 7c95978..9b63cbe 100644
--- a/plugins/mouse/msd-mouse-manager.c
+++ b/plugins/mouse/msd-mouse-manager.c
@@ -99,8 +99,8 @@ static void msd_mouse_manager_init (MsdMouseManager *mouse_manag
static void msd_mouse_manager_finalize (GObject *object);
static void set_mouse_settings (MsdMouseManager *manager);
#ifdef HAVE_X11_EXTENSIONS_XINPUT_H
-static int set_tap_to_click (gboolean state, gboolean left_handed);
-static void set_click_actions (gboolean enable_two_finger_click, gboolean enable_three_finger_click);
+static void set_tap_to_click (MsdMouseManager * manager);
+static void set_click_actions (MsdMouseManager * manager);
#endif
G_DEFINE_TYPE (MsdMouseManager, msd_mouse_manager, G_TYPE_OBJECT)
@@ -308,7 +308,7 @@ touchpad_has_single_button (XDevice *device)
static void
-set_xinput_devices_left_handed (gboolean left_handed)
+set_xinput_devices_left_handed (MsdMouseManager * manager, gboolean left_handed)
{
XDeviceInfo *device_info;
gint n_devices;
@@ -342,7 +342,7 @@ set_xinput_devices_left_handed (gboolean left_handed)
gboolean single_button = touchpad_has_single_button (device);
if (tap && !single_button)
- set_tap_to_click (tap, left_handed);
+ set_tap_to_click (manager);
XCloseDevice (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), device);
g_object_unref (settings);
@@ -440,7 +440,7 @@ set_left_handed (MsdMouseManager *manager,
/* When XInput support is available, never set the
* button ordering on the core pointer as that would
* revert the changes we make on the devices themselves */
- set_xinput_devices_left_handed (left_handed);
+ set_xinput_devices_left_handed (manager, left_handed);
return;
}
#endif
@@ -621,8 +621,8 @@ set_disable_w_typing (MsdMouseManager *manager, gboolean state)
}
#ifdef HAVE_X11_EXTENSIONS_XINPUT_H
-static int
-set_tap_to_click (gboolean state, gboolean left_handed)
+static void
+set_tap_to_click (MsdMouseManager * manager)
{
int numdevices, i, format, rc;
unsigned long nitems, bytes_after;
@@ -632,12 +632,18 @@ set_tap_to_click (gboolean state, gboolean left_handed)
Atom prop, type;
if (devicelist == NULL)
- return 0;
+ return;
prop = XInternAtom (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "Synaptics Tap Action", False);
if (!prop)
- return 0;
+ return;
+
+ gboolean state = g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_TAP_TO_CLICK);
+ gboolean left_handed = g_settings_get_boolean (manager->priv->settings_mouse, KEY_MOUSE_LEFT_HANDED);
+ gint one_finger_tap = g_settings_get_int (manager->priv->settings_touchpad, KEY_TOUCHPAD_ONE_FINGER_TAP);
+ gint two_finger_tap = g_settings_get_int (manager->priv->settings_touchpad, KEY_TOUCHPAD_TWO_FINGER_TAP);
+ gint three_finger_tap = g_settings_get_int (manager->priv->settings_touchpad, KEY_TOUCHPAD_THREE_FINGER_TAP);
for (i = 0; i < numdevices; i++) {
if ((device = device_is_touchpad (devicelist[i]))) {
@@ -646,18 +652,13 @@ set_tap_to_click (gboolean state, gboolean left_handed)
False, XA_INTEGER, &type, &format, &nitems,
&bytes_after, &data);
- GSettings *settings = g_settings_new (MATE_TOUCHPAD_SCHEMA);
- gint one_finger_tap = g_settings_get_int (settings, KEY_TOUCHPAD_ONE_FINGER_TAP);
- gint two_finger_tap = g_settings_get_int (settings, KEY_TOUCHPAD_TWO_FINGER_TAP);
- gint three_finger_tap = g_settings_get_int (settings, KEY_TOUCHPAD_THREE_FINGER_TAP);
if (one_finger_tap > 3 || one_finger_tap < 1)
one_finger_tap = 1;
if (two_finger_tap > 3 || two_finger_tap < 1)
two_finger_tap = 2;
if (three_finger_tap > 3 || three_finger_tap < 1)
three_finger_tap = 3;
- g_object_unref (settings);
-
+
if (rc == Success && type == XA_INTEGER && format == 8 && nitems >= 7)
{
/* Set RLM mapping for 1/2/3 fingers*/
@@ -679,12 +680,10 @@ set_tap_to_click (gboolean state, gboolean left_handed)
}
XFreeDeviceList (devicelist);
- return 0;
}
- static void
-set_click_actions (gint enable_two_finger_click,
- gint enable_three_finger_click)
+static void
+set_click_actions (MsdMouseManager * manager)
{
int numdevices, i, format, rc;
unsigned long nitems, bytes_after;
@@ -700,6 +699,9 @@ set_click_actions (gint enable_two_finger_click,
if (!prop)
return;
+ gint enable_two_finger_click = g_settings_get_int (manager->priv->settings_touchpad, KEY_TWO_FINGER_CLICK);
+ gint enable_three_finger_click = g_settings_get_int (manager->priv->settings_touchpad, KEY_THREE_FINGER_CLICK);
+
for (i = 0; i < numdevices; i++) {
if ((device = device_is_touchpad (devicelist[i]))) {
g_debug ("setting click action to click on %s", devicelist[i].name);
@@ -999,12 +1001,12 @@ set_mouse_settings (MsdMouseManager *manager)
set_left_handed (manager, left_handed);
set_motion_acceleration (manager, g_settings_get_double (manager->priv->settings_mouse, KEY_MOUSE_MOTION_ACCELERATION));
set_motion_threshold (manager, g_settings_get_int (manager->priv->settings_mouse, KEY_MOUSE_MOTION_THRESHOLD));
- set_middle_button (manager, g_settings_get_boolean (manager->priv->settings_mouse, KEY_MIDDLE_BUTTON_EMULATION));
+ set_middle_button (manager, g_settings_get_boolean (manager->priv->settings_mouse, KEY_MIDDLE_BUTTON_EMULATION));
set_disable_w_typing (manager, g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_DISABLE_W_TYPING));
#ifdef HAVE_X11_EXTENSIONS_XINPUT_H
- set_tap_to_click (g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_TAP_TO_CLICK), left_handed);
- set_click_actions (g_settings_get_int (manager->priv->settings_touchpad, KEY_TWO_FINGER_CLICK), g_settings_get_int (manager->priv->settings_touchpad, KEY_THREE_FINGER_CLICK));
+ set_tap_to_click (manager);
+ set_click_actions (manager);
set_edge_scroll (g_settings_get_int (manager->priv->settings_touchpad, KEY_TOUCHPAD_SCROLL_METHOD));
set_horiz_scroll (g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_PAD_HORIZ_SCROLL));
set_touchpad_enabled (g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_ENABLED));
@@ -1028,20 +1030,15 @@ mouse_callback (GSettings *settings,
set_middle_button (manager, g_settings_get_boolean (settings, key));
#ifdef HAVE_X11_EXTENSIONS_XINPUT_H
} else if (g_strcmp0 (key, KEY_TOUCHPAD_TAP_TO_CLICK) == 0) {
- set_tap_to_click (g_settings_get_boolean (settings, key),
- g_settings_get_boolean (manager->priv->settings_mouse, KEY_MOUSE_LEFT_HANDED));
+ set_tap_to_click (manager);
} else if (g_str_equal (key, KEY_TWO_FINGER_CLICK) || g_str_equal (key, KEY_THREE_FINGER_CLICK)) {
- set_click_actions(g_settings_get_int (settings, KEY_TWO_FINGER_CLICK),
- g_settings_get_int (settings, KEY_THREE_FINGER_CLICK));
+ set_click_actions(manager);
} else if (g_strcmp0 (key, KEY_TOUCHPAD_ONE_FINGER_TAP) == 0) {
- set_tap_to_click (g_settings_get_boolean (settings, KEY_TOUCHPAD_TAP_TO_CLICK),
- g_settings_get_boolean (manager->priv->settings_mouse, KEY_MOUSE_LEFT_HANDED));
+ set_tap_to_click (manager);
} else if (g_strcmp0 (key, KEY_TOUCHPAD_TWO_FINGER_TAP) == 0) {
- set_tap_to_click (g_settings_get_boolean (settings, KEY_TOUCHPAD_TAP_TO_CLICK),
- g_settings_get_boolean (manager->priv->settings_mouse, KEY_MOUSE_LEFT_HANDED));
+ set_tap_to_click (manager);
} else if (g_strcmp0 (key, KEY_TOUCHPAD_THREE_FINGER_TAP) == 0) {
- set_tap_to_click (g_settings_get_boolean (settings, KEY_TOUCHPAD_TAP_TO_CLICK),
- g_settings_get_boolean (manager->priv->settings_mouse, KEY_MOUSE_LEFT_HANDED));
+ set_tap_to_click (manager);
} else if (g_strcmp0 (key, KEY_TOUCHPAD_SCROLL_METHOD) == 0) {
set_edge_scroll (g_settings_get_int (settings, key));
set_horiz_scroll (g_settings_get_boolean (settings, KEY_TOUCHPAD_PAD_HORIZ_SCROLL));
@@ -1102,8 +1099,8 @@ msd_mouse_manager_idle_cb (MsdMouseManager *manager)
set_disable_w_typing (manager, g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_DISABLE_W_TYPING));
#ifdef HAVE_X11_EXTENSIONS_XINPUT_H
- set_tap_to_click (g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_TAP_TO_CLICK),
- g_settings_get_boolean (manager->priv->settings_mouse, KEY_MOUSE_LEFT_HANDED));
+ set_tap_to_click (manager);
+ set_click_actions (manager);
set_edge_scroll (g_settings_get_int (manager->priv->settings_touchpad, KEY_TOUCHPAD_SCROLL_METHOD));
set_horiz_scroll (g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_PAD_HORIZ_SCROLL));
set_touchpad_enabled (g_settings_get_boolean (manager->priv->settings_touchpad, KEY_TOUCHPAD_ENABLED));