/* 0 : default handler, 1:user handler */
}
-void _gallery_rotation_cb(app_device_orientation_e m, void *data)
+/**
+ * Perform an UI update according to the given rotation angle.
+ * Do not call elm_win_rotation_set / elm_win_rotation_with_resize_set.
+ * ecore_evas has already called
+ * elm_win_rotation_set / elm_win_rotation_with_resize_set function.
+ *
+ * Please set NULL to app_device_orientation_cb member of app_event_callback_s structure.
+ * And don't use app_device_orientation_cb callback which is supported by capi
+*/
+static void __gallery_rot_changed_cb(void *data, Evas_Object *obj, void *event)
{
GL_CHECK(data);
- gl_dbg("Appcore Rotation mode: %d", m);
gl_appdata *ad = (gl_appdata *)data;
GL_CHECK(ad->maininfo.win);
- enum ug_event evt = UG_EVENT_NONE;
- int r = -1;
-
- ad->maininfo.rotate_mode = m;
+ /* changed_ang value is 0 90 180 270 */
+ int changed_ang = elm_win_rotation_get(ad->maininfo.win);
+ gl_dbg("New angle: %d, old angle: %d", changed_ang,
+ ad->maininfo.rotate_mode);
+ if (changed_ang == ad->maininfo.rotate_mode)
+ return;
+ else
+ ad->maininfo.rotate_mode = changed_ang;
- switch (m) {
+ enum ug_event evt = UG_EVENT_NONE;
+ /* Send event to UG */
+ switch (changed_ang) {
case APP_DEVICE_ORIENTATION_0:
- r = 0;
evt = UG_EVENT_ROTATE_PORTRAIT;
break;
case APP_DEVICE_ORIENTATION_90:
- r = 90;
evt = UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN;
break;
case APP_DEVICE_ORIENTATION_180:
- r = 180;
evt = UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN;
break;
case APP_DEVICE_ORIENTATION_270:
- r = 270;
evt = UG_EVENT_ROTATE_LANDSCAPE;
break;
- default:
- r = -1;
- break;
}
-
ug_send_event(evt);
- if (r >= 0 && ad->maininfo.win)
- elm_win_rotation_with_resize_set(ad->maininfo.win, m);
-
int view_mode = gl_get_view_mode(ad);
if (ad->uginfo.ug_called_by_me) {
if (view_mode == GL_VIEW_ALBUMS){
eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
gl_dbg_launch(" elm_win_add:end");
if (eo) {
+ /**
+ * Register a list of rotation angles that your application supports
+ *
+ * The window manager is going to decide rotation of application windows
+ * by referring the list of rotation angles.
+ * In this means if your application sets 0, 90 and 270 degrees to be the list of
+ * supported rotation angles, the window manager will not rotate your
+ * application window if the device is rotated 180 degrees
+ */
+ 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 };
+ gl_dbg("");
+ 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);
+
elm_win_autodel_set(eo, EINA_TRUE);
elm_win_title_set(eo, name);
evas_object_smart_callback_add(eo, "profile,changed",
profile_changed_cb, ad);
evas_object_smart_callback_add(eo, "delete,request",
_gallery_win_del_cb, ad);
+ evas_object_smart_callback_add(eo, "wm,rotation,changed",
+ __gallery_rot_changed_cb, data);
ad->maininfo.win_scale = elm_config_scale_get();
gl_dbg("main window scale: %f", ad->maininfo.win_scale);
evas_object_data_set(ad->maininfo.naviframe, GL_NAVIFRAME_OBJ_DATA_KEY,
conform);
-
gl_dbg("gl_ctrl_create_ctrlbar_view: done");
- if (gl_is_rotation_locked()) {
- gl_dbg("Rotation is in locked state!");
- } else {
- int mode = APP_DEVICE_ORIENTATION_0;
- mode = app_get_device_orientation();
- ad->maininfo.rotate_mode = mode;
- }
-
/* Create view layout and Set view layout to Naviframe*/
_gallery_create_view_ly(ad);
ug_pause();
}
-/* auto rotate view after resume if disabling/re-enabling rotate device */
-static int __gallery_resume_update_rotation_mode(gl_appdata *ad)
-{
- GL_CHECK_VAL(ad, -1);
- int display_mode = -1;
- int device_mode = APP_DEVICE_ORIENTATION_0;
-
- /**
- * display_mode is view mode, e.x. view is portrait normal
- * device_mode is target mode, e.x. device is portrait normal
- */
- display_mode = elm_win_rotation_get(ad->maininfo.win);
- device_mode = app_get_device_orientation();
- gl_dbg("display_mode is %d, device_mode is %d\n", display_mode,
- device_mode);
-
- /**
- * disable rotate when view isn't portrait normal, then after resume,
- * rotate view to portrait
- */
- if (gl_is_rotation_locked() &&
- (display_mode != APP_DEVICE_ORIENTATION_0))
- _gallery_rotation_cb(APP_DEVICE_ORIENTATION_0, (void*)ad);
- /**
- * re-enable rotate when device isn't in portrait normal
- * and view is in portrait normal, then after resume,
- * rotate view by device_mode
- */
- else if (!gl_is_rotation_locked() && (device_mode != display_mode))
- _gallery_rotation_cb(device_mode, (void*)ad);
- return 0;
-}
-
static void _gallery_resume(void *data)
{
gl_dbg_launch("resume:start");
/* Update view */
gl_update_view(ad, GL_UPDATE_VIEW_NORMAL);
- __gallery_resume_update_rotation_mode(ad);
gl_dbg_launch("resume:done");
}
gl_dbgE("Failed to parse parameters, update view!");
gl_update_view(ad, GL_UPDATE_VIEW_NORMAL);
}
- /* Rotate window if it's not APP_DEVICE_ORIENTATION_0 mode */
- if (!gl_is_rotation_locked()) {
- int mode = APP_DEVICE_ORIENTATION_0;
- mode = app_get_device_orientation();
- if (mode != APP_DEVICE_ORIENTATION_0) {
- gl_dbg("Rotation window!");
- _gallery_rotation_cb(mode, ad);
- }
- }
elm_win_activate(ad->maininfo.win);
return;
}
event_callback.service = _gallery_reset;
event_callback.low_memory = NULL;
event_callback.low_battery = _gallery_low_battery_cb;
- event_callback.device_orientation = _gallery_rotation_cb;
+ event_callback.device_orientation = NULL;
event_callback.language_changed = _gallery_lang_changed_cb;
event_callback.region_format_changed = NULL;