From f06c70feed0941b5bceedcecf89e9aa22034aca8 Mon Sep 17 00:00:00 2001 From: Grissiom Date: Fri, 1 Feb 2013 10:27:10 +0800 Subject: sync with rtgui-0.6 --- components/rtgui/widgets/window.c | 50 +++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 20 deletions(-) (limited to 'components/rtgui/widgets/window.c') diff --git a/components/rtgui/widgets/window.c b/components/rtgui/widgets/window.c index cb93ee9e92..78971a4649 100644 --- a/components/rtgui/widgets/window.c +++ b/components/rtgui/widgets/window.c @@ -178,7 +178,7 @@ static rt_bool_t _rtgui_win_deal_close(struct rtgui_win *win, return RT_FALSE; } - rtgui_win_hiden(win); + rtgui_win_hide(win); win->flag |= RTGUI_WIN_FLAG_CLOSED; @@ -280,7 +280,7 @@ rt_base_t rtgui_win_show(struct rtgui_win *win, rt_bool_t is_modal) /* set main window */ if (app->main_object == RT_NULL) - rtgui_app_set_main_win(win); + rtgui_app_set_main_win(app, win); if (is_modal == RT_TRUE) { @@ -328,7 +328,7 @@ void rtgui_win_end_modal(struct rtgui_win *win, rtgui_modal_code_t modal_code) } RTM_EXPORT(rtgui_win_end_modal); -void rtgui_win_hiden(struct rtgui_win *win) +void rtgui_win_hide(struct rtgui_win *win) { RT_ASSERT(win != RT_NULL); @@ -351,7 +351,7 @@ void rtgui_win_hiden(struct rtgui_win *win) win->flag &= ~RTGUI_WIN_FLAG_ACTIVATE; } } -RTM_EXPORT(rtgui_win_hiden); +RTM_EXPORT(rtgui_win_hide); rt_err_t rtgui_win_activate(struct rtgui_win *win) { @@ -469,7 +469,7 @@ rt_bool_t rtgui_win_event_handler(struct rtgui_object *object, struct rtgui_even break; case RTGUI_EVENT_WIN_HIDE: - rtgui_win_hiden(win); + rtgui_win_hide(win); break; case RTGUI_EVENT_WIN_CLOSE: @@ -538,27 +538,37 @@ rt_bool_t rtgui_win_event_handler(struct rtgui_object *object, struct rtgui_even break; case RTGUI_EVENT_MOUSE_BUTTON: - /* check whether has widget which handled mouse event before */ - if (win->last_mevent_widget != RT_NULL) - { - RTGUI_OBJECT(win->last_mevent_widget)->event_handler( - RTGUI_OBJECT(win->last_mevent_widget), - event); - - /* clean last mouse event handled widget */ - win->last_mevent_widget = RT_NULL; - } - else if (rtgui_container_dispatch_mouse_event(RTGUI_CONTAINER(win), - (struct rtgui_event_mouse *)event) == RT_FALSE) { + rt_bool_t res = rtgui_container_dispatch_mouse_event(RTGUI_CONTAINER(win), + (struct rtgui_event_mouse *)event); #ifndef RTGUI_USING_SMALL_SIZE if (RTGUI_WIDGET(object)->on_mouseclick != RT_NULL) { - return RTGUI_WIDGET(object)->on_mouseclick(object, event); + RTGUI_WIDGET(object)->on_mouseclick(object, event); } #endif + /* check whether has widget which handled mouse event before. + * + * Note #1: that the widget should have already received mouse down + * event and we should only feed the mouse up event to it here. + * + * Note #2: the widget is responsible to clean up + * last_mevent_widget on mouse up event(but not overwrite other + * widgets). If not, it will receive two mouse up events. + */ + if (((struct rtgui_event_mouse *)event)->button & RTGUI_MOUSE_BUTTON_UP + && win->last_mevent_widget != RT_NULL) + { + RTGUI_OBJECT(win->last_mevent_widget)->event_handler( + RTGUI_OBJECT(win->last_mevent_widget), + event); + + /* clean last mouse event handled widget */ + win->last_mevent_widget = RT_NULL; + } + + return res; } - break; case RTGUI_EVENT_MOUSE_MOTION: #if 0 @@ -623,7 +633,7 @@ rt_bool_t rtgui_win_event_handler(struct rtgui_object *object, struct rtgui_even return RT_TRUE; break; - default : + default: return rtgui_container_event_handler(object, event); } -- cgit v1.3.1