diff options
| author | Grissiom <[email protected]> | 2013-02-01 10:27:10 +0800 |
|---|---|---|
| committer | Grissiom <[email protected]> | 2013-02-01 10:27:10 +0800 |
| commit | f06c70feed0941b5bceedcecf89e9aa22034aca8 (patch) | |
| tree | 89fd3a989b4d88fc72b39eaad6567de3a3d23874 /components/rtgui/common/rtgui_system.c | |
| parent | 4f02e67bef7eacee5102d7730356663d9c889e15 (diff) | |
sync with rtgui-0.6
Diffstat (limited to 'components/rtgui/common/rtgui_system.c')
| -rw-r--r-- | components/rtgui/common/rtgui_system.c | 60 |
1 files changed, 17 insertions, 43 deletions
diff --git a/components/rtgui/common/rtgui_system.c b/components/rtgui/common/rtgui_system.c index 576655dadf..781b25adc5 100644 --- a/components/rtgui/common/rtgui_system.c +++ b/components/rtgui/common/rtgui_system.c @@ -70,7 +70,7 @@ static void rtgui_time_out(void *parameter) event.timer = timer; - rtgui_send(timer->tid, &(event.parent), sizeof(rtgui_event_timer_t)); + rtgui_send(timer->app, &(event.parent), sizeof(rtgui_event_timer_t)); } rtgui_timer_t *rtgui_timer_create(rt_int32_t time, rt_int32_t flag, rtgui_timeout_func timeout, void *parameter) @@ -78,7 +78,7 @@ rtgui_timer_t *rtgui_timer_create(rt_int32_t time, rt_int32_t flag, rtgui_timeou rtgui_timer_t *timer; timer = (rtgui_timer_t *) rtgui_malloc(sizeof(rtgui_timer_t)); - timer->tid = rt_thread_self(); + timer->app = rtgui_app_self(); timer->timeout = timeout; timer->user_data = parameter; @@ -371,7 +371,7 @@ const char *event_string[] = #define DBG_MSG(x) rt_kprintf x -static void rtgui_event_dump(rt_thread_t tid, rtgui_event_t *event) +static void rtgui_event_dump(struct rtgui_app* app, rtgui_event_t *event) { char *sender = "(unknown)"; @@ -389,12 +389,12 @@ static void rtgui_event_dump(rt_thread_t tid, rtgui_event_t *event) if (event->type >= RTGUI_EVENT_COMMAND) { - rt_kprintf("%s -- USER EVENT --> %s \n", sender, tid->name); + rt_kprintf("%s -- USER EVENT --> %s \n", sender, app->name); return ; } else { - rt_kprintf("%s -- %s --> %s ", sender, event_string[event->type], tid->name); + rt_kprintf("%s -- %s --> %s ", sender, event_string[event->type], app->name); } switch (event->type) @@ -545,88 +545,68 @@ static void rtgui_event_dump(rt_thread_t tid, rtgui_event_t *event) } #else #define DBG_MSG(x) -#define rtgui_event_dump(tid, event) +#define rtgui_event_dump(app, event) #endif /************************************************************************/ /* RTGUI IPC APIs */ /************************************************************************/ -rt_err_t rtgui_send(rt_thread_t tid, rtgui_event_t *event, rt_size_t event_size) +rt_err_t rtgui_send(struct rtgui_app* app, rtgui_event_t *event, rt_size_t event_size) { rt_err_t result; - struct rtgui_app *app; - RT_ASSERT(tid != RT_NULL); + RT_ASSERT(app != RT_NULL); RT_ASSERT(event != RT_NULL); RT_ASSERT(event_size != 0); - rtgui_event_dump(tid, event); - - /* find struct rtgui_application */ - app = (struct rtgui_app *)(tid->user_data); - if (app == RT_NULL) - return -RT_ERROR; + rtgui_event_dump(app, event); result = rt_mq_send(app->mq, event, event_size); if (result != RT_EOK) { if (event->type != RTGUI_EVENT_TIMER) - rt_kprintf("send event to %s failed\n", app->tid->name); + rt_kprintf("send event to %s failed\n", app->name); } return result; } RTM_EXPORT(rtgui_send); -rt_err_t rtgui_send_urgent(rt_thread_t tid, rtgui_event_t *event, rt_size_t event_size) +rt_err_t rtgui_send_urgent(struct rtgui_app* app, rtgui_event_t *event, rt_size_t event_size) { rt_err_t result; - struct rtgui_app *app; - RT_ASSERT(tid != RT_NULL); + RT_ASSERT(app != RT_NULL); RT_ASSERT(event != RT_NULL); RT_ASSERT(event_size != 0); - rtgui_event_dump(tid, event); - - /* find rtgui_application */ - app = (struct rtgui_app *)(tid->user_data); - if (app == RT_NULL) - return -RT_ERROR; + rtgui_event_dump(app, event); result = rt_mq_urgent(app->mq, event, event_size); if (result != RT_EOK) - rt_kprintf("send ergent event failed\n"); + rt_kprintf("send ergent event to %s failed\n", app->name); return result; } RTM_EXPORT(rtgui_send_urgent); -rt_err_t rtgui_send_sync(rt_thread_t tid, rtgui_event_t *event, rt_size_t event_size) +rt_err_t rtgui_send_sync(struct rtgui_app* app, rtgui_event_t *event, rt_size_t event_size) { rt_err_t r; - struct rtgui_app *app; rt_int32_t ack_buffer, ack_status; struct rt_mailbox ack_mb; - RT_ASSERT(tid != RT_NULL); + RT_ASSERT(app != RT_NULL); RT_ASSERT(event != RT_NULL); RT_ASSERT(event_size != 0); - rtgui_event_dump(tid, event); + rtgui_event_dump(app, event); /* init ack mailbox */ r = rt_mb_init(&ack_mb, "ack", &ack_buffer, 1, 0); if (r != RT_EOK) goto __return; - app = (struct rtgui_app *)(tid->user_data); - if (app == RT_NULL) - { - r = -RT_ERROR; - goto __return; - } - event->ack = &ack_mb; r = rt_mq_send(app->mq, event, event_size); if (r != RT_EOK) @@ -728,12 +708,6 @@ rt_err_t rtgui_recv_filter(rt_uint32_t type, rtgui_event_t *event, rt_size_t eve } RTM_EXPORT(rtgui_recv_filter); -rt_thread_t rtgui_get_server(void) -{ - return rt_thread_find("rtgui"); -} -RTM_EXPORT(rtgui_get_server); - void rtgui_set_mainwin_rect(struct rtgui_rect *rect) { _mainwin_rect = *rect; |
