fixed tickernoti problem and adding smack rules
[apps/home/quickpanel.git] / daemon / notifications / noti_win.c
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;