elm/check: fix emission of legacy "changed" callback

legacy "check" and "toggle" widgets operate differently:
* check emits only the "toggle" event
* toggle emits "toggle", "on", "off"

legacy also must not emit events when the widget's state is changed
programmatically

to handle this effectively, check whether the event has been emitted for
each state when the signal is emitted from the theme, and track this
for subsequent uses to ensure that exactly one event is triggered
when it should be

Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D9831
This commit is contained in:
Mike Blumenkrantz 2019-09-18 12:02:35 -04:00 committed by Marcel Hollerbach
parent 011022ae1b
commit 7767ce884a
2 changed files with 26 additions and 2 deletions

View File

@ -50,6 +50,25 @@ static const Elm_Action key_actions[] = {
{NULL, NULL}
};
static void
_check_legacy_event(Eo *obj)
{
EFL_UI_CHECK_DATA_GET(obj, pd);
if (pd->selected)
{
if (pd->legacy_changed_emitted_select) return;
pd->legacy_changed_emitted_select = EINA_TRUE;
pd->legacy_changed_emitted_unselect = EINA_FALSE;
}
else
{
if (pd->legacy_changed_emitted_unselect) return;
pd->legacy_changed_emitted_unselect = EINA_TRUE;
pd->legacy_changed_emitted_select = EINA_FALSE;
}
evas_object_smart_callback_call(obj, "changed", NULL);
}
static void
_activate(Evas_Object *obj)
{
@ -97,8 +116,7 @@ _activate(Evas_Object *obj)
// "efl,state,check,on" or "efl,state,check,off" for eo-api
efl_ui_selectable_selected_set(obj, !efl_ui_selectable_selected_get(obj));
if (elm_widget_is_legacy(obj))
evas_object_smart_callback_call(obj, "changed", NULL);
_check_legacy_event(obj);
if (_elm_config->atspi_mode)
efl_access_state_changed_signal_emit(obj,
EFL_ACCESS_STATE_TYPE_CHECKED,
@ -231,6 +249,8 @@ _on_check_off(void *data,
Evas_Object *obj = data;
_flush_selected(obj, EINA_FALSE);
if (elm_widget_is_legacy(obj))
_check_legacy_event(obj);
}
static void
@ -242,6 +262,8 @@ _on_check_on(void *data,
Evas_Object *obj = data;
_flush_selected(obj, EINA_TRUE);
if (elm_widget_is_legacy(obj))
_check_legacy_event(obj);
}
static void

View File

@ -28,6 +28,8 @@ struct _Efl_Ui_Check_Data
{
Eina_Bool *statep;
Eina_Bool selected;
Eina_Bool legacy_changed_emitted_unselect : 1;
Eina_Bool legacy_changed_emitted_select : 1;
};
/**