Use new elementary APIs to support the window manager rotation
authorQingtao Zhang <qintao.zhang@samsung.com>
Mon, 15 Apr 2013 07:38:20 +0000 (15:38 +0800)
committerQingtao Zhang <qintao.zhang@samsung.com>
Mon, 15 Apr 2013 07:38:20 +0000 (15:38 +0800)
Change-Id: Ic93f73d1c0a50f58da95008a942d9d9174ece938

CMakeLists.txt
include/gallery.h
packaging/org.tizen.gallery.spec
src/gallery.c
src/widget/gl-notify.c

index 8c5fe00241752548e7f613c7be5e9c4685a9589b..1352dd441c9a97f7983dbb07f6097f62e41388d3 100755 (executable)
@@ -92,7 +92,7 @@ pkg_check_modules(pkgs REQUIRED
        capi-appfw-app-manager
        haptic
        utilX
-       status
+       notification
 )
 
 FOREACH(flag ${pkgs_CFLAGS})
index f504715b2d1779b8c8b4eef2b28d9d554cbf7d82..a4ed60e6bb51a5ea20538b99e90642b2c0f54831 100755 (executable)
@@ -491,7 +491,6 @@ struct _gl_appdata
 typedef struct _gl_appdata gl_appdata;
 
 int gallery_reset_app(void *data);
-void _gallery_rotation_cb(app_device_orientation_e m, void *data);
 
 #ifdef _cplusplus
 }
index 2f67a8ae21e4f8b27c82a155244a61b885c58508..652c82fb566c73ff16cd5aa5a57821ab29e7dbb5 100755 (executable)
@@ -34,7 +34,7 @@ BuildRequires:  pkgconfig(capi-appfw-application)
 BuildRequires:  pkgconfig(capi-appfw-app-manager)
 BuildRequires:  pkgconfig(haptic)
 BuildRequires:  pkgconfig(utilX)
-BuildRequires:  pkgconfig(status)
+BuildRequires:  pkgconfig(notification)
 
 Requires: media-server ug-image-viewer-efl
 
index af5e0e38fcedb81d1f796895cc791a283f042d5a..82c8bcc038fe202bd89177a55d4b71ab2105b337 100755 (executable)
@@ -150,44 +150,47 @@ static void _gallery_low_battery_cb(void *data)
        /* 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){
@@ -238,12 +241,34 @@ static Evas_Object *_gallery_create_win(void *data, const char *name)
        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);
 
@@ -449,17 +474,8 @@ static int _gallery_init_view(gl_appdata *ad)
        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);
 
@@ -653,39 +669,6 @@ static void _gallery_pause(void *data)
        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");
@@ -710,7 +693,6 @@ static void _gallery_resume(void *data)
 
        /* Update view */
        gl_update_view(ad, GL_UPDATE_VIEW_NORMAL);
-       __gallery_resume_update_rotation_mode(ad);
 
        gl_dbg_launch("resume:done");
 }
@@ -1080,15 +1062,6 @@ static void _gallery_reset(service_h service, void *data)
                        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;
        }
@@ -1145,7 +1118,7 @@ int main(int argc, char *argv[])
        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;
 
index 0264e88850c911b9c9895bbd6174f3cf17e047af..e897d950e7ca26ee5726799f97e4c60729472a73 100755 (executable)
@@ -14,7 +14,7 @@
   * limitations under the License.
   */
 
-#include <status.h>
+#include <notification.h>
 #include "gl-notify.h"
 #include "gl-thumbs.h"
 #include "gl-controlbar.h"
@@ -56,7 +56,7 @@ static int __gl_notify_add(void *data, Evas_Object *parent)
 int _gl_notify_create_notiinfo(void *data, const char *text)
 {
        GL_CHECK_VAL(text, -1);
-       int ret = status_message_post(text);
+       int ret = notification_status_message_post(text);
        if (ret != 0)
                gl_dbgE("status_message_post()... [0x%x]!", ret);
        return ret;