bool
mp_app_grab_mm_keys(struct appdata *ad)
{
	utilx_grab_key(ecore_x_display_get(), ad->xwin, KEY_MEDIA, OR_EXCLUSIVE_GRAB);
	int err = media_key_reserve(_mp_app_media_key_event_cb, ad);
	if (err != MEDIA_KEY_ERROR_NONE) {
		mp_error("media_key_reserve().. [0x%x]", err);
		return false;
	}

	return true;
}
int create_and_show_basic_popup_min(struct appdata *ad)
{
	Evas_Object *btn1;
	Evas_Object *btn2;

	ad->popup_poweroff = elm_popup_add(ad->win_main);
	if (ad->popup_poweroff == NULL) {
		system_print("\n System-popup : Add popup failed \n");
		return -1;
	}

	evas_object_size_hint_weight_set(ad->popup_poweroff, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	elm_object_text_set(ad->popup_poweroff, _("IDS_ST_BODY_POWER_OFF"));
	elm_object_part_text_set(ad->popup_poweroff, "title,text", _("IDS_COM_BODY_SYSTEM_INFO_ABB"));

	btn1 = elm_button_add(ad->popup_poweroff);
	elm_object_text_set(btn1, _("IDS_COM_SK_OK"));
	elm_object_part_content_set(ad->popup_poweroff, "button1", btn1);
	elm_object_style_set (btn1,"popup_button/default");
	evas_object_smart_callback_add(btn1, "clicked", poweroff_response_yes_cb_min, ad);
	btn2 = elm_button_add(ad->popup_poweroff);
	elm_object_text_set(btn2, _("IDS_COM_SK_CANCEL"));
	elm_object_part_content_set(ad->popup_poweroff, "button2", btn2);
	elm_object_style_set (btn2,"popup_button/default");
	evas_object_smart_callback_add(btn2, "clicked", poweroff_response_no_cb_min, ad);

	Ecore_X_Window xwin;
	xwin = elm_win_xwindow_get(ad->popup_poweroff);
	ecore_x_netwm_window_type_set(xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
	utilx_grab_key(ecore_x_display_get(), xwin, KEY_SELECT, SHARED_GRAB);
	ecore_event_handler_add(ECORE_EVENT_KEY_UP, poweroff_response_no_cb_min, NULL);
	evas_object_show(ad->popup_poweroff);
	
	return 0;
	
}
int X_make_syspopup(bundle *b, Display *dpy, Window xwin, void *win,
		    int (*rotate_func) (Display*, Window, syspopup*),
		    syspopup_handler *handler, void *user_data)
{
	syspopup *sp = NULL;
	syspopup_info_t *info;
	const char *popup_name = _syspopup_get_name_from_bundle(b);
	XWindowAttributes attr;
	int is_unviewable = 0;

	if (popup_name == NULL || handler == NULL)
		return -1;

	info = _syspopup_info_get(popup_name);
	if (info == NULL)
		return -1;

	if (_syspopup_init(__X_syspopup_term_handler,
			   __X_syspopup_timeout_handler) < 0){
		_syspopup_info_free(info);
		return -1;
	}

	XGetWindowAttributes(dpy, xwin, &attr);

	if (attr.map_state == IsViewable) {
		XUnmapWindow(dpy, xwin);
		is_unviewable = 1;
	}

	sp = (syspopup *) malloc(sizeof(syspopup));
	if (sp == NULL) {
		_syspopup_info_free(info);
		return -1;
	}
	
	sp->name = strdup(info->name);
	sp->def_term_fn = handler->def_term_fn;
	sp->def_timeout_fn = handler->def_timeout_fn;
	sp->user_data = user_data;
	sp->internal_data = (void *)xwin;
	sp->win = (void *)win;
	sp->rotate_cb = rotate_func;
	sp->timeout_id = 0;
	sp->dupped_bundle = bundle_dup(b);
	_syspopup_add_new(sp);

	_syspopup_set_term_type(sp, info);
	_syspopup_set_endkey_type(sp, info);

	_syspopup_reset_timeout(sp, info);

	__X_syspopup_change_xwin_type(dpy, xwin);
	utilx_set_system_notification_level(dpy, xwin, info->prio);

	utilx_grab_key(dpy, xwin, KEY_END, TOP_POSITION_GRAB);

	if (info->focus == 1) {
		__X_syspopup_disable_focus (dpy, xwin);
	}

	rotate_func(dpy, xwin, sp);

	if (is_unviewable == 1) {
		XMapWindow(dpy, xwin);
	}

	_syspopup_info_free(info);

	return sp->id;
}