From 2c648d75b77241c5c47dd30adf9186556fbf90e4 Mon Sep 17 00:00:00 2001 From: thewaiter Date: Fri, 26 Aug 2022 20:25:59 +0200 Subject: [PATCH] Mouse and touchpad settings modifs --- config/bodhi/e.src | 2 +- src/bin/e_config.c | 8 ++ src/bin/e_config.h | 3 +- src/bin/e_mouse.c | 122 +++++++++--------- .../conf_interaction/e_int_config_mouse.c | 52 +++++++- 5 files changed, 121 insertions(+), 66 deletions(-) diff --git a/config/bodhi/e.src b/config/bodhi/e.src index b9df85429b..4d4799be4f 100644 --- a/config/bodhi/e.src +++ b/config/bodhi/e.src @@ -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"; diff --git a/src/bin/e_config.c b/src/bin/e_config.c index c135be9916..d2d3c5cd1b 100644 --- a/src/bin/e_config.c +++ b/src/bin/e_config.c @@ -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); @@ -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; @@ -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); diff --git a/src/bin/e_config.h b/src/bin/e_config.h index a08e96500a..61d5b0eddc 100644 --- a/src/bin/e_config.h +++ b/src/bin/e_config.h @@ -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 @@ -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 diff --git a/src/bin/e_mouse.c b/src/bin/e_mouse.c index a171b8aa8c..84c77cb560 100644 --- a/src/bin/e_mouse.c +++ b/src/bin/e_mouse.c @@ -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) { @@ -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; } diff --git a/src/modules/conf_interaction/e_int_config_mouse.c b/src/modules/conf_interaction/e_int_config_mouse.c index e3b93013e7..0191c4dd8d 100644 --- a/src/modules/conf_interaction/e_int_config_mouse.c +++ b/src/modules/conf_interaction/e_int_config_mouse.c @@ -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 * @@ -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 * @@ -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) && @@ -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; @@ -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)); @@ -271,37 +291,50 @@ _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); @@ -309,18 +342,25 @@ _basic_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dial 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);