From a1ee019309d171f9dc641c7ef09d545a49edc1a1 Mon Sep 17 00:00:00 2001 From: "bernard.xiong@gmail.com" Date: Sun, 30 May 2010 22:44:21 +0000 Subject: [PATCH] move the basic routine of dc to inline; add hdc memory image type; move event buffer from stack to gui thread structure. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@755 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- components/rtgui/common/dc.c | 138 +++--------------- components/rtgui/common/font_hz_file.c | 2 +- components/rtgui/common/image_hdc.c | 2 +- components/rtgui/common/region.c | 4 +- components/rtgui/common/rtgui_system.c | 31 ++-- components/rtgui/common/rtgui_theme.c | 4 +- components/rtgui/include/rtgui/dc.h | 108 ++++++++++++-- components/rtgui/include/rtgui/image.h | 2 +- components/rtgui/include/rtgui/image_hdc.h | 2 +- components/rtgui/include/rtgui/region.h | 18 +-- components/rtgui/include/rtgui/rtgui_system.h | 10 +- components/rtgui/widgets/window.c | 14 +- components/rtgui/widgets/workbench.c | 15 +- 13 files changed, 173 insertions(+), 177 deletions(-) diff --git a/components/rtgui/common/dc.c b/components/rtgui/common/dc.c index 652e6b7fd7..681d2b242b 100644 --- a/components/rtgui/common/dc.c +++ b/components/rtgui/common/dc.c @@ -31,46 +31,6 @@ void rtgui_dc_destory(struct rtgui_dc* dc) rtgui_free(dc); } -/* - * draw a point on dc - */ -void rtgui_dc_draw_point(struct rtgui_dc* dc, int x, int y) -{ - if (dc == RT_NULL) return; - - dc->draw_point(dc, x, y); -} - -/* - * draw a color point on dc - */ -void rtgui_dc_draw_color_point(struct rtgui_dc* dc, int x, int y, rtgui_color_t color) -{ - if (dc == RT_NULL) return; - - dc->draw_color_point(dc, x, y, color); -} - -/* - * draw a vertical line on dc - */ -void rtgui_dc_draw_vline(struct rtgui_dc* dc, int x, int y1, int y2) -{ - if (dc == RT_NULL) return; - - dc->draw_vline(dc, x, y1, y2); -} - -/* - * draw a horizontal line on dc - */ -void rtgui_dc_draw_hline(struct rtgui_dc* dc, int x1, int x2, int y) -{ - if (dc == RT_NULL) return; - - dc->draw_hline(dc, x1, x2, y); -} - void rtgui_dc_draw_line (struct rtgui_dc* dc, int x1, int y1, int x2, int y2) { if (dc == RT_NULL) return; @@ -163,20 +123,6 @@ void rtgui_dc_draw_round_rect(struct rtgui_dc* dc, struct rtgui_rect* rect) rtgui_dc_draw_vline(dc, rect->x2, rect->y1 + r, rect->y2 - r); } -void rtgui_dc_fill_rect (struct rtgui_dc* dc, struct rtgui_rect* rect) -{ - if (dc == RT_NULL) return; - - dc->fill_rect(dc, rect); -} - -void rtgui_dc_blit(struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect) -{ - if (dc == RT_NULL || dest == RT_NULL || rect == RT_NULL) return; - - dc->blit(dc, dc_point, dest, rect); -} - void rtgui_dc_draw_text (struct rtgui_dc* dc, const char* text, struct rtgui_rect* rect) { rt_uint32_t len; @@ -236,67 +182,33 @@ void rtgui_dc_draw_text (struct rtgui_dc* dc, const char* text, struct rtgui_rec #endif } +/* + * draw a monochrome color bitmap data + */ +void rtgui_dc_draw_mono_bmp(struct rtgui_dc* dc, int x, int y, int w, int h, const rt_uint8_t* data) +{ + int word_bytes; + int i, j, k; + + /* get word bytes */ + word_bytes = (w + 7)/8; + + /* draw mono bitmap data */ + for (i = 0; i < h; i ++) + for (j = 0; j < word_bytes; j++) + for (k = 0; k < 8; k++) + if ( ((data[i*2 + j] >> (7-k)) & 0x01) != 0) + rtgui_dc_draw_point(dc, x + 8*j + k, y + i); +} + void rtgui_dc_draw_byte(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data) { - int i, k; - - /* draw byte */ - for (i=0; i < h; i ++) - { - for (k=0; k < 8; k++) - { - if (((data[i] >> (7-k)) & 0x01) != 0) - { - rtgui_dc_draw_point(dc, x + k, y + i); - } - } - } + rtgui_dc_draw_mono_bmp(dc, x, y, 8, h, data); } void rtgui_dc_draw_word(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data) { - int i, j, k; - - /* draw word */ - for (i=0; i < h; i ++) - { - for (j=0; j < 2; j++) - for (k=0; k < 8; k++) - { - if (((data[i * 2 + j] >> (7-k)) & 0x01) != 0) - { - rtgui_dc_draw_point(dc, x + 8*j + k, y + i); - } - } - } -} - -void rtgui_dc_set_gc(struct rtgui_dc* dc, rtgui_gc_t* gc) -{ - if (dc != RT_NULL) - { - dc->set_gc(dc, gc); - } -} - -rtgui_gc_t *rtgui_dc_get_gc(struct rtgui_dc* dc) -{ - if (dc != RT_NULL) - { - return dc->get_gc(dc); - } - - return RT_NULL; -} - -rt_bool_t rtgui_dc_get_visible(struct rtgui_dc* dc) -{ - if (dc != RT_NULL) - { - return dc->get_visible(dc); - } - - return RT_FALSE; + rtgui_dc_draw_mono_bmp(dc, x, y, 16, h, data); } void rtgui_dc_draw_shaded_rect(struct rtgui_dc* dc, rtgui_rect_t* rect, @@ -1295,11 +1207,3 @@ void rtgui_dc_draw_focus_rect(struct rtgui_dc* dc, rtgui_rect_t* rect) rtgui_dc_draw_point(dc, rect->x2, i); } } - -void rtgui_dc_get_rect(struct rtgui_dc*dc, rtgui_rect_t* rect) -{ - if (dc != RT_NULL && rect != RT_NULL) - { - dc->get_rect(dc, rect); - } -} diff --git a/components/rtgui/common/font_hz_file.c b/components/rtgui/common/font_hz_file.c index 9a4b6380cb..03b41f02a1 100644 --- a/components/rtgui/common/font_hz_file.c +++ b/components/rtgui/common/font_hz_file.c @@ -116,7 +116,7 @@ static void rtgui_hz_file_font_draw_text(struct rtgui_font* font, struct rtgui_d /* draw word */ for (i=0; i < h; i ++) { - for (j=0; j < 2; j++) + for (j=0; j < word_bytes; j++) for (k=0; k < 8; k++) { if ( ((font_ptr[i*2 + j] >> (7-k)) & 0x01) != 0 && diff --git a/components/rtgui/common/image_hdc.c b/components/rtgui/common/image_hdc.c index 56bf614aa5..a9d8bcc744 100644 --- a/components/rtgui/common/image_hdc.c +++ b/components/rtgui/common/image_hdc.c @@ -37,7 +37,7 @@ struct rtgui_image_engine rtgui_image_hdc_engine = rtgui_image_hdc_blit }; -struct rtgui_image_engine rtgui_image_hdcmm_engine = +const struct rtgui_image_engine rtgui_image_hdcmm_engine = { "hdcmm", {RT_NULL}, diff --git a/components/rtgui/common/region.c b/components/rtgui/common/region.c index cb6191a570..42ac6cd121 100644 --- a/components/rtgui/common/region.c +++ b/components/rtgui/common/region.c @@ -2202,14 +2202,14 @@ void rtgui_rect_intersect(rtgui_rect_t *src, rtgui_rect_t *dest) if (dest->y2 > src->y2) dest->y2 = src->y2; } -int rtgui_rect_contains_point(rtgui_rect_t *rect, int x, int y) +int rtgui_rect_contains_point(const rtgui_rect_t *rect, int x, int y) { if (INBOX(rect, x, y)) return RT_EOK; return -RT_ERROR; } -int rtgui_rect_is_intersect(rtgui_rect_t *rect1, rtgui_rect_t *rect2) +int rtgui_rect_is_intersect(const rtgui_rect_t *rect1, const rtgui_rect_t *rect2) { if (INBOX(rect1, rect2->x1, rect2->y1) || INBOX(rect1, rect2->x1, rect2->y2) || diff --git a/components/rtgui/common/rtgui_system.c b/components/rtgui/common/rtgui_system.c index dc5df0c1f2..df438ab5ee 100644 --- a/components/rtgui/common/rtgui_system.c +++ b/components/rtgui/common/rtgui_system.c @@ -29,9 +29,6 @@ void rtgui_system_server_init() { - /* init rtgui_thread */ - rtgui_thread_system_init(); - /* init image */ rtgui_system_image_init(); /* init font */ @@ -276,13 +273,6 @@ static void rtgui_event_dump(rt_thread_t tid, rtgui_event_t* event) #define rtgui_event_dump(tid, event) #endif -struct rt_semaphore _rtgui_thread_hash_semaphore; - -void rtgui_thread_system_init() -{ - rt_sem_init(&_rtgui_thread_hash_semaphore, "rtgui", 1, RT_IPC_FLAG_FIFO); -} - rtgui_thread_t* rtgui_thread_register(rt_thread_t tid, rt_mq_t mq) { rtgui_thread_t* thread = rtgui_malloc(sizeof(struct rtgui_thread)); @@ -296,12 +286,8 @@ rtgui_thread_t* rtgui_thread_register(rt_thread_t tid, rt_mq_t mq) thread->mq = mq; thread->widget = RT_NULL; - /* take semaphore */ - rt_sem_take(&_rtgui_thread_hash_semaphore, RT_WAITING_FOREVER); /* set user thread */ tid->user_data = (rt_uint32_t)thread; - /* release semaphore */ - rt_sem_release(&_rtgui_thread_hash_semaphore); } return thread; @@ -316,18 +302,27 @@ void rtgui_thread_deregister(rt_thread_t tid) if (thread != RT_NULL) { - /* take semaphore */ - rt_sem_take(&_rtgui_thread_hash_semaphore, RT_WAITING_FOREVER); /* remove rtgui_thread */ tid->user_data = 0; - /* release semaphore */ - rt_sem_release(&_rtgui_thread_hash_semaphore); /* free rtgui_thread */ rtgui_free(thread); } } +/* get current gui thread */ +rtgui_thread_t* rtgui_thread_self() +{ + struct rtgui_thread* thread; + rt_thread_t self; + + /* get current thread */ + self = rt_thread_self(); + thread = (struct rtgui_thread*)(self->user_data); + + return thread; +} + extern rt_thread_t rt_thread_find(char* name); rt_thread_t rtgui_thread_get_server() { diff --git a/components/rtgui/common/rtgui_theme.c b/components/rtgui/common/rtgui_theme.c index 1c5a6f1a9d..2cb4628d9c 100644 --- a/components/rtgui/common/rtgui_theme.c +++ b/components/rtgui/common/rtgui_theme.c @@ -488,7 +488,7 @@ void rtgui_theme_draw_radiobutton(struct rtgui_radiobox* radiobox, rt_uint16_t i { struct rtgui_dc* dc; struct rtgui_rect rect, item_rect; - rt_size_t item_size, bord_size; + int item_size, bord_size; /* begin drawing */ dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(radiobox)); @@ -572,7 +572,7 @@ void rtgui_theme_draw_radiobox(struct rtgui_radiobox* radiobox) { struct rtgui_dc* dc; struct rtgui_rect rect, item_rect; - rt_size_t item_size, bord_size, index; + int item_size, bord_size, index; rtgui_color_t fc; /* begin drawing */ diff --git a/components/rtgui/include/rtgui/dc.h b/components/rtgui/include/rtgui/dc.h index a4abda7cc3..54b4820eea 100644 --- a/components/rtgui/include/rtgui/dc.h +++ b/components/rtgui/include/rtgui/dc.h @@ -69,25 +69,13 @@ void rtgui_dc_end_drawing(struct rtgui_dc* dc); /* destroy a dc */ void rtgui_dc_destory(struct rtgui_dc* dc); -void rtgui_dc_draw_point(struct rtgui_dc* dc, int x, int y); -void rtgui_dc_draw_color_point(struct rtgui_dc* dc, int x, int y, rtgui_color_t color); - -void rtgui_dc_draw_vline(struct rtgui_dc* dc, int x, int y1, int y2); -void rtgui_dc_draw_hline(struct rtgui_dc* dc, int x1, int x2, int y); -void rtgui_dc_fill_rect (struct rtgui_dc* dc, struct rtgui_rect* rect); -void rtgui_dc_blit(struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect); - -void rtgui_dc_set_gc(struct rtgui_dc* dc, rtgui_gc_t* gc); -rtgui_gc_t *rtgui_dc_get_gc(struct rtgui_dc* dc); - -rt_bool_t rtgui_dc_get_visible(struct rtgui_dc* dc); -void rtgui_dc_get_rect(struct rtgui_dc*dc, rtgui_rect_t* rect); - void rtgui_dc_draw_line (struct rtgui_dc* dc, int x1, int y1, int x2, int y2); void rtgui_dc_draw_rect (struct rtgui_dc* dc, struct rtgui_rect* rect); void rtgui_dc_draw_round_rect(struct rtgui_dc* dc, struct rtgui_rect* rect); void rtgui_dc_draw_text (struct rtgui_dc* dc, const char* text, struct rtgui_rect* rect); + +void rtgui_dc_draw_mono_bmp(struct rtgui_dc* dc, int x, int y, int w, int h, const rt_uint8_t* data); void rtgui_dc_draw_byte(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data); void rtgui_dc_draw_word(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data); @@ -107,4 +95,96 @@ void rtgui_dc_draw_arc(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16 void rtgui_dc_draw_ellipse(struct rtgui_dc* dc, rt_int16_t x, rt_int16_t y, rt_int16_t rx, rt_int16_t ry); void rtgui_dc_fill_ellipse(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t rx, rt_int16_t ry); +/* + * dc inline function + * + * Note: + * In order to improve drawing speed, put most of common function of dc to inline + */ + +/* + * draw a point on dc + */ +rt_inline void rtgui_dc_draw_point(struct rtgui_dc* dc, int x, int y) +{ + dc->draw_point(dc, x, y); +} + +/* + * draw a color point on dc + */ +rt_inline void rtgui_dc_draw_color_point(struct rtgui_dc* dc, int x, int y, rtgui_color_t color) +{ + dc->draw_color_point(dc, x, y, color); +} + +/* + * draw a vertical line on dc + */ +rt_inline void rtgui_dc_draw_vline(struct rtgui_dc* dc, int x, int y1, int y2) +{ + dc->draw_vline(dc, x, y1, y2); +} + +/* + * draw a horizontal line on dc + */ +rt_inline void rtgui_dc_draw_hline(struct rtgui_dc* dc, int x1, int x2, int y) +{ + dc->draw_hline(dc, x1, x2, y); +} + +/* + * fill a rect with background color + */ +rt_inline void rtgui_dc_fill_rect (struct rtgui_dc* dc, struct rtgui_rect* rect) +{ + dc->fill_rect(dc, rect); +} + +/* + * blit a dc on hardware dc + */ +rt_inline void rtgui_dc_blit(struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect) +{ + if (dest == RT_NULL || rect == RT_NULL) return; + + dc->blit(dc, dc_point, dest, rect); +} + +/* + * set gc of dc + */ +rt_inline void rtgui_dc_set_gc(struct rtgui_dc* dc, rtgui_gc_t* gc) +{ + dc->set_gc(dc, gc); +} + +/* + * get gc of dc + */ +rt_inline rtgui_gc_t *rtgui_dc_get_gc(struct rtgui_dc* dc) +{ + return dc->get_gc(dc); +} + +/* + * get visible status of dc + */ +rt_inline rt_bool_t rtgui_dc_get_visible(struct rtgui_dc* dc) +{ + return dc->get_visible(dc); +} + +/* + * get rect of dc + */ +rt_inline void rtgui_dc_get_rect(struct rtgui_dc*dc, rtgui_rect_t* rect) +{ + if (rect != RT_NULL) + { + dc->get_rect(dc, rect); + } +} + #endif diff --git a/components/rtgui/include/rtgui/image.h b/components/rtgui/include/rtgui/image.h index d6245d4881..5c63747f13 100644 --- a/components/rtgui/include/rtgui/image.h +++ b/components/rtgui/include/rtgui/image.h @@ -39,7 +39,7 @@ struct rtgui_image rt_uint16_t w, h; /* image engine */ - struct rtgui_image_engine* engine; + const struct rtgui_image_engine* engine; /* image private data */ void* data; diff --git a/components/rtgui/include/rtgui/image_hdc.h b/components/rtgui/include/rtgui/image_hdc.h index eab22da980..8d253631f1 100644 --- a/components/rtgui/include/rtgui/image_hdc.h +++ b/components/rtgui/include/rtgui/image_hdc.h @@ -28,7 +28,7 @@ struct rtgui_image_hdcmm }; void rtgui_image_hdc_init(void); -extern struct rtgui_image_engine rtgui_image_hdcmm_engine; +extern const struct rtgui_image_engine rtgui_image_hdcmm_engine; #define HDC_HEADER_SIZE (5 * 4) #define RTGUI_IMAGE_HDC_DEF(bpp, w, h, pixels) \ diff --git a/components/rtgui/include/rtgui/region.h b/components/rtgui/include/rtgui/region.h index 72c06653e3..c822212bff 100644 --- a/components/rtgui/include/rtgui/region.h +++ b/components/rtgui/include/rtgui/region.h @@ -14,7 +14,7 @@ #ifndef __RTGUI_REGION_H__ #define __RTGUI_REGION_H__ -#include +#include #if defined(__cplusplus) || defined(c_plusplus) extern "C" { @@ -83,15 +83,15 @@ void rtgui_region_reset(rtgui_region_t *region, rtgui_rect_t* rect); void rtgui_region_empty (rtgui_region_t *region); void rtgui_region_dump(rtgui_region_t* region); -/* rect functions */ -extern rtgui_rect_t rtgui_empty_rect; - +/* rect functions */ +extern rtgui_rect_t rtgui_empty_rect; + void rtgui_rect_moveto(rtgui_rect_t *rect, int x, int y); -void rtgui_rect_moveto_align(rtgui_rect_t *rect, rtgui_rect_t *to, int align); -void rtgui_rect_inflate(rtgui_rect_t *rect, int d); -void rtgui_rect_intersect(rtgui_rect_t *src, rtgui_rect_t *dest); -int rtgui_rect_contains_point(rtgui_rect_t *rect, int x, int y); -int rtgui_rect_is_intersect(rtgui_rect_t *rect1, rtgui_rect_t *rect2); +void rtgui_rect_moveto_align(rtgui_rect_t *rect, rtgui_rect_t *to, int align); +void rtgui_rect_inflate(rtgui_rect_t *rect, int d); +void rtgui_rect_intersect(rtgui_rect_t *src, rtgui_rect_t *dest); +int rtgui_rect_contains_point(const rtgui_rect_t *rect, int x, int y); +int rtgui_rect_is_intersect(const rtgui_rect_t *rect1, const rtgui_rect_t *rect2); #if defined(__cplusplus) || defined(c_plusplus) } diff --git a/components/rtgui/include/rtgui/rtgui_system.h b/components/rtgui/include/rtgui/rtgui_system.h index 8c5bef7cc7..4afc65e4e0 100644 --- a/components/rtgui/include/rtgui/rtgui_system.h +++ b/components/rtgui/include/rtgui/rtgui_system.h @@ -21,6 +21,12 @@ struct rtgui_dc; struct rtgui_event; struct rtgui_widget; +#ifdef RTGUI_USING_SMALL_SIZE +#define RTGUI_EVENT_BUFFER_SIZE 64 +#else +#define RTGUI_EVENT_BUFFER_SIZE 256 +#endif + struct rtgui_thread { /* the thread id */ @@ -31,6 +37,8 @@ struct rtgui_thread /* the owner of thread */ struct rtgui_widget* widget; + /* event buffer */ + rt_uint8_t event_buffer[RTGUI_EVENT_BUFFER_SIZE]; }; typedef struct rtgui_thread rtgui_thread_t; struct rtgui_timer; @@ -55,9 +63,9 @@ void rtgui_timer_destory(rtgui_timer_t* timer); void rtgui_timer_start(rtgui_timer_t* timer); void rtgui_timer_stop (rtgui_timer_t* timer); -void rtgui_thread_system_init(void); rtgui_thread_t* rtgui_thread_register(rt_thread_t tid, rt_mq_t mq); void rtgui_thread_deregister(rt_thread_t tid); +rtgui_thread_t* rtgui_thread_self(void); rt_thread_t rtgui_thread_get_server(void); diff --git a/components/rtgui/widgets/window.c b/components/rtgui/widgets/window.c index 7401611cc7..0997d769ba 100644 --- a/components/rtgui/widgets/window.c +++ b/components/rtgui/widgets/window.c @@ -522,16 +522,20 @@ rt_bool_t rtgui_win_event_handler(struct rtgui_widget* widget, struct rtgui_even /* windows event loop */ void rtgui_win_event_loop(rtgui_win_t* wnd) { - /* the buffer uses to receive event */ - char event_buf[256]; + rtgui_thread_t* tid; + struct rtgui_event* event; - struct rtgui_event* event = (struct rtgui_event*)&event_buf[0]; + tid = rtgui_thread_self(); + RT_ASSERT(tid != RT_NULL); + + /* point to event buffer */ + event = (struct rtgui_event*)tid->event_buffer; if (wnd->style & RTGUI_WIN_STYLE_UNDER_MODAL) { while (wnd->style & RTGUI_WIN_STYLE_UNDER_MODAL) { - if (rtgui_thread_recv(event, sizeof(event_buf)) == RT_EOK) + if (rtgui_thread_recv(event, RTGUI_EVENT_BUFFER_SIZE) == RT_EOK) { /* perform event handler */ RTGUI_WIDGET(wnd)->event_handler(RTGUI_WIDGET(wnd), event); @@ -542,7 +546,7 @@ void rtgui_win_event_loop(rtgui_win_t* wnd) { while (!(wnd->style & RTGUI_WIN_STYLE_CLOSED)) { - if (rtgui_thread_recv(event, sizeof(event_buf)) == RT_EOK) + if (rtgui_thread_recv(event, RTGUI_EVENT_BUFFER_SIZE) == RT_EOK) { /* perform event handler */ RTGUI_WIDGET(wnd)->event_handler(RTGUI_WIDGET(wnd), event); diff --git a/components/rtgui/widgets/workbench.c b/components/rtgui/widgets/workbench.c index 2408f1254e..28224d1eb9 100644 --- a/components/rtgui/widgets/workbench.c +++ b/components/rtgui/widgets/workbench.c @@ -162,16 +162,21 @@ void rtgui_workbench_set_flag(rtgui_workbench_t* workbench, rt_uint8_t flag) rt_bool_t rtgui_workbench_event_loop(rtgui_workbench_t* workbench) { - /* the buffer uses to receive event */ - char event_buf[256]; - struct rtgui_event* event = (struct rtgui_event*)&event_buf[0]; + rtgui_thread_t* tid; + struct rtgui_event* event; + + tid = rtgui_thread_self(); + RT_ASSERT(tid != RT_NULL); + + /* point to event buffer */ + event = (struct rtgui_event*)tid->event_buffer; if (workbench->flag & RTGUI_WORKBENCH_FLAG_MODAL_MODE) { /* event loop for modal mode shown view */ while (workbench->flag & RTGUI_WORKBENCH_FLAG_MODAL_MODE) { - if (rtgui_thread_recv(event, sizeof(event_buf)) == RT_EOK) + if (rtgui_thread_recv(event, RTGUI_EVENT_BUFFER_SIZE) == RT_EOK) { RTGUI_WIDGET(workbench)->event_handler(RTGUI_WIDGET(workbench), event); } @@ -184,7 +189,7 @@ rt_bool_t rtgui_workbench_event_loop(rtgui_workbench_t* workbench) while (!(workbench->flag & RTGUI_WORKBENCH_FLAG_CLOSED)) { - if (rtgui_thread_recv(event, sizeof(event_buf)) == RT_EOK) + if (rtgui_thread_recv(event, RTGUI_EVENT_BUFFER_SIZE) == RT_EOK) { RTGUI_WIDGET(workbench)->event_handler(RTGUI_WIDGET(workbench), event); }