📄 widget_ctk.c
字号:
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
HDIa_memFree(MSF_MODID_WIDGET, p);
}
/*****************************************************************************
* FUNCTION
* widget_init_ctk
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void widget_init_ctk(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
ctk_app_create_struct app_create;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
CTK_INIT_STRUCT(app_create);
strncpy(app_create.app_name, "widget", CTK_APP_NAME_LEN + 1);
app_create.app_name[CTK_APP_NAME_LEN] = '\0';
app_create.app_taskid = MOD_WAP;
/*
* The memory mechanism of CTK service can't use HDIa_mem...
* because there are some bugs in MMS code
*
app_create.app_mem_alloc_fp = widget_ctk_malloc;
app_create.app_mem_free_fp = widget_ctk_mfree;
*/
app_create.app_rpc_MMI_void_fp = widget_execute_MMI;
app_create.app_rpc_UA_void_fp = widget_execute_WAP;
app_create.app_rpc_MMI_handle_fp = (ctk_rpc_handle) widget_execute_MMI_i; /* Assume ctk_object_handle is interger-type */
app_create.app_rpc_UA_handle_fp = (ctk_rpc_handle) widget_execute_WAP_i;
widget_ctk_appid = ctk_app_create(&app_create);
widget_current_ctk = NULL;
}
/*****************************************************************************
* FUNCTION
* widget_deinit_ctk
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void widget_deinit_ctk(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
ASSERT(widget_ctk_appid);
ctk_app_close(widget_ctk_appid);
widget_ctk_appid = 0;
}
/*****************************************************************************
* FUNCTION
* widget_current_ctk_state
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
*
*****************************************************************************/
widget_ctk_state_enum widget_current_ctk_state(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* If widget_current_ctk != NULL, it must be WIDGET_CTK_STATE_ENTERED or WIDGET_CTK_STATE_PAUSED */
if (widget_current_ctk == NULL)
{
return WIDGET_CTK_STATE_NONE;
}
else
{
return widget_current_ctk->ctk_state;
}
}
/*****************************************************************************
* FUNCTION
* widget_current_ctk_MMI_screen_id
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
*
*****************************************************************************/
ctk_MMI_screen_id widget_current_ctk_MMI_screen_id(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (widget_current_ctk == NULL)
{
return 0;
}
else
{
WAP_DBG_ASSERT(widget_current_ctk->ctk_state == WIDGET_CTK_STATE_ENTERED ||
widget_current_ctk->ctk_state == WIDGET_CTK_STATE_PAUSED);
return ctk_screen_get_MMI_screen_id(widget_current_ctk->ctk_screen);
}
}
/*****************************************************************************
* FUNCTION
* widget_release_ctk_data
* DESCRIPTION
* release CTK data
* PARAMETERS
* ctk [IN] The target MsfWindow containg CTK screen
* RETURNS
* void
*****************************************************************************/
void widget_release_ctk_data(widget_ctk_struct *ctk)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* widget_ctk_leave_screen_if_present should be invoked before this point */
if (ctk == widget_current_ctk)
{
/* If this happens, setting widget_current_ctk as NULL does not solve it */
WAP_DBG_ASSERT(0);
widget_current_ctk = NULL;
}
ctk_screen_close(ctk->ctk_screen);
}
/*****************************************************************************
* FUNCTION
* widget_prepare_to_enter_ctk_window
* DESCRIPTION
* Used when the CTK window is focused (it might not be in widget_screen)
* PARAMETERS
* ctk [IN] The target MsfWindow containg CTK screen
* RETURNS
* void
*****************************************************************************/
void widget_prepare_to_enter_ctk_window(widget_ctk_struct *ctk)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* Wait until widget_paint_hdlr */
if (ctk->ctk_state == WIDGET_CTK_STATE_NONE)
{
/*
* Note that we do not set widget_current_ctk here, but in widget_paint_ctk instead.
* Because it doesn't guarentee to be in widget screen here, and the last CTK screen
* might still be active
*/
ctk->ctk_state = WIDGET_CTK_STATE_PREPARE_TO_ENTER;
}
}
/*****************************************************************************
* FUNCTION
* widget_paint_ctk
* DESCRIPTION
* Go to the CTK screen if the window is just focused
* PARAMETERS
* ctk [IN] The target MsfWindow containg CTK screen
* RETURNS
* void
*****************************************************************************/
void widget_paint_ctk(widget_ctk_struct *ctk)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/*
* After leaving CTK screen and go back to widget screen, ctk->ctk_state will be WIDGET_CTK_STATE_NONE
* We should not paint it, but do nothing until the focus is changed to another window!!
* This guarenteed synchronization between different CTK screens
*/
if (ctk->ctk_state == WIDGET_CTK_STATE_PREPARE_TO_ENTER)
{
WAP_DBG_ASSERT(WIDGET_IS_MMI_TASK());
/* We are in MMI task, ctk_screen_enter is not invoked by RPC */
ctk_screen_invoke_on_enter(ctk->ctk_screen);
WAP_DBG_ASSERT(!WGUI_CTX->is_widget_screen);
/*
* Althogh we will set the state in widget_ctk_on_enter(),
* * we still set it here to prevent enter CTK screen again
*/
WAP_DBG_ASSERT(ctk->ctk_state == WIDGET_CTK_STATE_ENTERED);
ctk->ctk_state = WIDGET_CTK_STATE_ENTERED; // TODO: we should remove this line
ctk->idlescreen_seq_no = WIPC_CTX->idlescreen_seq_no;
WAP_DBG_ASSERT(widget_current_ctk == NULL);
widget_current_ctk = ctk;
}
}
/*****************************************************************************
* FUNCTION
* widget_MMI_ctk_leave_screen_if_present
* DESCRIPTION
* Leave the current CTK screen (if any)
* 1. If it is active, leave it
* 2. If it is interrupted by another MMI screen, delete the history node
* PARAMETERS
* arg [IN]
* to_remove_handle the target MsfWindow or NULL for delete any active target window(?)
* to_remove_modId the target module ID or -1 for delete any active target window(?)
* RETURNS
* void
* REMARKS
* Typically WAP already defocus or release a MsfCtkWindow object, and we need to remove
* the corresponding MMI screen (active or in history). Otherwise, MMI might display a CTK
* screen with invalid MsfCtkWindow object.
*****************************************************************************/
typedef struct
{
widget_header_struct *to_remove_handle;
int to_remove_modId;
} widget_ctk_leave_screen_param_struct;
static void widget_MMI_ctk_leave_screen_if_present(void *arg)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
widget_ctk_leave_screen_param_struct *param = (widget_ctk_leave_screen_param_struct*) arg;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
WIDGET_LOG("widget_MMI_ctk_leave_screen_if_present()");
/*
* Tmp fix. Although this should not happen, but ctk_screen_general_key_handler is executed in
* * MMI task and it might invoke MSF_WIDGET_SET_IN_FOCUS in MMI task
* * (which also invokes widget_ctk_leave_screen_if_present), and when MMI task received RPC
* * request, widget_current_ctk might be already changed.
*/
if (widget_current_ctk == NULL)
{
WAP_DBG_ASSERT(0);
return;
}
if (param->to_remove_handle != NULL)
{
if (param->to_remove_handle != _H(widget_current_ctk))
{
WAP_DBG_ASSERT(0);
return;
}
}
else if (param->to_remove_modId >= 0)
{
if (widget_current_ctk->module_id != (kal_uint8) param->to_remove_modId)
{
WAP_DBG_ASSERT(0);
return;
}
}
switch (widget_current_ctk->ctk_state)
{
case WIDGET_CTK_STATE_ENTERED:
ASSERT(!WGUI_CTX->is_widget_screen);
WIDGET_LOG("widget_MMI_ctk_leave_screen_if_present() - WIDGET_CTK_STATE_ENTERED");
if (IsScreenPresent(WAP_SCREEN_WIDGET))
{
GoBackToHistory(WAP_SCREEN_WIDGET);
}
else
{
WAP_DBG_ASSERT(0);
GoBackHistory();
}
/* Otherwise, it might press End key in widget CTK screen */
break;
case WIDGET_CTK_STATE_PAUSED:
/*
* We should not remove the new MMI screen that interrupts the CTK screen.
* Instead, when the new MMI screen exits, it go back to widget directly.
*
* FIXME. There is still a race condition here that the new MMI screen exits
* before we call in ctk_screen_remove_from_history
*/
WIDGET_LOG("widget_MMI_ctk_leave_screen_if_present() - WIDGET_CTK_STATE_PAUSED");
DeleteScreenIfPresent(ctk_screen_get_MMI_screen_id(widget_current_ctk->ctk_screen));
widget_current_ctk->ctk_state = WIDGET_CTK_STATE_NONE;
break;
default:
EXT_ASSERT(0, (kal_uint32) widget_current_ctk->ctk_state, (kal_uint32) widget_current_ctk, 0);
}
widget_current_ctk = NULL; /* Prevent from being invoked more than one time */
}
/*****************************************************************************
* FUNCTION
* widget_ctk_leave_screen_if_present
* DESCRIPTION
*
* PARAMETERS
* to_remove_handle [IN]
* to_remove_modId [IN]
* RETURNS
* void
*****************************************************************************/
void widget_ctk_leave_screen_if_present(widget_header_struct *to_remove_handle, int to_remove_modId)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -