Hello,

Please find attached a patchset that will add a configuration panel that will allow a user to control the mouse acceleration in X.

--
Regards,
Ravenlock
#include "e.h"

static void *_create_data(E_Config_Dialog *cfd);
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static int  _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data 
*cfdata);
static Evas_Object  *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas,
                                           E_Config_Dialog_Data *cfdata);

struct _E_Config_Dialog_Data
{
   E_Config_Dialog *cfd;
   
   double numerator;
   double denominator;
   double threshold;
};

static E_Dialog *mouse_dialog = NULL;

static void
_cb_mouse_dialog_ok(void *data, E_Dialog *dia)
{
   e_object_del(E_OBJECT(mouse_dialog));
   mouse_dialog = NULL;
}

EAPI E_Config_Dialog *
e_int_config_mouse(E_Container *con)
{
   E_Config_Dialog *cfd;
   E_Config_Dialog_View *v;
   
   if (e_config_dialog_find("E", "_config_mouse_dialog")) 
     return NULL;

   v = E_NEW(E_Config_Dialog_View, 1);
   
   v->create_cfdata = _create_data;
   v->free_cfdata = _free_data;
   v->basic.apply_cfdata = _basic_apply_data;
   v->basic.create_widgets = _basic_create_widgets;
   v->override_auto_apply = 1;
   
   cfd = e_config_dialog_new(con, _("Mouse Acceleration Settings"), "E", 
                             "_config_mouse_dialog", "enlightenment/mouse", 
                             0, v, NULL);
   return cfd;
}

static void
_fill_data(E_Config_Dialog_Data *cfdata)
{
   cfdata->numerator = e_config->mouse_accel_numerator;
   cfdata->denominator = e_config->mouse_accel_denominator;
   cfdata->threshold = e_config->mouse_accel_threshold;
}

static void *
_create_data(E_Config_Dialog *cfd)
{
   E_Config_Dialog_Data *cfdata;

   cfdata = E_NEW(E_Config_Dialog_Data, 1);
   cfdata->cfd = cfd;

   _fill_data(cfdata);
   return cfdata;
}

static void
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
   if (!cfdata) return;

   E_FREE(cfdata);
}

/* advanced window */
static int
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
   e_config->mouse_accel_numerator = cfdata->numerator;
   // Force denominator to 1 for simplicity.
   e_config->mouse_accel_denominator = 1; //cfdata->denominator;
   e_config->mouse_accel_threshold = cfdata->threshold;

   // Apply the above settings
   e_mouse_init();

   e_config_save_queue();
   return 1;
}

static Evas_Object *
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data 
*cfdata)
{
   Evas_Object *o, *of, *ob;
   E_Radio_Group *rg;
   o = e_widget_list_add(evas, 0, 0);

   of = e_widget_framelist_add(evas, _("Mouse Acceleration"), 0);

   ob = e_widget_label_add(evas, _("Acceleration"));
   e_widget_framelist_object_append(of, ob);
   ob = e_widget_slider_add(evas, 1, 0, _("%1.0f"), 1.0, 10.0, 1.0, 0, 
                            &(cfdata->numerator), NULL, 200);
   e_widget_framelist_object_append(of, ob);
   
   /*ob = e_widget_label_add(evas, _("Denominator"));
   e_widget_framelist_object_append(of, ob);
   ob = e_widget_slider_add(evas, 1, 0, _("%1.0f"), 1.0, 10.0, 1.0, 0, 
                            &(cfdata->denominator), NULL, 200);
   e_widget_framelist_object_append(of, ob);*/

   ob = e_widget_label_add(evas, _("Threshold"));
   e_widget_framelist_object_append(of, ob);
   ob = e_widget_slider_add(evas, 1, 0, _("%1.0f"), 1.0, 10.0, 1.0, 0, 
                            &(cfdata->threshold), NULL, 200);
   e_widget_framelist_object_append(of, ob);

   e_widget_list_object_append(o, of, 1, 1, 0.5);
   
   e_dialog_resizable_set(cfd->dia, 0);
   return o;   
}
#ifdef E_TYPEDEFS
#else
#ifndef E_INT_CONFIG_MOUSE_H
#define E_INT_CONFIG_MOUSE_H

EAPI E_Config_Dialog *e_int_config_mouse(E_Container *con);

#endif
#endif
/*
 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
 */
#include "e.h"
 
EAPI int
e_mouse_init(void)
{
   if (!ecore_x_pointer_control_set(e_config->mouse_accel_numerator,
                                        e_config->mouse_accel_denominator,
                                        e_config->mouse_accel_threshold))
                                        return 0;
           
   return 1;
}
#ifdef E_TYPEDEFS
#else
#ifndef E_MOUSE_H
#define E_MOUSE_H

EAPI int e_mouse_init(void);

#endif
#endif
Index: e17/apps/e/src/bin/Makefile.am
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/Makefile.am,v
retrieving revision 1.176
diff -u -r1.176 Makefile.am
--- e17/apps/e/src/bin/Makefile.am      2 Mar 2007 17:00:20 -0000       1.176
+++ e17/apps/e/src/bin/Makefile.am      10 Mar 2007 03:49:48 -0000
@@ -187,7 +187,9 @@
 e_int_config_borders.h \
 e_int_config_desk.h \
 e_int_config_clientlist.h \
-e_fm_prop.h
+e_fm_prop.h \
+e_int_config_mouse.h \
+e_mouse.h
  
 enlightenment_src = \
 e_user.c \
@@ -350,6 +352,8 @@
 e_int_config_desk.c \
 e_fm_prop.c \
 e_int_config_clientlist.c \
+e_int_config_mouse.c \
+e_mouse.c \
 $(ENLIGHTENMENTHEADERS)
 
 enlightenment_SOURCES = \
Index: e17/apps/e/src/bin/e_config.c
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_config.c,v
retrieving revision 1.228
diff -u -r1.228 e_config.c
--- e17/apps/e/src/bin/e_config.c       2 Mar 2007 17:00:20 -0000       1.228
+++ e17/apps/e/src/bin/e_config.c       10 Mar 2007 03:49:49 -0000
@@ -511,6 +511,10 @@
    E_CONFIG_VAL(D, T, clientlist_separate_iconified_apps, INT);
    E_CONFIG_VAL(D, T, clientlist_warp_to_iconified_desktop, INT);
    
+   E_CONFIG_VAL(D, T, mouse_accel_numerator, INT);
+   E_CONFIG_VAL(D, T, mouse_accel_denominator, INT);
+   E_CONFIG_VAL(D, T, mouse_accel_threshold, INT);
+
    E_CONFIG_VAL(D, T, border_raise_on_mouse_action, INT);
    E_CONFIG_VAL(D, T, border_raise_on_focus, INT);
    E_CONFIG_VAL(D, T, desk_flip_wrap, INT);
@@ -1337,6 +1341,12 @@
    e_config->clientlist_warp_to_iconified_desktop = 0;
    IFCFGEND;
 
+   IFCFG(0x0111);
+   e_config->mouse_accel_numerator = 2;
+   e_config->mouse_accel_denominator = 1;
+   e_config->mouse_accel_threshold = 4;
+   IFCFGEND;
+
    e_config->config_version = E_CONFIG_FILE_VERSION;   
      
 #if 0 /* example of new config */
@@ -1455,6 +1465,10 @@
    E_CONFIG_LIMIT(e_config->clientlist_separate_iconified_apps, 0, 2);
    E_CONFIG_LIMIT(e_config->clientlist_warp_to_iconified_desktop, 0, 1);
    
+   E_CONFIG_LIMIT(e_config->mouse_accel_numerator, 1, 10);
+   E_CONFIG_LIMIT(e_config->mouse_accel_denominator, 1, 10);
+   E_CONFIG_LIMIT(e_config->mouse_accel_threshold, 1, 10);
+
    /* FIXME: disabled auto apply because it causes problems */
    e_config->cfgdlg_auto_apply = 0;
    /* FIXME: desklock personalized password id disabled for security reasons */
Index: e17/apps/e/src/bin/e_config.h
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_config.h,v
retrieving revision 1.143
diff -u -r1.143 e_config.h
--- e17/apps/e/src/bin/e_config.h       2 Mar 2007 17:00:20 -0000       1.143
+++ e17/apps/e/src/bin/e_config.h       10 Mar 2007 03:49:50 -0000
@@ -52,7 +52,7 @@
 /* increment this whenever a new set of config values are added but the users
  * config doesn't need to be wiped - simply new values need to be put in
  */
-#define E_CONFIG_FILE_GENERATION 0x0110
+#define E_CONFIG_FILE_GENERATION 0x0111
 #define E_CONFIG_FILE_VERSION    ((E_CONFIG_FILE_EPOCH << 16) | 
E_CONFIG_FILE_GENERATION)
 
 #define E_EVAS_ENGINE_DEFAULT      0
@@ -253,6 +253,10 @@
    int         clientlist_separate_iconified_apps;
    int         clientlist_warp_to_iconified_desktop;
 
+   int         mouse_accel_numerator;
+   int         mouse_accel_denominator;
+   int         mouse_accel_threshold;
+   
    int         display_res_restore; // GUI
    int         display_res_width; // GUI
    int         display_res_height; // GUI
Index: e17/apps/e/src/bin/e_configure.c
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_configure.c,v
retrieving revision 1.90
diff -u -r1.90 e_configure.c
--- e17/apps/e/src/bin/e_configure.c    21 Feb 2007 00:05:27 -0000      1.90
+++ e17/apps/e/src/bin/e_configure.c    10 Mar 2007 03:49:50 -0000
@@ -418,6 +418,7 @@
    cat = _e_configure_category_add(eco, _("Keyboard & Mouse"), 
"enlightenment/behavior");
    _e_configure_item_add(cat, _("Key Bindings"), "enlightenment/keys", 
e_int_config_keybindings);
    _e_configure_item_add(cat, _("Mouse Bindings"), 
"enlightenment/mouse_clean", e_int_config_mousebindings);
+   _e_configure_item_add(cat, _("Mouse Acceleration"), 
"enlightenment/mouse_clean", e_int_config_mouse);
 
    cat = _e_configure_category_add(eco, _("Windows"), "enlightenment/windows");
    _e_configure_item_add(cat, _("Window Display"), "enlightenment/windows", 
e_int_config_window_display);
Index: e17/apps/e/src/bin/e_includes.h
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_includes.h,v
retrieving revision 1.148
diff -u -r1.148 e_includes.h
--- e17/apps/e/src/bin/e_includes.h     21 Feb 2007 00:05:27 -0000      1.148
+++ e17/apps/e/src/bin/e_includes.h     10 Mar 2007 03:49:50 -0000
@@ -163,3 +163,6 @@
 #include "e_int_config_desk.h"
 #include "e_int_config_clientlist.h"
 #include "e_fm_prop.h"
+#include "e_int_config_mouse.h"
+#include "e_int_config_mouse.h"
+#include "e_int_config_mouse.h"
Index: e17/apps/e/src/bin/e_main.c
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_main.c,v
retrieving revision 1.201
diff -u -r1.201 e_main.c
--- e17/apps/e/src/bin/e_main.c 2 Mar 2007 17:00:20 -0000       1.201
+++ e17/apps/e/src/bin/e_main.c 10 Mar 2007 03:49:51 -0000
@@ -785,6 +785,14 @@
        _e_main_shutdown(-1);
      }
      
+   TS("mouse");     
+   /* setup mouse accel */
+   if (!e_mouse_init())
+     {
+       e_error_message_show(_("Enlightenment cannot configure the mouse 
acceleration settings."));
+       _e_main_shutdown(-1);
+     }
+
    TS("desklock");
    /* setup desklock */
    if (!e_desklock_init())
Index: e17/libs/ecore/src/lib/ecore_x/Ecore_X.h
===================================================================
RCS file: /var/cvs/e/e17/libs/ecore/src/lib/ecore_x/Ecore_X.h,v
retrieving revision 1.183
diff -u -r1.183 Ecore_X.h
--- e17/libs/ecore/src/lib/ecore_x/Ecore_X.h    9 Mar 2007 01:11:09 -0000       
1.183
+++ e17/libs/ecore/src/lib/ecore_x/Ecore_X.h    10 Mar 2007 03:53:46 -0000
@@ -1417,7 +1417,8 @@
 EAPI void ecore_x_window_save_set_del(Ecore_X_Window win);
 EAPI Ecore_X_Window *ecore_x_window_children_get(Ecore_X_Window win, int *num);
 
-
+EAPI int  ecore_x_pointer_control_set(int accel_num, int accel_denom, int 
threshold);
+EAPI int  ecore_x_pointer_control_get(int *accel_num, int *accel_denom, int 
*threshold);
 EAPI int  ecore_x_pointer_grab(Ecore_X_Window win);
 EAPI int  ecore_x_pointer_confine_grab(Ecore_X_Window win);
 EAPI void ecore_x_pointer_ungrab(void);
Index: e17/libs/ecore/src/lib/ecore_x/ecore_x.c
===================================================================
RCS file: /var/cvs/e/e17/libs/ecore/src/lib/ecore_x/ecore_x.c,v
retrieving revision 1.125
diff -u -r1.125 ecore_x.c
--- e17/libs/ecore/src/lib/ecore_x/ecore_x.c    9 Mar 2007 01:11:09 -0000       
1.125
+++ e17/libs/ecore/src/lib/ecore_x/ecore_x.c    10 Mar 2007 03:53:47 -0000
@@ -1089,6 +1089,21 @@
 }
 
 EAPI int
+ecore_x_pointer_control_set(int accel_num, int accel_denom, int threshold)
+{
+   return XChangePointerControl(_ecore_x_disp, 1, 1, 
+                               accel_num, accel_denom, threshold);
+}
+
+
+EAPI int
+ecore_x_pointer_control_get(int *accel_num, int *accel_denom, int *threshold)
+{
+   return XGetPointerControl(_ecore_x_disp, 
+                               accel_num, accel_denom, threshold);
+}
+
+EAPI int
 ecore_x_pointer_grab(Ecore_X_Window win)
 {
    if (XGrabPointer(_ecore_x_disp, win, False,
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to