From ceefcb9732e9df0d71dfa12d913addb2f90c0aa3 Mon Sep 17 00:00:00 2001 From: yangfasheng Date: Fri, 19 Jan 2018 10:20:02 +0800 Subject: [PATCH] =?UTF-8?q?gui=20=E5=BC=95=E6=93=8E=E4=BC=98=E5=8C=96?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/gui/include/rtgui/event.h | 6 +++--- components/gui/include/rtgui/rtgui.h | 2 +- components/gui/src/font_freetype.c | 6 +++++- components/gui/src/rtgui_app.c | 2 +- components/gui/src/rtgui_system.c | 13 +++++++++---- components/gui/src/server.c | 11 ++++++++--- 6 files changed, 27 insertions(+), 13 deletions(-) diff --git a/components/gui/include/rtgui/event.h b/components/gui/include/rtgui/event.h index 78f269a23..d1a8070af 100644 --- a/components/gui/include/rtgui/event.h +++ b/components/gui/include/rtgui/event.h @@ -343,7 +343,7 @@ struct rtgui_event_gesture enum rtgui_gesture_type type; - rt_uint32_t win_acti_cnt; /* win id */ + rt_uint32_t win_acti_cnt; /* window activate count */ }; /* @@ -362,7 +362,7 @@ struct rtgui_event_mouse * different id. id should never be 0. */ rt_uint32_t id; - rt_uint32_t win_acti_cnt; /* win id */ + rt_uint32_t win_acti_cnt; /* window activate count */ }; #define RTGUI_MOUSE_BUTTON_LEFT 0x01 #define RTGUI_MOUSE_BUTTON_RIGHT 0x02 @@ -383,7 +383,7 @@ struct rtgui_event_kbd { _RTGUI_EVENT_WIN_ELEMENTS - rt_uint32_t win_acti_cnt; /* win id */ + rt_uint32_t win_acti_cnt; /* window activate count */ rt_uint16_t type; /* key down or up */ rt_uint16_t key; /* current key */ diff --git a/components/gui/include/rtgui/rtgui.h b/components/gui/include/rtgui/rtgui.h index 8f8fecb08..b918c78be 100644 --- a/components/gui/include/rtgui/rtgui.h +++ b/components/gui/include/rtgui/rtgui.h @@ -173,7 +173,7 @@ enum RTGUI_MODAL_CODE { RTGUI_MODAL_OK, RTGUI_MODAL_CANCEL, - RTGUI_MODAL_MAX = 0xFFFFFFFF, + RTGUI_MODAL_MAX = 0xFFFF, }; typedef enum RTGUI_MODAL_CODE rtgui_modal_code_t; diff --git a/components/gui/src/font_freetype.c b/components/gui/src/font_freetype.c index 0ec954945..e9a5ce008 100644 --- a/components/gui/src/font_freetype.c +++ b/components/gui/src/font_freetype.c @@ -62,6 +62,8 @@ extern unsigned short ff_convert(unsigned short wch, int direction); #define gb2312tounicode(code) ff_convert(code, 1) #endif +#ifndef UTF8_TO_UNICODE + static void gbk_to_unicode(rt_uint16_t *unicode, const char *text, int len) { int i; @@ -91,6 +93,8 @@ static void gbk_to_unicode(rt_uint16_t *unicode, const char *text, int len) *unicode = '\0'; } +#else + static rt_uint16_t _get_unicode(const char* str, int n) { int i; @@ -244,6 +248,7 @@ static int utf8_to_unicode(rt_uint16_t* unicode, const char* utf8, int len) return index; } +#endif static void _rtgui_rect_move_to_align(const rtgui_rect_t *rect, rtgui_rect_t *to, rt_uint16_t height, int align) { @@ -574,7 +579,6 @@ static void ftc_draw_text(struct rtgui_font *font, struct rtgui_ttf_font *ttf_font; rt_int16_t begin_x, btm_y; rt_int16_t topy; - rt_uint8_t a, r, g, b; rtgui_color_t fgc; struct rtgui_rect text_rect; diff --git a/components/gui/src/rtgui_app.c b/components/gui/src/rtgui_app.c index c7210c12c..758c898b6 100644 --- a/components/gui/src/rtgui_app.c +++ b/components/gui/src/rtgui_app.c @@ -286,7 +286,7 @@ rt_bool_t rtgui_app_event_handler(struct rtgui_object *object, rtgui_event_t *ev case RTGUI_EVENT_WIN_ACTIVATE: { - app->win_acti_cnt++; + app->win_acti_cnt ++; _rtgui_application_dest_handle(app, event); } break; diff --git a/components/gui/src/rtgui_system.c b/components/gui/src/rtgui_system.c index 8cdfe763c..1803c9cf6 100644 --- a/components/gui/src/rtgui_system.c +++ b/components/gui/src/rtgui_system.c @@ -87,6 +87,7 @@ INIT_APP_EXPORT(rtgui_system_server_init); /************************************************************************/ static void rtgui_time_out(void *parameter) { + rt_err_t result; rtgui_timer_t *timer; rtgui_event_timer_t event; timer = (rtgui_timer_t *)parameter; @@ -103,7 +104,11 @@ static void rtgui_time_out(void *parameter) event.timer = timer; timer->pending_cnt++; - rtgui_send(timer->app, &(event.parent), sizeof(rtgui_event_timer_t)); + result = rtgui_send(timer->app, &(event.parent), sizeof(rtgui_event_timer_t)); + if (result == RT_EOK) + { + timer->pending_cnt++; + } } rtgui_timer_t *rtgui_timer_create(rt_int32_t time, rt_int32_t flag, rtgui_timeout_func timeout, void *parameter) @@ -417,7 +422,7 @@ const char *rtgui_event_string[] = "WIN_CLOSE", /* close a window */ "WIN_MOVE", /* move a window */ "WIN_RESIZE", /* resize a window */ - "WIN_UPDATE_END", + "WIN_UPDATE_END", "WIN_MODAL_ENTER", /* a window modals */ "SET_WM", /* set window manager */ @@ -547,8 +552,8 @@ static void rtgui_event_dump(struct rtgui_app* app, rtgui_event_t *event) break; case RTGUI_EVENT_WIN_ACTIVATE: - case RTGUI_EVENT_WIN_DESTROY: - case RTGUI_EVENT_WIN_CLOSE: + case RTGUI_EVENT_WIN_DESTROY: + case RTGUI_EVENT_WIN_CLOSE: case RTGUI_EVENT_WIN_DEACTIVATE: case RTGUI_EVENT_WIN_SHOW: case RTGUI_EVENT_WIN_HIDE: diff --git a/components/gui/src/server.c b/components/gui/src/server.c index 75e7879aa..6072bba33 100644 --- a/components/gui/src/server.c +++ b/components/gui/src/server.c @@ -115,6 +115,7 @@ void rtgui_server_handle_mouse_btn(struct rtgui_event_mouse *event) return; event->wid = wnd->wid; + event->win_acti_cnt = rtgui_app_get_win_acti_cnt(); /* only raise window if the button is pressed down */ if (event->button & RTGUI_MOUSE_BUTTON_DOWN && @@ -124,9 +125,10 @@ void rtgui_server_handle_mouse_btn(struct rtgui_event_mouse *event) } /* send mouse event to thread */ - rtgui_send(wnd->app, - (struct rtgui_event *)event, - sizeof(struct rtgui_event_mouse)); + while (rtgui_send(wnd->app, (struct rtgui_event *)event, sizeof(struct rtgui_event_mouse)) != RT_EOK) + { + rt_thread_delay(RT_TICK_PER_SECOND / 50); + } } void rtgui_server_handle_mouse_motion(struct rtgui_event_mouse *event) @@ -152,6 +154,8 @@ void rtgui_server_handle_mouse_motion(struct rtgui_event_mouse *event) if (win) { event->wid = win->wid; + event->win_acti_cnt = rtgui_app_get_win_acti_cnt(); + rtgui_send(win->wid->app, &(event->parent), sizeof(*event)); } @@ -175,6 +179,7 @@ void rtgui_server_handle_kbd(struct rtgui_event_kbd *event) /* send to focus window */ event->wid = wnd->wid; + event->win_acti_cnt = rtgui_app_get_win_acti_cnt(); /* send keyboard event to thread */ rtgui_send(wnd->app, (struct rtgui_event *)event, sizeof(struct rtgui_event_kbd));