fixed tickernoti problem and adding smack rules
authoryoungsub ko <ys4610.ko@samsung.com>
Mon, 24 Jun 2013 11:26:28 +0000 (20:26 +0900)
committeryoungsub ko <ys4610.ko@samsung.com>
Mon, 24 Jun 2013 11:26:28 +0000 (20:26 +0900)
daemon/notifications/noti_win.c
daemon/notifications/ticker.c
daemon/quickpanel-ui.c
org.tizen.quickpanel.rule

index 2261226..c97fe7d 100755 (executable)
@@ -125,6 +125,85 @@ static void _del(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj,
        free(wd);
 }
 
+#ifdef HAVE_X
+static void _update_geometry_on_rotation(Evas_Object *obj, int angle,
+               int *x, int *y, int *w)
+{
+       Evas_Coord root_w, root_h;
+       struct Internal_Data *wd = evas_object_data_get(obj, data_key);
+
+       if (!wd)
+               return;
+
+       ecore_x_window_size_get(ecore_x_window_root_first_get(), &root_w,
+               &root_h);
+
+       /* rotate window */
+       switch (angle) {
+       case 90:
+               *w = root_h;
+               if (wd->orient == NOTI_ORIENT_BOTTOM)
+                       *x = root_w - wd->h;
+               break;
+       case 270:
+               *w = root_h;
+               if (!(wd->orient == NOTI_ORIENT_BOTTOM))
+                       *x = root_w - wd->h;
+               break;
+       case 180:
+               *w = root_w;
+               if (!wd->orient == NOTI_ORIENT_BOTTOM)
+                       *y = root_h - wd->h;
+               break;
+       case 0:
+       default:
+               *w = root_w;
+               if (wd->orient == NOTI_ORIENT_BOTTOM)
+                       *y = root_h - wd->h;
+               break;
+       }
+}
+
+static void _win_rotated(Evas_Object *obj)
+{
+       int x = 0;
+       int y = 0;
+       int w = 0;
+       int angle = 0;
+       struct Internal_Data *wd =  evas_object_data_get(obj, data_key);
+
+       if (!wd)
+               return;
+       angle = elm_win_rotation_get(obj);
+       if (angle % 90)
+               return;
+       angle %= 360;
+       if (angle < 0)
+               angle += 360;
+       wd->angle = angle;
+
+       _update_geometry_on_rotation(obj, wd->angle, &x, &y, &w);
+
+       evas_object_move(obj, x, y);
+       wd->w = w;
+       evas_object_resize(obj, wd->w, wd->h);
+}
+
+static Eina_Bool _prop_change(void *data, int type __UNUSED__, void *event)
+{
+       Ecore_X_Event_Window_Property *ev;
+       struct Internal_Data *wd = evas_object_data_get(data, data_key);
+
+       if (!wd)
+               return ECORE_CALLBACK_PASS_ON;
+       ev = event;
+       if (ev->atom == ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE)
+               if (ev->win == elm_win_xwindow_get(data))
+                       _win_rotated(data);
+       return ECORE_CALLBACK_PASS_ON;
+}
+#endif
+
 HAPI Evas_Object *noti_win_add(Evas_Object *parent)
 {
        Evas_Object *win;
@@ -162,6 +241,8 @@ HAPI Evas_Object *noti_win_add(Evas_Object *parent)
 #ifdef HAVE_X
        ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, NULL);
        evas_object_resize(win, w, NOTI_HEIGHT);
+       wd->rotation_event_handler = ecore_event_handler_add(
+               ECORE_X_EVENT_WINDOW_PROPERTY, _prop_change, win);
 #endif
        wd->w = w;
        wd->h = NOTI_HEIGHT;
index 7f01ae0..cac9ce0 100755 (executable)
@@ -52,8 +52,9 @@ static int quickpanel_ticker_init(void *data);
 static int quickpanel_ticker_fini(void *data);
 static int quickpanel_ticker_enter_hib(void *data);
 static int quickpanel_ticker_leave_hib(void *data);
-static void quickpanel_ticker_reflesh(void *data);
+void quickpanel_ticker_reflesh(void *data);
 static void _quickpanel_ticker_destroy_tickernoti(Evas_Object *tickernoti);
+static int _quickpanel_ticker_get_angle(void *data);
 
 QP_Module ticker = {
        .name = "ticker",
@@ -62,7 +63,7 @@ QP_Module ticker = {
        .hib_enter = quickpanel_ticker_enter_hib,
        .hib_leave = quickpanel_ticker_leave_hib,
        .lang_changed = NULL,
-       .refresh = NULL,
+       .refresh = quickpanel_ticker_reflesh
 };
 
 static int _is_lockscreen_launched(void) {
@@ -478,52 +479,6 @@ static void _noti_hide_cb(void *data, Evas_Object *obj,
        _quickpanel_ticker_hide(data);
 }
 
-static void _quickpanel_ticker_win_rotated(Evas_Object *ticker_win) {
-       int angle = 0;
-       Evas_Coord root_w, root_h;
-       int x = 0, y = 0, w = 0, h = 0;
-
-       retif(ticker_win == NULL, , "invalid data");
-
-       angle = elm_win_rotation_get(ticker_win);
-       ecore_x_window_size_get(ecore_x_window_root_first_get(), &root_w, &root_h);
-       evas_object_size_hint_min_get(ticker_win, NULL, &g_noti_height);
-
-       // rotate win
-       switch(angle)
-       {
-               case 90:
-                       h = g_noti_height;
-                       w = root_h;
-                       break;
-               case 270:
-                       h = g_noti_height;
-                       w = root_h;
-                       x = root_w - g_noti_height;
-                       break;
-               case 180:
-                       w = root_w;
-                       h = g_noti_height;
-                       y = root_h - g_noti_height;
-                       break;
-               case 0:
-               default:
-                       w = root_w;
-                       h = g_noti_height;
-                       break;
-       }
-
-       if (ticker_win != NULL) {
-               evas_object_move(ticker_win, x, y);
-               evas_object_resize(ticker_win, w, h);
-       }
-}
-
-static void _quickpanel_ticker_rotate_cb(void *data, Evas_Object *obj, void *event)
-{
-       _quickpanel_ticker_win_rotated(obj);
-}
-
 static Evas_Object *_quickpanel_ticker_create_tickernoti(void *data)
 {
        notification_h noti = (notification_h) data;
@@ -560,15 +515,6 @@ static Evas_Object *_quickpanel_ticker_create_tickernoti(void *data)
        evas_object_size_hint_min_set(detail, 1, noti_height);
        g_noti_height = noti_height;
 
-       if (elm_win_wm_rotation_supported_get(tickernoti))
-       {
-               int rots[4] = { 0, 90, 180, 270 };
-               elm_win_wm_rotation_available_rotations_set(tickernoti, rots, 4);
-
-               evas_object_smart_callback_add(tickernoti, "wm,rotation,changed",
-                               _quickpanel_ticker_rotate_cb, data);
-       }
-
        noti_win_content_set(tickernoti, detail);
 
        icon = _quickpanel_ticker_create_icon(detail, noti);
@@ -620,6 +566,93 @@ static void _quickpanel_ticker_destroy_tickernoti(Evas_Object *tickernoti)
        evas_object_del(tickernoti);
 }
 
+static int _quickpanel_ticker_get_angle(void *data)
+{
+       struct appdata *ad = (struct appdata *)data;
+       Ecore_X_Window xwin, root;
+       int ret = 0, angle = 0, count = 0;
+       unsigned char *prop_data = NULL;
+
+       xwin = elm_win_xwindow_get(ad->win);
+       root = ecore_x_window_root_get(xwin);
+
+       ret = ecore_x_window_prop_property_get(root,
+                               ECORE_X_ATOM_E_ILLUME_ROTATE_ROOT_ANGLE,
+                               ECORE_X_ATOM_CARDINAL, 32,
+                               &prop_data, &count);
+
+       if (ret && prop_data) {
+               memcpy(&angle, prop_data, sizeof(int));
+
+               if (prop_data)
+                       free(prop_data);
+
+               return angle;
+       } else {
+               ERR("Fail to get angle");
+               if (prop_data)
+                       free(prop_data);
+
+               return -1;
+       }
+}
+
+static void _quickpanel_ticker_update_geometry_on_rotation(void *data, int *x, int *y, int *w, int *h) {
+       int angle = 0;
+
+       if (!data)
+               return;
+       angle = _quickpanel_ticker_get_angle(data);
+       Evas_Coord root_w, root_h;
+
+       /*
+        * manually calculate win_tickernoti_indi window position & size
+        *  - win_indi is not full size window
+        */
+       ecore_x_window_size_get(ecore_x_window_root_first_get(), &root_w, &root_h);
+       evas_object_size_hint_min_get(g_ticker, NULL, &g_noti_height);
+
+       DBG("angle:%d", angle);
+
+       // rotate win
+       switch(angle)
+       {
+               case 90:
+                       *h = g_noti_height;
+                       *w = root_h;
+                       break;
+               case 270:
+                       *h = g_noti_height;
+                       *w = root_h;
+                       *x = root_w - g_noti_height;
+                       break;
+               case 180:
+                       *w = root_w;
+                       *h = g_noti_height;
+                       *y = root_h - g_noti_height;
+                       break;
+               case 0:
+               default:
+                       *w = root_w;
+                       *h = g_noti_height;
+                       break;
+       }
+       elm_win_rotation_set(g_ticker, angle);
+}
+
+static void _quickpanel_ticker_win_rotated(void *data) {
+       retif(data == NULL, ,"data is NULL");
+       struct appdata *ad = data;
+       int x = 0, y = 0, w = 0, h = 0;
+
+       _quickpanel_ticker_update_geometry_on_rotation(ad, &x, &y, &w, &h);
+
+       if (g_ticker != NULL) {
+               evas_object_move(g_ticker, x, y);
+               evas_object_resize(g_ticker, w, h);
+       }
+}
+
 static void _quickpanel_noti_media_feedback_sound(notification_h noti) {
        retif(noti == NULL, ,"op_list is NULL");
 
@@ -754,6 +787,13 @@ static void _quickpanel_ticker_noti_detailed_changed_cb(void *data, notification
                        notification_free(noti);
                        return;
                }
+
+               if (_quickpanel_ticker_get_angle(quickpanel_get_app_data()) == -1) {
+                       ERR("[workaround] WM not ready");
+                       notification_free(noti);
+                       return;
+               }
+
                /* Display ticker */
                if (g_timer) {
                        ecore_timer_del(g_timer);
@@ -771,7 +811,7 @@ static void _quickpanel_ticker_noti_detailed_changed_cb(void *data, notification
                g_timer = ecore_timer_add(QP_TICKER_DURATION,
                                _quickpanel_ticker_timeout_cb, noti);
 
-               _quickpanel_ticker_win_rotated(g_ticker);
+               _quickpanel_ticker_win_rotated(data);
                evas_object_show(g_ticker);
 
                evas_object_event_callback_add(g_ticker, EVAS_CALLBACK_SHOW,
@@ -819,3 +859,12 @@ static int quickpanel_ticker_leave_hib(void *data)
 {
        return QP_OK;
 }
+
+void quickpanel_ticker_reflesh(void *data)
+{
+       retif(data == NULL, , "Invalid parameter!");
+
+       if (g_ticker != NULL) {
+               _quickpanel_ticker_win_rotated(data);
+       }
+}
index cbc9028..6194dca 100755 (executable)
@@ -331,16 +331,22 @@ static void _quickpanel_ui_rotation(void *data, int new_angle)
        }
 }
 
+void quickpanel_ticker_reflesh(void *data);
+
 static Eina_Bool quickpanel_ui_client_message_cb(void *data, int type,
                                                 void *event)
 {
+       int new_angle = 0;
        struct appdata *ad = data;
        Ecore_X_Event_Client_Message *ev = event;
 
        retif(data == NULL || event == NULL,
                ECORE_CALLBACK_RENEW, "Invalid parameter!");
 
-       if (ev->message_type == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE) {
+       if (ev->message_type == ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE) {
+                       new_angle = ev->data.l[0];
+                       quickpanel_ticker_reflesh(ad);
+       } else if (ev->message_type == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE) {
                if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF) {
                        ad->is_opened = 0;
                        qp_closed_modules(data);
index 9dda6d7..a1561f4 100755 (executable)
@@ -31,8 +31,10 @@ org.tizen.quickpanel data-provider-master rw
 org.tizen.quickpanel data-provider-master::notification rw
 org.tizen.quickpanel org.tizen.setting::default-resources rx
 org.tizen.quickpanel starter::vconf rw
+org.tizen.quickpanel device::app_logging w
+org.tizen.quickpanel device::sys_logging w
 
-e17 org.tizen.quickpanel w
+e17 org.tizen.quickpanel rw
 system org.tizen.quickpanel w
 display_wd org.tizen.quickpanel w
 dbus org.tizen.quickpanel rwx