From 2d30da3529a4e64e3539cd2a4cfb19c1a5344b1f Mon Sep 17 00:00:00 2001 From: Stanislav Radomskiy Date: Fri, 26 Apr 2013 15:20:26 +0300 Subject: [PATCH] Fixing keyboard orientation/rotation issue in landscape mode RSA bug id: TREL-202 Change-Id: I0ada49748f0cfd010b880b72836896d8f3c5dbc9 --- main/email.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/main/email.c b/main/email.c index 918e942..7c52b95 100755 --- a/main/email.c +++ b/main/email.c @@ -70,7 +70,7 @@ static int app_low_battery(void *data); static int app_lang_changed(void *data); static int app_region_changed(void *data); -static Evas_Object *create_win(const char *name); +static Evas_Object *create_win(const char *name, struct appdata *ad); static void win_del(void *data, Evas_Object *obj, void *event); static void launch_email_ug(service_h b, struct appdata *ad); static int check_app_svc_operation(service_h b, struct appdata *ad, gint account_id); @@ -84,7 +84,7 @@ static void result_cb(ui_gadget_h ug, service_h result, void *priv); static void destroy_cb(ui_gadget_h ug, void *priv); static void aul_destroy_cb(ui_gadget_h ug, void *priv); ui_gadget_h create_ug(char *ug_name, service_h bd, void *data); -static int _email_main_rotation_cb(app_device_orientation_e m, void *data); +static void _email_main_rotation_cb(void *data, Evas_Object *obj, void *event); static void _email_timezone_change_cb(keynode_t *key, void *data); @@ -267,15 +267,18 @@ ui_gadget_h create_ug(char *ug_name, service_h bd, void *data) return ug; } -static int _email_main_rotation_cb(app_device_orientation_e m, void *data) +static void _email_main_rotation_cb(void *data, Evas_Object *obj, void *event) { debug_log(""); struct appdata *ad = data; - int rotation_mode = -1; + enum ug_event rotation_mode; + int m = 0; if (ad == NULL || ad->win_main == NULL) { - return -1; + debug_log("ad or ad->win_main is NULL"); + return; } + m = elm_win_rotation_get(ad->win_main); debug_log("app_device_orientation: %d", m); switch (m) { @@ -307,7 +310,7 @@ static int _email_main_rotation_cb(app_device_orientation_e m, void *data) ret = service_create(&service); if (!service) { debug_log("service create failed"); - return 0; + return; } snprintf(buf, sizeof(buf), "%d", rotation_mode); @@ -320,7 +323,7 @@ static int _email_main_rotation_cb(app_device_orientation_e m, void *data) debug_log("service_destroy: %d", ret); } - return 0; + return; } static bool app_create(void *data) @@ -333,7 +336,8 @@ static bool app_create(void *data) elm_config_preferred_engine_set("opengl_x11"); //"software_x11" /* create window */ - win = create_win(PACKAGE); + win = create_win(PACKAGE, ad); + debug_log("create_win, ad: %p", ad); if (win == NULL) { debug_log("create_win returns NULL"); return false; @@ -492,7 +496,7 @@ int main(int argc, char *argv[]) ops.service = (app_service_cb)app_reset; ops.low_memory = (app_low_memory_cb)app_low_memory; ops.low_battery = (app_low_battery_cb)app_low_battery; - ops.device_orientation = (app_device_orientation_cb)_email_main_rotation_cb; + ops.device_orientation = NULL; ops.language_changed = (app_language_changed_cb)app_lang_changed; ops.region_format_changed = (app_region_format_changed_cb)app_region_changed; @@ -505,7 +509,7 @@ int main(int argc, char *argv[]) return app_efl_main(&argc, &argv, &ops, &ad); } -static Evas_Object *create_win(const char *name) +static Evas_Object *create_win(const char *name, struct appdata *ad) { debug_log(""); Evas_Object *eo; @@ -517,6 +521,20 @@ static Evas_Object *create_win(const char *name) evas_object_smart_callback_add(eo, "delete,request", win_del, NULL); ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h); evas_object_resize(eo, w, h); + + if (elm_win_wm_rotation_supported_get(eo)) { + const int rots[4] = { APP_DEVICE_ORIENTATION_0, + APP_DEVICE_ORIENTATION_90, + APP_DEVICE_ORIENTATION_180, + APP_DEVICE_ORIENTATION_270 }; + debug_log(""); + elm_win_wm_rotation_available_rotations_set(eo, rots, 4); + } + /* pass '-1' value to this API then it will unset + * preferred rotation angle */ + elm_win_wm_rotation_preferred_rotation_set(eo, -1); + evas_object_smart_callback_add(eo, "wm,rotation,changed", + _email_main_rotation_cb, ad); } return eo; -- 2.7.4