提交 ceefcb97 编写于 作者: Y yangfasheng

gui 引擎优化;

上级 973a5fb8
...@@ -343,7 +343,7 @@ struct rtgui_event_gesture ...@@ -343,7 +343,7 @@ struct rtgui_event_gesture
enum rtgui_gesture_type type; 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 ...@@ -362,7 +362,7 @@ struct rtgui_event_mouse
* different id. id should never be 0. */ * different id. id should never be 0. */
rt_uint32_t id; 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_LEFT 0x01
#define RTGUI_MOUSE_BUTTON_RIGHT 0x02 #define RTGUI_MOUSE_BUTTON_RIGHT 0x02
...@@ -383,7 +383,7 @@ struct rtgui_event_kbd ...@@ -383,7 +383,7 @@ struct rtgui_event_kbd
{ {
_RTGUI_EVENT_WIN_ELEMENTS _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 type; /* key down or up */
rt_uint16_t key; /* current key */ rt_uint16_t key; /* current key */
......
...@@ -173,7 +173,7 @@ enum RTGUI_MODAL_CODE ...@@ -173,7 +173,7 @@ enum RTGUI_MODAL_CODE
{ {
RTGUI_MODAL_OK, RTGUI_MODAL_OK,
RTGUI_MODAL_CANCEL, RTGUI_MODAL_CANCEL,
RTGUI_MODAL_MAX = 0xFFFFFFFF, RTGUI_MODAL_MAX = 0xFFFF,
}; };
typedef enum RTGUI_MODAL_CODE rtgui_modal_code_t; typedef enum RTGUI_MODAL_CODE rtgui_modal_code_t;
......
...@@ -62,6 +62,8 @@ extern unsigned short ff_convert(unsigned short wch, int direction); ...@@ -62,6 +62,8 @@ extern unsigned short ff_convert(unsigned short wch, int direction);
#define gb2312tounicode(code) ff_convert(code, 1) #define gb2312tounicode(code) ff_convert(code, 1)
#endif #endif
#ifndef UTF8_TO_UNICODE
static void gbk_to_unicode(rt_uint16_t *unicode, const char *text, int len) static void gbk_to_unicode(rt_uint16_t *unicode, const char *text, int len)
{ {
int i; int i;
...@@ -91,6 +93,8 @@ static void gbk_to_unicode(rt_uint16_t *unicode, const char *text, int len) ...@@ -91,6 +93,8 @@ static void gbk_to_unicode(rt_uint16_t *unicode, const char *text, int len)
*unicode = '\0'; *unicode = '\0';
} }
#else
static rt_uint16_t _get_unicode(const char* str, int n) static rt_uint16_t _get_unicode(const char* str, int n)
{ {
int i; int i;
...@@ -244,6 +248,7 @@ static int utf8_to_unicode(rt_uint16_t* unicode, const char* utf8, int len) ...@@ -244,6 +248,7 @@ static int utf8_to_unicode(rt_uint16_t* unicode, const char* utf8, int len)
return index; 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) 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, ...@@ -574,7 +579,6 @@ static void ftc_draw_text(struct rtgui_font *font,
struct rtgui_ttf_font *ttf_font; struct rtgui_ttf_font *ttf_font;
rt_int16_t begin_x, btm_y; rt_int16_t begin_x, btm_y;
rt_int16_t topy; rt_int16_t topy;
rt_uint8_t a, r, g, b;
rtgui_color_t fgc; rtgui_color_t fgc;
struct rtgui_rect text_rect; struct rtgui_rect text_rect;
......
...@@ -286,7 +286,7 @@ rt_bool_t rtgui_app_event_handler(struct rtgui_object *object, rtgui_event_t *ev ...@@ -286,7 +286,7 @@ rt_bool_t rtgui_app_event_handler(struct rtgui_object *object, rtgui_event_t *ev
case RTGUI_EVENT_WIN_ACTIVATE: case RTGUI_EVENT_WIN_ACTIVATE:
{ {
app->win_acti_cnt++; app->win_acti_cnt ++;
_rtgui_application_dest_handle(app, event); _rtgui_application_dest_handle(app, event);
} }
break; break;
......
...@@ -87,6 +87,7 @@ INIT_APP_EXPORT(rtgui_system_server_init); ...@@ -87,6 +87,7 @@ INIT_APP_EXPORT(rtgui_system_server_init);
/************************************************************************/ /************************************************************************/
static void rtgui_time_out(void *parameter) static void rtgui_time_out(void *parameter)
{ {
rt_err_t result;
rtgui_timer_t *timer; rtgui_timer_t *timer;
rtgui_event_timer_t event; rtgui_event_timer_t event;
timer = (rtgui_timer_t *)parameter; timer = (rtgui_timer_t *)parameter;
...@@ -103,7 +104,11 @@ static void rtgui_time_out(void *parameter) ...@@ -103,7 +104,11 @@ static void rtgui_time_out(void *parameter)
event.timer = timer; event.timer = timer;
timer->pending_cnt++; 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) 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[] = ...@@ -417,7 +422,7 @@ const char *rtgui_event_string[] =
"WIN_CLOSE", /* close a window */ "WIN_CLOSE", /* close a window */
"WIN_MOVE", /* move a window */ "WIN_MOVE", /* move a window */
"WIN_RESIZE", /* resize a window */ "WIN_RESIZE", /* resize a window */
"WIN_UPDATE_END", "WIN_UPDATE_END",
"WIN_MODAL_ENTER", /* a window modals */ "WIN_MODAL_ENTER", /* a window modals */
"SET_WM", /* set window manager */ "SET_WM", /* set window manager */
...@@ -547,8 +552,8 @@ static void rtgui_event_dump(struct rtgui_app* app, rtgui_event_t *event) ...@@ -547,8 +552,8 @@ static void rtgui_event_dump(struct rtgui_app* app, rtgui_event_t *event)
break; break;
case RTGUI_EVENT_WIN_ACTIVATE: case RTGUI_EVENT_WIN_ACTIVATE:
case RTGUI_EVENT_WIN_DESTROY: case RTGUI_EVENT_WIN_DESTROY:
case RTGUI_EVENT_WIN_CLOSE: case RTGUI_EVENT_WIN_CLOSE:
case RTGUI_EVENT_WIN_DEACTIVATE: case RTGUI_EVENT_WIN_DEACTIVATE:
case RTGUI_EVENT_WIN_SHOW: case RTGUI_EVENT_WIN_SHOW:
case RTGUI_EVENT_WIN_HIDE: case RTGUI_EVENT_WIN_HIDE:
......
...@@ -115,6 +115,7 @@ void rtgui_server_handle_mouse_btn(struct rtgui_event_mouse *event) ...@@ -115,6 +115,7 @@ void rtgui_server_handle_mouse_btn(struct rtgui_event_mouse *event)
return; return;
event->wid = wnd->wid; event->wid = wnd->wid;
event->win_acti_cnt = rtgui_app_get_win_acti_cnt();
/* only raise window if the button is pressed down */ /* only raise window if the button is pressed down */
if (event->button & RTGUI_MOUSE_BUTTON_DOWN && if (event->button & RTGUI_MOUSE_BUTTON_DOWN &&
...@@ -124,9 +125,10 @@ void rtgui_server_handle_mouse_btn(struct rtgui_event_mouse *event) ...@@ -124,9 +125,10 @@ void rtgui_server_handle_mouse_btn(struct rtgui_event_mouse *event)
} }
/* send mouse event to thread */ /* send mouse event to thread */
rtgui_send(wnd->app, while (rtgui_send(wnd->app, (struct rtgui_event *)event, sizeof(struct rtgui_event_mouse)) != RT_EOK)
(struct rtgui_event *)event, {
sizeof(struct rtgui_event_mouse)); rt_thread_delay(RT_TICK_PER_SECOND / 50);
}
} }
void rtgui_server_handle_mouse_motion(struct rtgui_event_mouse *event) 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) ...@@ -152,6 +154,8 @@ void rtgui_server_handle_mouse_motion(struct rtgui_event_mouse *event)
if (win) if (win)
{ {
event->wid = win->wid; event->wid = win->wid;
event->win_acti_cnt = rtgui_app_get_win_acti_cnt();
rtgui_send(win->wid->app, &(event->parent), sizeof(*event)); rtgui_send(win->wid->app, &(event->parent), sizeof(*event));
} }
...@@ -175,6 +179,7 @@ void rtgui_server_handle_kbd(struct rtgui_event_kbd *event) ...@@ -175,6 +179,7 @@ void rtgui_server_handle_kbd(struct rtgui_event_kbd *event)
/* send to focus window */ /* send to focus window */
event->wid = wnd->wid; event->wid = wnd->wid;
event->win_acti_cnt = rtgui_app_get_win_acti_cnt();
/* send keyboard event to thread */ /* send keyboard event to thread */
rtgui_send(wnd->app, (struct rtgui_event *)event, sizeof(struct rtgui_event_kbd)); rtgui_send(wnd->app, (struct rtgui_event *)event, sizeof(struct rtgui_event_kbd));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册