From 6dac26e5b0b7f9dedcc94869bd3d3a4716e9b600 Mon Sep 17 00:00:00 2001 From: "bernard.xiong" Date: Sun, 7 Feb 2010 23:42:49 +0000 Subject: [PATCH] remove more fields on window create. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@386 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- rtgui/common/rtgui_system.c | 28 +++++++++++++++++++++++++--- rtgui/include/rtgui/event.h | 23 +++++++++++------------ rtgui/server/server.c | 2 +- rtgui/server/topwin.c | 27 +++++++++++++++++---------- rtgui/widgets/toplevel.c | 15 ++++++++++----- rtgui/widgets/window.c | 8 +++++--- 6 files changed, 69 insertions(+), 34 deletions(-) diff --git a/rtgui/common/rtgui_system.c b/rtgui/common/rtgui_system.c index b64940a9c..b2f86ac96 100644 --- a/rtgui/common/rtgui_system.c +++ b/rtgui/common/rtgui_system.c @@ -154,11 +154,19 @@ static void rtgui_event_dump(rt_thread_t tid, rtgui_event_t* event) struct rtgui_event_win_create *create = (struct rtgui_event_win_create*)event; rt_kprintf(" win: %s at (x1:%d, y1:%d, x2:%d, y2:%d)", +#ifdef RTGUI_USING_SMALL_SIZE + create->wid->title, + RTGUI_WIDGET(create->wid)->extent.x1, + RTGUI_WIDGET(create->wid)->extent.y1, + RTGUI_WIDGET(create->wid)->extent.x2, + RTGUI_WIDGET(create->wid)->extent.y2); +#else create->title, create->extent.x1, create->extent.y1, create->extent.x2, create->extent.y2); +#endif } break; @@ -340,6 +348,7 @@ struct rtgui_widget* rtgui_thread_get_widget() rt_err_t rtgui_thread_send(rt_thread_t tid, rtgui_event_t* event, rt_size_t event_size) { + rt_err_t result; struct rtgui_thread* thread; rtgui_event_dump(tid, event); @@ -350,11 +359,16 @@ rt_err_t rtgui_thread_send(rt_thread_t tid, rtgui_event_t* event, rt_size_t even thread = (struct rtgui_thread*) (tid->user_data); if (thread == RT_NULL) return -RT_ERROR; - return rt_mq_send(thread->mq, event, event_size); + result = rt_mq_send(thread->mq, event, event_size); + if (result != RT_EOK) + rt_kprintf("send event failed\n"); + + return result; } rt_err_t rtgui_thread_send_urgent(rt_thread_t tid, rtgui_event_t* event, rt_size_t event_size) { + rt_err_t result; struct rtgui_thread* thread; rtgui_event_dump(tid, event); @@ -364,7 +378,11 @@ rt_err_t rtgui_thread_send_urgent(rt_thread_t tid, rtgui_event_t* event, rt_size thread = (struct rtgui_thread*) (tid->user_data); if (thread == RT_NULL) return -RT_ERROR; - return rt_mq_urgent(thread->mq, event, event_size); + result = rt_mq_urgent(thread->mq, event, event_size); + if (result != RT_EOK) + rt_kprintf("send ergent event failed\n"); + + return result; } rt_err_t rtgui_thread_send_sync(rt_thread_t tid, rtgui_event_t* event, rt_size_t event_size) @@ -387,7 +405,11 @@ rt_err_t rtgui_thread_send_sync(rt_thread_t tid, rtgui_event_t* event, rt_size_t event->ack = &ack_mb; r = rt_mq_send(thread->mq, event, event_size); - if (r != RT_EOK) goto __return; + if (r != RT_EOK) + { + rt_kprintf("send sync event failed\n"); + goto __return; + } r = rt_mb_recv(&ack_mb, (rt_uint32_t*)&ack_status, RT_WAITING_FOREVER); if ( r!= RT_EOK) goto __return; diff --git a/rtgui/include/rtgui/event.h b/rtgui/include/rtgui/event.h index 50ad4887e..1b0a6d102 100644 --- a/rtgui/include/rtgui/event.h +++ b/rtgui/include/rtgui/event.h @@ -77,7 +77,9 @@ enum { struct rtgui_event { /* the event type */ - rt_uint32_t type; + rt_uint16_t type; + /* user field of event */ + rt_uint16_t user; /* the event sender */ rt_thread_t sender; @@ -91,6 +93,7 @@ typedef struct rtgui_event rtgui_event_t; #define RTGUI_EVENT_INIT(e, t) do \ { \ (e)->type = (t); \ + (e)->user = 0; \ (e)->sender = rt_thread_self(); \ (e)->ack = RT_NULL; \ } while (0) @@ -172,16 +175,15 @@ struct rtgui_event_win_create { struct rtgui_event parent; - /* the window flag */ - rt_uint32_t flag; - +#ifndef RTGUI_USING_SMALL_SIZE /* the window title */ rt_uint8_t title[RTGUI_NAME_MAX]; + /* the window extent */ + struct rtgui_rect extent; +#endif /* the window id */ rtgui_win_t* wid; - /* the window extent */ - struct rtgui_rect extent; }; struct rtgui_event_win_move @@ -332,9 +334,9 @@ struct rtgui_event_kbd rtgui_win_t* wid; /* destination window */ - RTGUI_KBD_TYPE type; /* key down or up */ - RTGUI_KBD_KEY key; /* current key */ - RTGUI_KBD_MOD mod; /* current key modifiers */ + rt_uint16_t type; /* key down or up */ + rt_uint16_t key; /* current key */ + rt_uint16_t mod; /* current key modifiers */ rt_uint16_t unicode; /* translated character */ }; #define RTGUI_KBD_IS_SET_CTRL(e) ((e)->mod & (RTGUI_KMOD_LCTRL | RTGUI_KMOD_RCTRL))) @@ -357,9 +359,6 @@ struct rtgui_event_command /* command id */ rt_int32_t command_id; - /* command integer */ - rt_int32_t command_int; - /* command string */ char command_string[RTGUI_NAME_MAX]; }; diff --git a/rtgui/server/server.c b/rtgui/server/server.c index 43694198e..4c72781f6 100644 --- a/rtgui/server/server.c +++ b/rtgui/server/server.c @@ -483,7 +483,7 @@ static void rtgui_server_entry(void* parameter) #ifdef RTGUI_USING_SMALL_SIZE /* create rtgui server msgq */ rtgui_server_mq = rt_mq_create("rtgui", - 64, 8, RT_IPC_FLAG_FIFO); + 32, 8, RT_IPC_FLAG_FIFO); #else /* create rtgui server msgq */ rtgui_server_mq = rt_mq_create("rtgui", diff --git a/rtgui/server/topwin.c b/rtgui/server/topwin.c index c8f2b903d..059b06d4a 100644 --- a/rtgui/server/topwin.c +++ b/rtgui/server/topwin.c @@ -70,14 +70,18 @@ rt_err_t rtgui_topwin_add(struct rtgui_event_win_create* event) if (topwin == RT_NULL) return -RT_ERROR; topwin->wid = event->wid; +#ifdef RTGUI_USING_SMALL_SIZE + topwin->extent = RTGUI_WIDGET(event->wid)->extent; +#else topwin->extent = event->extent; +#endif topwin->tid = event->parent.sender; topwin->flag = 0; - if (event->flag & RTGUI_WIN_STYLE_NO_TITLE) topwin->flag |= WINTITLE_NO; - if (event->flag & RTGUI_WIN_STYLE_CLOSEBOX) topwin->flag |= WINTITLE_CLOSEBOX; - if (!(event->flag & RTGUI_WIN_STYLE_NO_BORDER)) topwin->flag |= WINTITLE_BORDER; - if (event->flag & RTGUI_WIN_STYLE_NO_FOCUS) topwin->flag |= WINTITLE_NOFOCUS; + if (event->parent.user & RTGUI_WIN_STYLE_NO_TITLE) topwin->flag |= WINTITLE_NO; + if (event->parent.user & RTGUI_WIN_STYLE_CLOSEBOX) topwin->flag |= WINTITLE_CLOSEBOX; + if (!(event->parent.user & RTGUI_WIN_STYLE_NO_BORDER)) topwin->flag |= WINTITLE_BORDER; + if (event->parent.user & RTGUI_WIN_STYLE_NO_FOCUS) topwin->flag |= WINTITLE_NOFOCUS; if(!(topwin->flag & WINTITLE_NO) || (topwin->flag & WINTITLE_BORDER)) { @@ -93,7 +97,11 @@ rt_err_t rtgui_topwin_add(struct rtgui_event_win_create* event) /* add title rect */ if (!(topwin->flag & WINTITLE_NO)) rect.y1 -= WINTITLE_HEIGHT; +#ifdef RTGUI_USING_SMALL_SIZE + topwin->title = rtgui_wintitle_create(event->wid->title); +#else topwin->title = rtgui_wintitle_create(event->title); +#endif rtgui_widget_set_rect(RTGUI_WIDGET(topwin->title), &rect); /* update clip info */ @@ -289,9 +297,7 @@ void rtgui_topwin_raise(struct rtgui_win* wid, rt_thread_t sender) /* send clip info event */ count = 0; - for (node = _rtgui_topwin_show_list.next; - node != &(topwin->list); - node = node->next) + for (node = _rtgui_topwin_show_list.next; node != RT_NULL; node = node->next) { struct rtgui_topwin* wnd = rtgui_list_entry(node, struct rtgui_topwin, list); @@ -1020,12 +1026,13 @@ void rtgui_topwin_get_clipinfo(struct rtgui_rect* rect_list, rt_int32_t count) topwin = rtgui_list_entry(node, struct rtgui_topwin, list); if (topwin->title != RT_NULL) - rtgui_widget_get_rect(RTGUI_WIDGET(topwin->title), rect); - else *rect = topwin->extent; + *rect = RTGUI_WIDGET(topwin->title)->extent; + else + *rect = topwin->extent; rect ++; count --; - if (count < 0) break; + if (count <= 0) break; } rt_sem_release(&_rtgui_topwin_lock); } diff --git a/rtgui/widgets/toplevel.c b/rtgui/widgets/toplevel.c index cd4144b4c..35284383c 100644 --- a/rtgui/widgets/toplevel.c +++ b/rtgui/widgets/toplevel.c @@ -37,12 +37,13 @@ static void _rtgui_toplevel_constructor(rtgui_toplevel_t *toplevel) static void _rtgui_toplevel_destructor(rtgui_toplevel_t* toplevel) { /* release external clip info */ - rtgui_free(toplevel->external_clip_rect); - toplevel->drawing = 0; - rtgui_free(toplevel->external_clip_rect); - toplevel->external_clip_rect = RT_NULL; - toplevel->external_clip_size = 0; + if (toplevel->external_clip_size > 0) + { + rtgui_free(toplevel->external_clip_rect); + toplevel->external_clip_rect = RT_NULL; + toplevel->external_clip_size = 0; + } } rtgui_type_t *rtgui_toplevel_type_get(void) @@ -115,6 +116,10 @@ rt_bool_t rtgui_toplevel_event_handler(rtgui_widget_t* widget, rtgui_event_t* ev return RT_FALSE; } +#include +#include +#include + void rtgui_toplevel_handle_clip(struct rtgui_toplevel* top, struct rtgui_event_clip_info* info) { diff --git a/rtgui/widgets/window.c b/rtgui/widgets/window.c index 33b51126d..1f6dfdcc3 100644 --- a/rtgui/widgets/window.c +++ b/rtgui/widgets/window.c @@ -77,10 +77,12 @@ static rt_bool_t _rtgui_win_create_in_server(rtgui_win_t* win) } /* send win create event to server */ - ecreate.wid = win; - ecreate.extent = RTGUI_WIDGET(win)->extent; - ecreate.flag = win->style; + ecreate.wid = win; + ecreate.parent.user = win->style; +#ifndef RTGUI_USING_SMALL_SIZE + ecreate.extent = RTGUI_WIDGET(win)->extent; rt_strncpy((char*)ecreate.title, (char*)win->title, RTGUI_NAME_MAX); +#endif if (rtgui_thread_send_sync(server, RTGUI_EVENT(&ecreate), sizeof(struct rtgui_event_win_create)) != RT_EOK)