From: gs86.lee Date: Mon, 19 Aug 2013 10:59:19 +0000 (+0900) Subject: changed rotation API X-Git-Tag: 2.2.1_release~6^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d80df5c93d47e6b2900150851f5a07a0a86390a0;p=apps%2Fhome%2Fvolume-app.git changed rotation API Change-Id: Idbf521caf7de61ae648cee24ed6e2dfc7b20d3d9 --- diff --git a/src/_logic.c b/src/_logic.c index 9288786..6bbbe02 100755 --- a/src/_logic.c +++ b/src/_logic.c @@ -284,8 +284,6 @@ Eina_Bool _volume_show(void *data) if(status == UNLOCK_STATUS) { - _rotate_func(ad); - /* set type once when volume app shows */ ad->type = _get_volume_type(); ad->step = _get_step(ad->type); @@ -943,6 +941,34 @@ int _make_volume_layout(void *data) { return 0; } +/* rotation event callback func. */ +static void _rotate_changed_cb(void *data, Evas_Object *obj, void *event_info) +{ + struct appdata *ad = data; + retvm_if(ad == NULL, NULL, "Invalid argument: appdata is NULL\n"); + + static int current_angle = 0; + //int changed_angle = elm_win_rotation_get(obj); + ad->angle = elm_win_rotation_get(obj); + + _D("window rotated [%d] => [%d]", current_angle, ad->angle); + /* If S View Lock is not running, execute rotations function */ + if(current_angle != ad->angle) { + current_angle = ad->angle; + switch(current_angle){ + case 90 : + case 270 : + _D("show,landscape"); + elm_object_signal_emit(ad->block_events, "show,landscape", "bg"); + break; + default : + _D("show,portrait"); + elm_object_signal_emit(ad->block_events, "show,portrait", "bg"); + break; + } + } +} + int _app_create(struct appdata *ad) { _D("%s\n", __func__); @@ -968,6 +994,16 @@ int _app_create(struct appdata *ad) return -1; } + /* Set available rotations */ + if (elm_win_wm_rotation_supported_get(ad->win)) { + const int rots[4] = { 0, 90, 180, 270 }; + elm_win_wm_rotation_available_rotations_set(ad->win, &rots, 4); + _D("set available rotations"); + } + + /* rotation event callback */ + evas_object_smart_callback_add(ad->win, "wm,rotation,changed", _rotate_changed_cb, ad); + _init_svi(ad); /* vconf changed callback */ @@ -992,144 +1028,6 @@ int _app_create(struct appdata *ad) return ret; } -int __utilx_ss_get_window_property(Display *dpy, Window win, Atom atom, - Atom type, unsigned int *val, - unsigned int len) -{ - unsigned char *prop_ret = NULL; - Atom type_ret = -1; - unsigned long bytes_after = 0; - unsigned long num_ret = -1; - int format_ret = -1; - unsigned int i = 0; - int num = 0; - - prop_ret = NULL; - if (XGetWindowProperty(dpy, win, atom, 0, 0x7fffffff, False, - type, &type_ret, &format_ret, &num_ret, - &bytes_after, &prop_ret) != Success) - return -1; - - if (type_ret != type || format_ret != 32) - num = -1; - else if (num_ret == 0 || !prop_ret) - num = 0; - else { - if (num_ret < len) - len = num_ret; - for (i = 0; i < len; i++) { - val[i] = ((unsigned long *)prop_ret)[i]; - } - num = len; - } - - if (prop_ret) - XFree(prop_ret); - - return num; -} - -int _x_rotation_get(Display *dpy, void *data) -{ - Window active_win = 0; - Window root_win = 0; - int rotation = -1; - int ret = -1; - - Atom atom_active_win; - Atom atom_win_rotate_angle; - - retvm_if(dpy == NULL, -1, "dpy is NULL\n"); - root_win = XDefaultRootWindow(dpy); - - atom_active_win = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False); - ret = __utilx_ss_get_window_property(dpy, root_win, atom_active_win, - XA_WINDOW, - (unsigned int *)&active_win, 1); - - if(ret < 0) - return ret; - - atom_win_rotate_angle = XInternAtom(dpy, "_E_ILLUME_ROTATE_ROOT_ANGLE", False); - ret = __utilx_ss_get_window_property(dpy, root_win, - atom_win_rotate_angle, XA_CARDINAL, - (unsigned int *)&rotation, 1); - - if(ret != -1) - return rotation; - - return -1; -} - -int _volume_popup_resize(void *data, int angle) -{ - int rotation = 0; - struct appdata *ad = (struct appdata *)data; - retvm_if(ad->win == NULL, -1, "Invalid argument: window is NULL\n"); - retvm_if(ad->block_events == NULL, -1, "Invalid argument: notify is NULL\n"); - - if(angle == -1) - rotation = ad->angle; - else - rotation = angle; - - switch(rotation){ - case 90 : - case 270 : - _D("show,landscape"); - elm_object_signal_emit(ad->block_events, "show,landscape", "bg"); - break; - case 0 : - case 180 : - default : - _D("show,portrait"); - elm_object_signal_emit(ad->block_events, "show,portrait", "bg"); - break; - } - return 1; -} - -int _efl_rotate(Display *dpy, void *data) -{ - int rotation = -1; - struct appdata *ad = (struct appdata *)data; - retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n"); - - rotation = _x_rotation_get(dpy, ad); - _D("Window rotations : %d", rotation); - - if(rotation == -1) { - rotation = 0; - } - - if(rotation >= 0){ - elm_win_rotation_set(ad->win, rotation); - ad->angle = rotation; - return _volume_popup_resize(data, rotation); - } - - return 0; -} - -int _rotate_func(void *data) -{ - _D("%s", __func__); - struct appdata *ad = (struct appdata *)data; - Display *d = NULL; - int ret = 0; - - retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n"); - - d = XOpenDisplay(NULL); - ret = _efl_rotate(d, ad); - - if(d != NULL){ - XCloseDisplay(d); - } - - return ret; -} - int myterm(bundle *b, void *data) { _D("%s\n", __func__); diff --git a/src/_logic.h b/src/_logic.h index eb51f7c..5465ffa 100755 --- a/src/_logic.h +++ b/src/_logic.h @@ -27,7 +27,6 @@ volume_type_t _get_volume_type(void); int _close_volume(void *data); int _app_create(struct appdata *ad); int _app_pause(struct appdata *ad); -int _rotate_func(void *data); int _app_reset(bundle *b, void *data); Eina_Bool popup_timer_cb(void *data); void _init_press_timers(void *data); diff --git a/src/volume.c b/src/volume.c index e90d815..0cdc3ad 100755 --- a/src/volume.c +++ b/src/volume.c @@ -28,22 +28,6 @@ struct text_part { char *msgid; }; -static Eina_Bool rotate_cb(void *data, int type, void *event) -{ - struct appdata *ad = data; - Ecore_X_Event_Client_Message *ev = event; - - retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n"); - if (!event){ - return ECORE_CALLBACK_RENEW; - } - - if (ev->message_type == ECORE_X_ATOM_E_ILLUME_ROTATE_ROOT_ANGLE){ - _rotate_func(data); - } - return ECORE_CALLBACK_RENEW; -} - static int app_create(void *data) { struct appdata *ad = data; @@ -62,10 +46,7 @@ static int app_create(void *data) ad->flag_deleting = EINA_FALSE; ad->flag_vib = EINA_FALSE; ad->lastval = 0; - - /* add rotation event callback */ - ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, - rotate_cb, (void *)data); + ad->angle = 0; return 0; }