Skip to content

Commit

Permalink
Mouse and touchpad settings modifs
Browse files Browse the repository at this point in the history
  • Loading branch information
thewaiter committed Aug 26, 2022
1 parent 28bc1ba commit 2c648d7
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 66 deletions.
2 changes: 1 addition & 1 deletion config/bodhi/e.src
Original file line number Diff line number Diff line change
Expand Up @@ -1928,7 +1928,7 @@ group "E_Config" struct {
value "priority" int: -1000;
}
}
value "config_version" int: 1000016;
value "config_version" int: 1000017;
value "show_splash" int: 1;
value "init_default_theme" string: "/usr/share/enlightenment/data/themes/MokshaArcGreen.edj";
value "desktop_default_name" string: "%i-%i";
Expand Down
8 changes: 8 additions & 0 deletions src/bin/e_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ _e_config_edd_init(Eina_Bool old)
E_CONFIG_VAL(D, T, mouse_emulate_middle_button, UCHAR);

E_CONFIG_VAL(D, T, touch_accel, DOUBLE);
E_CONFIG_VAL(D, T, touch_extras, UCHAR);
E_CONFIG_VAL(D, T, touch_natural_scroll, UCHAR);
E_CONFIG_VAL(D, T, touch_emulate_middle_button, UCHAR);
E_CONFIG_VAL(D, T, touch_tap_to_click, UCHAR);
Expand Down Expand Up @@ -1080,6 +1081,12 @@ while (!e_config)
e_config->mouse_emulate_middle_button = 1;
e_config_save_queue();
}
CONFIG_VERSION_CHECK(17)
{
CONFIG_VERSION_UPDATE_INFO(17);
e_config->touch_extras = 0;
e_config_save_queue();
}
}

e_config->config_version = E_CONFIG_FILE_VERSION;
Expand Down Expand Up @@ -1221,6 +1228,7 @@ while (!e_config)
E_CONFIG_LIMIT(e_config->mouse_accel_threshold, 0, 10);
E_CONFIG_LIMIT(e_config->mouse_natural_scroll, 0, 1);

E_CONFIG_LIMIT(e_config->touch_extras, 0, 1);
E_CONFIG_LIMIT(e_config->touch_tap_to_click, 0, 1);
E_CONFIG_LIMIT(e_config->touch_clickpad, 0, 1);
E_CONFIG_LIMIT(e_config->touch_scrolling_2finger, 0, 1);
Expand Down
3 changes: 2 additions & 1 deletion src/bin/e_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ typedef struct _E_Event_Config_Icon_Theme E_Event_Config_Icon_Theme;
/* 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 16
#define E_CONFIG_FILE_GENERATION 17
#define E_CONFIG_FILE_VERSION ((E_CONFIG_FILE_EPOCH * 1000000) + E_CONFIG_FILE_GENERATION)

struct _E_Config
Expand Down Expand Up @@ -243,6 +243,7 @@ struct _E_Config
unsigned char mouse_natural_scroll; // GUI
unsigned char mouse_emulate_middle_button; // GUI

unsigned char touch_extras; // GUI
double touch_accel; // GUI
unsigned char touch_natural_scroll; // GUI
unsigned char touch_emulate_middle_button; // GUI
Expand Down
122 changes: 64 additions & 58 deletions src/bin/e_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,68 @@ _handle_dev_prop(int dev_slot, const char *dev, const char *prop, Device_Flags d
}
}

static void
generic_apply()
{
// generic accel - if synatics or evdev props found?
{
int accel_numerator, accel_denominator;

accel_numerator = 20 + (e_config->mouse_accel * 20.0);
accel_denominator = 10;
ecore_x_pointer_control_set(accel_numerator, accel_denominator,
e_config->mouse_accel_threshold);
}

// button mapping - for mouse hand and natural scroll
{
unsigned char map[256] = { 0 };
int n;

if (ecore_x_pointer_mapping_get(map, 256))
{
for (n = 0; n < 256; n++)
{
if (!map[n]) break;
}
if (n < 3)
{
map[0] = 1;
map[1] = 2;
map[2] = 3;
n = 3;
}
if (e_config->mouse_hand == E_MOUSE_HAND_RIGHT)
{
map[0] = 1;
map[2] = 3;
}
else if (e_config->mouse_hand == E_MOUSE_HAND_LEFT)
{
map[0] = 3;
map[2] = 1;
}
// if we are not on libinput or synaptics drivers anywehre then
// swap buttons the old fashioned way
//~ if ((n >= 5) && (!synaptics_check))
//~ {
//~ if (e_config->mouse_natural_scroll)
//~ {
//~ map[3] = 5;
//~ map[4] = 4;
//~ }
//~ else
//~ {
//~ map[3] = 4;
//~ map[4] = 5;
//~ }
//~ }
ecore_x_pointer_mapping_set(map, n);
}
}
}


static void
devices_apply(Eina_Bool force)
{
Expand Down Expand Up @@ -472,68 +534,12 @@ devices_apply(Eina_Bool force)
ecore_x_input_device_properties_free(props, num_props);
}
}

// generic accel - if synatics or evdev props found?
{
int accel_numerator, accel_denominator;

accel_numerator = 20 + (e_config->mouse_accel * 20.0);
accel_denominator = 10;
ecore_x_pointer_control_set(accel_numerator, accel_denominator,
e_config->mouse_accel_threshold);
}

// button mapping - for mouse hand and natural scroll
{
unsigned char map[256] = { 0 };
int n;

if (ecore_x_pointer_mapping_get(map, 256))
{
for (n = 0; n < 256; n++)
{
if (!map[n]) break;
}
if (n < 3)
{
map[0] = 1;
map[1] = 2;
map[2] = 3;
n = 3;
}
if (e_config->mouse_hand == E_MOUSE_HAND_RIGHT)
{
map[0] = 1;
map[2] = 3;
}
else if (e_config->mouse_hand == E_MOUSE_HAND_LEFT)
{
map[0] = 3;
map[2] = 1;
}
// if we are not on libinput or synaptics drivers anywehre then
// swap buttons the old fashioned way
if ((n >= 5) && (!driver_libinput) && (!driver_synaptics))
{
if (e_config->mouse_natural_scroll)
{
map[3] = 5;
map[4] = 4;
}
else
{
map[3] = 4;
map[4] = 5;
}
}
ecore_x_pointer_mapping_set(map, n);
}
}
}

EAPI int
e_mouse_update(void)
{
devices_apply(EINA_TRUE);
if (e_config->touch_extras) devices_apply(EINA_TRUE);
generic_apply();
return 1;
}
52 changes: 46 additions & 6 deletions src/modules/conf_interaction/e_int_config_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct _E_Config_Dialog_Data
int touch_scrolling_circular;
int touch_scrolling_horiz;
int touch_palm_detect;
int touch_extras;
};

E_Config_Dialog *
Expand Down Expand Up @@ -87,6 +88,7 @@ _fill_data(E_Config_Dialog_Data *cfdata)
cfdata->touch_scrolling_circular = e_config->touch_scrolling_circular;
cfdata->touch_scrolling_horiz = e_config->touch_scrolling_horiz;
cfdata->touch_palm_detect = e_config->touch_palm_detect;
cfdata->touch_extras = e_config->touch_extras;
}

static void *
Expand Down Expand Up @@ -115,6 +117,7 @@ _basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfda
(cfdata->mouse_emulate_middle_button == e_config->mouse_emulate_middle_button) &&
EINA_DBL_EQ(cfdata->touch_accel, e_config->touch_accel) &&
(cfdata->touch_natural_scroll == e_config->touch_natural_scroll) &&
(cfdata->touch_extras == e_config->touch_extras) &&
(cfdata->touch_emulate_middle_button == e_config->touch_emulate_middle_button) &&
(cfdata->touch_tap_to_click == e_config->touch_tap_to_click) &&
(cfdata->touch_clickpad == e_config->touch_clickpad) &&
Expand Down Expand Up @@ -150,6 +153,7 @@ _basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
e_config->mouse_natural_scroll = cfdata->mouse_natural_scroll;
e_config->mouse_emulate_middle_button = cfdata->mouse_emulate_middle_button;

e_config->touch_extras = cfdata->touch_extras;
e_config->touch_accel = cfdata->touch_accel;
e_config->touch_natural_scroll = cfdata->touch_natural_scroll;
e_config->touch_emulate_middle_button = cfdata->touch_emulate_middle_button;
Expand Down Expand Up @@ -189,10 +193,26 @@ _use_e_cursor_cb_change(void *data, Evas_Object *obj __UNUSED__)
e_widget_disabled_set(cfdata->gui.idle_cursor, disabled);
}

//~ static void
//~ _mouse_cb_change(void *data, Evas_Object *obj __UNUSED__)
//~ {
//~ E_Config_Dialog_Data *cfdata = data;
//~ e_widget_check_checked_set(cfdata->touch_natur, e_widget_check_checked_get(cfdata->mouse_natur));
//~ cfdata->touch_natural_scroll = cfdata->mouse_natural_scroll;
//~ }

static void
_touch_cb_change(void *data, Evas_Object *obj __UNUSED__)
{
E_Config_Dialog_Data *cfdata = data;
//~ e_widget_check_checked_set(cfdata->mouse_natur, e_widget_check_checked_get(cfdata->touch_natur));
cfdata->mouse_natural_scroll = cfdata->touch_natural_scroll;
}

static Evas_Object *
_basic_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data *cfdata)
{
Evas_Object *otb, *ol, *of, *ob, *oc;
Evas_Object *otb, *ol, *of, *ob, *oc, *ex;
E_Radio_Group *rg;

otb = e_widget_toolbook_add(evas, (24 * e_scale), (24 * e_scale));
Expand Down Expand Up @@ -271,56 +291,76 @@ _basic_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dial

e_widget_list_object_append(ol, of, 1, 0, 0.5);

of = e_widget_framelist_add(evas, _("Scrolling"), 0);
//~ of = e_widget_framelist_add(evas, _("Scrolling"), 0);

oc = e_widget_check_add(evas, _("Natural scrolling"), &(cfdata->mouse_natural_scroll));
e_widget_framelist_object_append(of, oc);
//~ oc = e_widget_check_add(evas, _("Natural scrolling"), &(cfdata->mouse_natural_scroll));
//~ cfdata->mouse_natur = oc;
//~ e_widget_on_change_hook_set(cfdata->mouse_natur, _mouse_cb_change, cfdata);
//~ e_widget_framelist_object_append(of, oc);

e_widget_list_object_append(ol, of, 1, 0, 0.5);
//~ e_widget_list_object_append(ol, of, 1, 0, 0.5);
e_widget_toolbook_page_append(otb, NULL, _("Mouse"), ol,
1, 0, 1, 0, 0.5, 0.0);

ol = e_widget_list_add(evas, 0, 0);

of = e_widget_framelist_add(evas, _("Settings"), 0);

ex = e_widget_check_add(evas, _("Enable Devices Extras"), &(cfdata->touch_extras));
e_widget_framelist_object_append(of, ex);

e_widget_list_object_append(ol, of, 1, 0, 0.5);

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

ob = e_widget_slider_add(evas, 1, 0, _("%1.1f"), -1.0, 1.0, 0.1, 0,
&(cfdata->touch_accel), NULL, 100);
e_widget_check_widget_disable_on_unchecked_add(ex, ob);
e_widget_framelist_object_append(of, ob);

e_widget_list_object_append(ol, of, 1, 0, 0.5);

of = e_widget_framelist_add(evas, _("Buttons"), 0);

oc = e_widget_check_add(evas, _("Tap to click"), &(cfdata->touch_tap_to_click));
e_widget_check_widget_disable_on_unchecked_add(ex, oc);
e_widget_framelist_object_append(of, oc);

oc = e_widget_check_add(evas, _("Middle mouse button emulation"), &(cfdata->touch_emulate_middle_button));
e_widget_check_widget_disable_on_unchecked_add(ex, oc);
e_widget_framelist_object_append(of, oc);

oc = e_widget_check_add(evas, _("Clickpad"), &(cfdata->touch_clickpad));
e_widget_check_widget_disable_on_unchecked_add(ex, oc);
e_widget_framelist_object_append(of, oc);

oc = e_widget_check_add(evas, _("Palm detect"), &(cfdata->touch_palm_detect));
e_widget_check_widget_disable_on_unchecked_add(ex, oc);
e_widget_framelist_object_append(of, oc);

e_widget_list_object_append(ol, of, 1, 0, 0.5);

of = e_widget_framelist_add(evas, _("Scrolling"), 0);

oc = e_widget_check_add(evas, _("Natural scrolling"), &(cfdata->touch_natural_scroll));
e_widget_on_change_hook_set(oc, _touch_cb_change, cfdata);
cfdata->mouse_natural_scroll = cfdata->touch_natural_scroll;
e_widget_check_widget_disable_on_unchecked_add(ex, oc);
e_widget_framelist_object_append(of, oc);

oc = e_widget_check_add(evas, _("Horizontal scrolling"), &(cfdata->touch_scrolling_horiz));
e_widget_check_widget_disable_on_unchecked_add(ex, oc);
e_widget_framelist_object_append(of, oc);

oc = e_widget_check_add(evas, _("Edge scrolling"), &(cfdata->touch_scrolling_edge));
e_widget_check_widget_disable_on_unchecked_add(ex, oc);
e_widget_framelist_object_append(of, oc);

oc = e_widget_check_add(evas, _("2 finger scrolling"), &(cfdata->touch_scrolling_2finger));
e_widget_check_widget_disable_on_unchecked_add(ex, oc);
e_widget_framelist_object_append(of, oc);

oc = e_widget_check_add(evas, _("Circular scrolling"), &(cfdata->touch_scrolling_circular));
e_widget_check_widget_disable_on_unchecked_add(ex, oc);
e_widget_framelist_object_append(of, oc);

e_widget_list_object_append(ol, of, 1, 0, 0.5);
Expand Down

0 comments on commit 2c648d7

Please sign in to comment.