~ubuntu-branches/debian/lenny/gsynaptics/lenny

« back to all changes in this revision

Viewing changes to src/gsynaptics.c

  • Committer: Bazaar Package Importer
  • Author(s): Michal Čihař
  • Date: 2008-06-18 11:24:03 UTC
  • mfrom: (3.1.3 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080618112403-ishc48mp2dkf2t40
Tags: 0.9.14-6
* Move fix for g_build_filename to separate patch.
* Add debian/README.source.
* Update to standards 3.8.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
                        {
72
72
                                gchar *str = g_strndup (p1 + 1, p2 - p1);
73
73
                                gchar *str2 = g_strdup (g_strchug (str));
74
 
                                value = g_ascii_strtod (str2, NULL);
 
74
 
 
75
                                value = g_ascii_strtod (str2, NULL);    // converted extracted string to gdouble
75
76
                                g_free (str);
76
77
                                g_free (str2);
77
78
                        }
253
254
 
254
255
#if 0
255
256
gint
256
 
g_synaptics_tap_action                 (GSynaptics *synaptics, TapEvent type)
 
257
g_synaptics_tap_action                 (GSynaptics *synaptics, TapType type)
257
258
{
258
259
}
259
260
#endif
373
374
        }
374
375
}
375
376
 
 
377
gint
 
378
g_synaptics_accel_factor (GSynaptics *synaptics)
 
379
{
 
380
        GSynapticsPrivate *priv = G_SYNAPTICS_GET_PRIVATE (synaptics);
 
381
        if (!g_synaptics_is_valid(synaptics))
 
382
                return 0;
 
383
 
 
384
        if (priv->synclient)
 
385
        {
 
386
                // Note (by Eugene Sia): returning gdouble instead of gint with value * 1000 
 
387
                // seems to cause a change in value when the value is returned to the calling function.
 
388
                // Possible bug in the gdouble implementation?
 
389
                return (gint) (g_synaptics_get_value_from_synclient ("AccelFactor") * 1000);
 
390
        }
 
391
        else
 
392
        {
 
393
                return (gint) (SYNSHM(synaptics)->accl * 1000);
 
394
        }
 
395
}
 
396
 
 
397
gint
 
398
g_synaptics_min_speed (GSynaptics *synaptics)
 
399
{
 
400
        GSynapticsPrivate *priv = G_SYNAPTICS_GET_PRIVATE (synaptics);
 
401
        if (!g_synaptics_is_valid(synaptics))
 
402
                return 0;
 
403
 
 
404
        if (priv->synclient)
 
405
        {
 
406
                return (gint) (g_synaptics_get_value_from_synclient ("MinSpeed") * 1000);
 
407
        }
 
408
        else
 
409
        {
 
410
                return (gint) (SYNSHM(synaptics)->min_speed * 1000);
 
411
        }
 
412
}
 
413
 
 
414
gint
 
415
g_synaptics_max_speed (GSynaptics *synaptics)
 
416
{
 
417
        GSynapticsPrivate *priv = G_SYNAPTICS_GET_PRIVATE (synaptics);
 
418
        if (!g_synaptics_is_valid(synaptics))
 
419
                return 0;
 
420
 
 
421
        if (priv->synclient)
 
422
        {
 
423
                return (gint) (g_synaptics_get_value_from_synclient ("MaxSpeed") * 1000);
 
424
        }
 
425
        else
 
426
        {
 
427
                return (gint) (SYNSHM(synaptics)->max_speed * 1000);
 
428
        }
 
429
}
 
430
 
376
431
gboolean
377
432
g_synaptics_is_coasting_enabled (GSynaptics *synaptics)
378
433
{
442
497
}
443
498
 
444
499
Button
445
 
g_synaptics_button_for_tap (GSynaptics *synaptics, TapEvent tap)
 
500
g_synaptics_button_for_tap (GSynaptics *synaptics, TapType tap)
446
501
{
447
502
        GSynapticsPrivate *priv = G_SYNAPTICS_GET_PRIVATE (synaptics);
448
503
        if (!g_synaptics_is_valid(synaptics))
560
615
 
561
616
#if 0
562
617
void
563
 
g_synaptics_set_tap_action (GSynaptics *synaptics, TapEvent type, int action)
 
618
g_synaptics_set_tap_action (GSynaptics *synaptics, TapType type, int action)
564
619
{
565
620
        if (!g_synaptics_is_valid(synaptics))
566
621
                return;
576
631
        if (!g_synaptics_is_valid(synaptics))
577
632
                return;
578
633
 
579
 
        if ( value < 0 && value > 4)
 
634
        if ( value < 0 || value > 4)
580
635
                return;
581
636
        
582
637
        if (priv->synclient)
649
704
}
650
705
 
651
706
void
 
707
g_synaptics_set_accel_factor(GSynaptics *synaptics, gint value)
 
708
{
 
709
        GSynapticsPrivate *priv = G_SYNAPTICS_GET_PRIVATE (synaptics);
 
710
        if (!g_synaptics_is_valid(synaptics))
 
711
                return;
 
712
 
 
713
        if (priv->synclient)
 
714
        {
 
715
                gchar *command;
 
716
                command = g_strdup_printf ("synclient AccelFactor=%f",
 
717
                                           (gdouble)value / 1000);
 
718
                g_spawn_command_line_async (command, NULL);
 
719
                g_free (command);
 
720
        }
 
721
        else
 
722
        {
 
723
                SYNSHM(synaptics)->accl = ((double)value) / 1000;
 
724
        }
 
725
}
 
726
 
 
727
void
 
728
g_synaptics_set_max_speed(GSynaptics *synaptics, gint value)
 
729
{
 
730
        GSynapticsPrivate *priv = G_SYNAPTICS_GET_PRIVATE (synaptics);
 
731
        if (!g_synaptics_is_valid(synaptics))
 
732
                return;
 
733
 
 
734
        if (priv->synclient)
 
735
        {
 
736
                gchar *command;
 
737
                command = g_strdup_printf ("synclient MaxSpeed=%f",
 
738
                                           (gdouble)value / 1000);
 
739
                g_spawn_command_line_async (command, NULL);
 
740
                g_free (command);
 
741
        }
 
742
        else
 
743
        {
 
744
                SYNSHM(synaptics)->max_speed = ((double)value) / 1000;
 
745
        }
 
746
}
 
747
 
 
748
void
 
749
g_synaptics_set_min_speed(GSynaptics *synaptics, gint value)
 
750
{
 
751
        GSynapticsPrivate *priv = G_SYNAPTICS_GET_PRIVATE (synaptics);
 
752
        if (!g_synaptics_is_valid(synaptics))
 
753
                return;
 
754
 
 
755
        if (priv->synclient)
 
756
        {
 
757
                gchar *command;
 
758
                command = g_strdup_printf ("synclient MinSpeed=%f",
 
759
                                           (gdouble)value / 1000);
 
760
                g_spawn_command_line_async (command, NULL);
 
761
                g_free (command);
 
762
        }
 
763
        else
 
764
        {
 
765
                SYNSHM(synaptics)->min_speed = ((double)value) / 1000;
 
766
        }
 
767
}
 
768
 
 
769
void
652
770
g_synaptics_set_circular_scroll_enabled (GSynaptics *synaptics, gboolean enable)
653
771
{
654
772
        GSynapticsPrivate *priv = G_SYNAPTICS_GET_PRIVATE (synaptics);
758
876
}
759
877
 
760
878
void
761
 
g_synaptics_set_button_for_tap (GSynaptics *synaptics, TapEvent tap, Button button)
 
879
g_synaptics_set_button_for_tap (GSynaptics *synaptics, TapType tap, Button button)
762
880
{
763
881
        GSynapticsPrivate *priv = G_SYNAPTICS_GET_PRIVATE (synaptics);
764
882
        if (!g_synaptics_is_valid(synaptics))