gpointing-device-settings r86 - in trunk: modules src test



Author: hiikezoe
Date: Mon Mar  2 03:26:50 2009
New Revision: 86
URL: http://svn.gnome.org/viewvc/gpointing-device-settings?rev=86&view=rev

Log:
gpds_xinput_set_property needs format type.

Modified:
   trunk/modules/gpds-touchpad-ui.c
   trunk/modules/gpds-trackpoint-ui.c
   trunk/modules/gsd-touchpad-manager.c
   trunk/modules/gsd-trackpoint-manager.c
   trunk/src/gpds-xinput.c
   trunk/src/gpds-xinput.h
   trunk/test/test-xinput.c

Modified: trunk/modules/gpds-touchpad-ui.c
==============================================================================
--- trunk/modules/gpds-touchpad-ui.c	(original)
+++ trunk/modules/gpds-touchpad-ui.c	Mon Mar  2 03:26:50 2009
@@ -182,6 +182,7 @@
     active = gtk_toggle_button_get_active(button);
     if (!gpds_xinput_set_property(xinput,
                                   property_name,
+                                  8,
                                   &error,
                                   active ? 1 : 0,
                                   NULL)) {
@@ -210,6 +211,7 @@
 
     if (!gpds_xinput_set_property(xinput,
                                   GPDS_TOUCHPAD_EDGE_SCROLLING,
+                                  16,
                                   &error,
                                   vertical_scrolling_active ? 1 : 0,
                                   horizontal_scrolling_active ? 1 : 0,
@@ -230,6 +232,7 @@
     value = gtk_range_get_value(range);
     if (!gpds_xinput_set_property(xinput,
                                   property_name,
+                                  16,
                                   &error,
                                   (gint)value,
                                   NULL)) {
@@ -256,6 +259,7 @@
 
     if (!gpds_xinput_set_property(xinput,
                                   GPDS_TOUCHPAD_SCROLLING_DISTANCE,
+                                  16,
                                   &error,
                                   (gint)vertical_scrolling_distance,
                                   (gint)horizontal_scrolling_distance,

Modified: trunk/modules/gpds-trackpoint-ui.c
==============================================================================
--- trunk/modules/gpds-trackpoint-ui.c	(original)
+++ trunk/modules/gpds-trackpoint-ui.c	Mon Mar  2 03:26:50 2009
@@ -159,6 +159,7 @@
     active = gtk_toggle_button_get_active(button);
     gpds_xinput_set_property(xinput,
                              property_name,
+                             8,
                              &error,
                              active ? 1 : 0,
                              NULL);
@@ -177,6 +178,7 @@
     value = gtk_spin_button_get_value(button);
     gpds_xinput_set_property(xinput,
                              property_name,
+                             16,
                              &error,
                              (gint)value,
                              NULL);
@@ -249,6 +251,7 @@
 
     gpds_xinput_set_property(ui->xinput,
                              GPDS_TRACK_POINT_WHEEL_EMULATION_AXES,
+                             8,
                              &error,
                              vertical_scroll_active ? 6 : -1,
                              vertical_scroll_active ? 7 : -1,

Modified: trunk/modules/gsd-touchpad-manager.c
==============================================================================
--- trunk/modules/gsd-touchpad-manager.c	(original)
+++ trunk/modules/gsd-touchpad-manager.c	Mon Mar  2 03:26:50 2009
@@ -96,12 +96,14 @@
         if (!strcmp(key, GPDS_TOUCHPAD_TAP_FAST_TAP_KEY)) {
             gpds_xinput_set_property(xinput,
                                      GPDS_TOUCHPAD_TAP_FAST_TAP,
+                                     8,
                                      NULL,
                                      gconf_value_get_bool(value),
                                      NULL);
         } else  if (!strcmp(key, GPDS_TOUCHPAD_CIRCULAR_SCROLLING_KEY)) {
             gpds_xinput_set_property(xinput,
                                      GPDS_TOUCHPAD_CIRCULAR_SCROLLING,
+                                     8,
                                      NULL,
                                      gconf_value_get_bool(value),
                                      NULL);
@@ -117,6 +119,7 @@
 
             gpds_xinput_set_property(xinput,
                                      GPDS_TOUCHPAD_EDGE_SCROLLING,
+                                     16,
                                      NULL,
                                      enable_vertical ? 1 : 0,
                                      enable_horizontal ? 1 : 0,
@@ -127,6 +130,7 @@
         if (!strcmp(key, GPDS_TOUCHPAD_TAP_TIME_KEY)) {
             gpds_xinput_set_property(xinput,
                                      GPDS_TOUCHPAD_TAP_TIME,
+                                     16,
                                      NULL,
                                      gconf_value_get_int(value),
                                      NULL);
@@ -145,6 +149,7 @@
                                      NULL);
             gpds_xinput_set_property(xinput,
                                      GPDS_TOUCHPAD_SCROLLING_DISTANCE,
+                                     16,
                                      NULL,
                                      vertical_scrolling_distance,
                                      horizontal_scrolling_distance,

Modified: trunk/modules/gsd-trackpoint-manager.c
==============================================================================
--- trunk/modules/gsd-trackpoint-manager.c	(original)
+++ trunk/modules/gsd-trackpoint-manager.c	Mon Mar  2 03:26:50 2009
@@ -96,12 +96,14 @@
         if (!strcmp(key, GPDS_TRACK_POINT_MIDDLE_BUTTON_EMULATION_KEY)) {
             gpds_xinput_set_property(xinput,
                                      GPDS_TRACK_POINT_MIDDLE_BUTTON_EMULATION,
+                                     8,
                                      NULL,
                                      gconf_value_get_bool(value),
                                      NULL);
         } else  if (!strcmp(key, GPDS_TRACK_POINT_WHEEL_EMULATION_KEY)) {
             gpds_xinput_set_property(xinput,
                                      GPDS_TRACK_POINT_WHEEL_EMULATION,
+                                     8,
                                      NULL,
                                      gconf_value_get_bool(value),
                                      NULL);
@@ -116,6 +118,7 @@
                                                       NULL);
             gpds_xinput_set_property(xinput,
                                      GPDS_TRACK_POINT_WHEEL_EMULATION_AXES,
+                                     8,
                                      NULL,
                                      enable_vertical ? 6 : -1,
                                      enable_vertical ? 7 : -1,
@@ -128,18 +131,21 @@
         if (!strcmp(key, GPDS_TRACK_POINT_MIDDLE_BUTTON_TIMEOUT_KEY)) {
             gpds_xinput_set_property(xinput,
                                      GPDS_TRACK_POINT_MIDDLE_BUTTON_TIMEOUT,
+                                     32,
                                      NULL,
                                      gconf_value_get_int(value),
                                      NULL);
         } else if (!strcmp(key, GPDS_TRACK_POINT_WHEEL_EMULATION_TIMEOUT_KEY)) {
             gpds_xinput_set_property(xinput,
                                      GPDS_TRACK_POINT_WHEEL_EMULATION_TIMEOUT,
+                                     16,
                                      NULL,
                                      gconf_value_get_int(value),
                                      NULL);
         } else if (!strcmp(key, GPDS_TRACK_POINT_WHEEL_EMULATION_INERTIA_KEY)) {
             gpds_xinput_set_property(xinput,
                                      GPDS_TRACK_POINT_WHEEL_EMULATION_INERTIA,
+                                     16,
                                      NULL,
                                      gconf_value_get_int(value),
                                      NULL);

Modified: trunk/src/gpds-xinput.c
==============================================================================
--- trunk/src/gpds-xinput.c	(original)
+++ trunk/src/gpds-xinput.c	Mon Mar  2 03:26:50 2009
@@ -223,6 +223,7 @@
 static gboolean
 set_property_va_list (GpdsXInput *xinput,
                       const gchar *property_name,
+                      gint format_type,
                       GError **error,
                       gint first_value, va_list var_args)
 {
@@ -230,10 +231,8 @@
     Atom property_atom;
     gint i, n_values = 1;
     gint *values;
-    gint max_value;
     gchar *property_data;
     va_list copy_var_args;
-    int format;
 
     device = get_device(xinput, error);
     if (!device)
@@ -247,25 +246,26 @@
 
     values = g_new(gint, n_values);
     values[0] = first_value;
-    max_value = values[0];
+
     for (i = 1; i < n_values; i++) {
         values[i] = va_arg(copy_var_args, gint);
-        max_value = MAX(max_value, values[i]);
     }
 
-    if (max_value <= G_MAXINT8) {
+    switch (format_type) {
+    case 8:
         property_data = (gchar*)g_new(int8_t*, n_values);
-        format = 8;
-    } else if (max_value <= G_MAXINT16) {
+        break;
+    case 16:
         property_data = (gchar*)g_new(int16_t*, n_values);
-        format = 16;
-    } else {
+        break;
+    case 32:
+    default:
         property_data = (gchar*)g_new(int32_t*, n_values);
-        format = 32;
+        break;
     }
 
     for (i = 0; i < n_values; i++) {
-        switch (format) {
+        switch (format_type) {
         case 8:
             *(((int8_t*)property_data) + i) = values[i];
             break;
@@ -285,7 +285,7 @@
     gdk_error_trap_push();
     XChangeDeviceProperty(GDK_DISPLAY(),
                           device, property_atom,
-                          XA_INTEGER, format, PropModeReplace,
+                          XA_INTEGER, format_type, PropModeReplace,
                           (unsigned char*)property_data, n_values);
     gdk_error_trap_pop();
 
@@ -297,6 +297,7 @@
 gboolean
 gpds_xinput_set_property (GpdsXInput *xinput,
                           const gchar *property_name,
+                          gint format_type,
                           GError **error,
                           gint first_value, ...)
 {
@@ -306,7 +307,7 @@
     g_return_val_if_fail(GPDS_IS_XINPUT(xinput), FALSE);
 
     va_start(var_args, first_value);
-    success = set_property_va_list(xinput, property_name, error, first_value, var_args);
+    success = set_property_va_list(xinput, property_name, format_type, error, first_value, var_args);
     va_end(var_args);
 
     return success;

Modified: trunk/src/gpds-xinput.h
==============================================================================
--- trunk/src/gpds-xinput.h	(original)
+++ trunk/src/gpds-xinput.h	Mon Mar  2 03:26:50 2009
@@ -62,6 +62,7 @@
 
 gboolean     gpds_xinput_set_property    (GpdsXInput *xinput,
                                           const gchar *property_name,
+                                          gint format_type,
                                           GError **error,
                                           gint first_property_value,
                                           ...) G_GNUC_NULL_TERMINATED;

Modified: trunk/test/test-xinput.c
==============================================================================
--- trunk/test/test-xinput.c	(original)
+++ trunk/test/test-xinput.c	Mon Mar  2 03:26:50 2009
@@ -42,38 +42,40 @@
     cut_trace(test_new());
 
     cut_assert_true(gpds_xinput_get_property(xinput,
-                                          "Middle Button Emulation",
-                                          &error,
-                                          &values, &n_values));
+                                             "Evdev Middle Button Emulation",
+                                             &error,
+                                             &values, &n_values));
     gcut_assert_error(error);
     cut_assert_equal_int(1, n_values);
     original_value = values[0];
 
     cut_assert_true(gpds_xinput_set_property(xinput,
-                                          "Middle Button Emulation",
-                                          &error,
-                                          1, NULL));
+                                             "Evdev Middle Button Emulation",
+                                             8,
+                                             &error,
+                                             1, NULL));
     gcut_assert_error(error);
     g_free(values);
     cut_assert_true(gpds_xinput_get_property(xinput,
-                                          "Middle Button Emulation",
-                                          &error,
-                                          &values, &n_values));
+                                             "Evdev Middle Button Emulation",
+                                             &error,
+                                             &values, &n_values));
     gcut_assert_error(error);
     cut_assert_equal_int(1, n_values);
     cut_assert_equal_int(1, values[0]);
 
     cut_assert_true(gpds_xinput_set_property(xinput,
-                                          "Middle Button Emulation",
-                                          &error,
-                                          original_value, NULL));
+                                             "Evdev Middle Button Emulation",
+                                             8,
+                                             &error,
+                                             original_value, NULL));
     gcut_assert_error(error);
 
     g_free(values);
     cut_assert_true(gpds_xinput_get_property(xinput,
-                                          "Middle Button Emulation",
-                                          &error,
-                                          &values, &n_values));
+                                             "Evdev Middle Button Emulation",
+                                             &error,
+                                             &values, &n_values));
     gcut_assert_error(error);
     cut_assert_equal_int(1, n_values);
     cut_assert_equal_int(original_value, values[0]);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]