Runtime toggle for touch user interface.

NOTE: just like everything else that was set from command line and now
we have preferences, we are being replaced with the actual preferences
system. This will be fixed in another commit.



SVN revision: 52230
This commit is contained in:
Gustavo Sverzut Barbieri 2010-09-14 02:04:28 +00:00
parent 954f3d4249
commit 220909643e
4 changed files with 54 additions and 0 deletions

View File

@ -1020,6 +1020,7 @@ chrome_prefs_apply(Evas_Object *chrome)
ewk_view_setting_auto_load_images_set(view, prefs_enable_auto_load_images_get(prefs));
ewk_view_setting_auto_shrink_images_set(view, prefs_enable_auto_shrink_images_get(prefs));
ewk_view_setting_scripts_window_open_set(view, prefs_allow_popup_get(prefs));
view_touch_interface_set(view, prefs_enable_touch_interface_get(prefs));
window_mouse_enabled_set(win->win, prefs_enable_mouse_cursor_get(prefs));
}
@ -1076,6 +1077,11 @@ pref_updated(More_Menu_Preference *p, void *new_value)
SET_PREF_TO_ALL_VIEWS(ewk_view_setting_scripts_window_open_set, *((int *)new_value));
break;
}
case EVE_PREF_TOUCH_INTERFACE:
{
SET_PREF_TO_ALL_VIEWS(view_touch_interface_set, *((int*)new_value));
break;
}
case EVE_PREF_MOUSE_CURSOR:
{
EINA_LIST_FOREACH(app.windows, win_iter, win)
@ -1891,6 +1897,7 @@ chrome_add(Browser_Window *win, const char *url)
}
ewk_view_setting_enable_plugins_set(view, !win->app->disable_plugins);
view_touch_interface_set(view, !win->app->disable_touch_interface);
evas_object_event_callback_add(view, EVAS_CALLBACK_KEY_DOWN, on_key_down,
win);

View File

@ -342,6 +342,8 @@ static const Ecore_Getopt options = {
ECORE_GETOPT_STORE_STR('U', "user-agent",
"user agent string to use. Special cases=iphone,safari,chrome,firefox,ie,ie9,ie8,ie7."),
ECORE_GETOPT_STORE_DEF_UINT('R', "rotate", "Screen Rotation in degrees", 0),
ECORE_GETOPT_STORE_DEF_BOOL('T', "disable-touch-interface",
"disable touch interface handling of mouse events", 1),
ECORE_GETOPT_VERSION('V', "version"),
ECORE_GETOPT_COPYRIGHT('C', "copyright"),
ECORE_GETOPT_LICENSE('L', "license"),
@ -366,6 +368,7 @@ elm_main(int argc, char **argv)
ECORE_GETOPT_VALUE_BOOL(app.disable_mouse),
ECORE_GETOPT_VALUE_STR(user_agent),
ECORE_GETOPT_VALUE_UINT(app.rotate),
ECORE_GETOPT_VALUE_BOOL(app.disable_touch_interface),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option),

View File

@ -58,6 +58,7 @@ struct _App
Eina_Bool is_fullscreen;
Eina_Bool disable_plugins;
Eina_Bool disable_mouse;
Eina_Bool disable_touch_interface;
unsigned int rotate;
};
@ -89,6 +90,8 @@ void view_zoom_next_down(Evas_Object *view);
Eina_Bool view_context_menu_set(Evas_Object *view, Evas_Object *widget, Ewk_Context_Menu *menu);
Evas_Object * view_context_menu_widget_get(Evas_Object *view);
Ewk_Context_Menu * view_context_menu_get(Evas_Object *view);
void view_touch_interface_set(Evas_Object *view, Eina_Bool setting);
Eina_Bool view_touch_interface_get(const Evas_Object *view);
Evas_Object * chrome_add(Browser_Window *win, const char *url);
void chrome_focused_notify(Evas_Object *chrome);

View File

@ -169,6 +169,7 @@ struct _View_Smart_Data
{
Eina_Bool first_calculate : 1;
Eina_Bool animated_zoom : 1;
Eina_Bool touch_interface : 1;
} flags;
Evas_Object *context_menu;
@ -1025,6 +1026,7 @@ _view_smart_add(Evas_Object *o)
View_Smart_Data *sd = calloc(1, sizeof(View_Smart_Data));
evas_object_smart_data_set(o, sd);
sd->flags.first_calculate = EINA_TRUE;
sd->flags.touch_interface = EINA_TRUE;
/* call parent and let it do the whole thing */
_parent_sc.sc.add(o);
@ -1129,6 +1131,10 @@ _view_smart_mouse_down(Ewk_View_Smart_Data *esd, const Evas_Event_Mouse_Down *ev
{
View_Smart_Data *sd = (View_Smart_Data *)esd;
/* non-touch interface just forwards events */
if (!sd->flags.touch_interface)
goto forward_event;
/* do not handle down when doing animated zoom */
if (sd->flags.animated_zoom)
return EINA_FALSE;
@ -1208,6 +1214,10 @@ _view_smart_mouse_up(Ewk_View_Smart_Data *esd, const Evas_Event_Mouse_Up *ev)
View_Smart_Data *sd = (View_Smart_Data *)esd;
Eina_Bool used;
/* non-touch interface just forwards events */
if (!sd->flags.touch_interface)
return _parent_sc.mouse_up(esd, ev);
/* cancel any previous kinetic animation (but should have none) */
if (sd->animator.kinetic)
{
@ -1614,3 +1624,34 @@ Ewk_Context_Menu *view_context_menu_get(Evas_Object *view)
return evas_object_data_get(view, "context-menu");
}
void view_touch_interface_set(Evas_Object *view, Eina_Bool setting)
{
Evas_Event_Mouse_Up ev;
VIEW_SD_GET_OR_RETURN(view, sd);
setting = !!setting;
if (sd->flags.touch_interface == setting) return;
sd->flags.touch_interface = setting;
if (setting) return; /* nothing to do to enter touch mode */
if (sd->animator.kinetic)
{
ecore_animator_del(sd->animator.kinetic);
sd->animator.kinetic = NULL;
}
memset(&ev, 0, sizeof(ev));
if (sd->animator.pan)
{
sd->pan.count = 0; /* avoid loops in _view_pan_stop() */
_view_pan_stop(sd, &ev);
}
else if (sd->animator.zoom)
_view_zoom_stop(sd, &ev);
}
Eina_Bool view_touch_interface_get(const Evas_Object *view)
{
VIEW_SD_GET_OR_RETURN(view, sd, EINA_FALSE);
return sd->flags.touch_interface;
}