mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-02-07 09:34:34 +08:00
gui 引擎已知问题优化修复;
This commit is contained in:
parent
2c145743cb
commit
c4e8c922d3
@ -342,6 +342,8 @@ struct rtgui_event_gesture
|
|||||||
_RTGUI_EVENT_WIN_ELEMENTS
|
_RTGUI_EVENT_WIN_ELEMENTS
|
||||||
|
|
||||||
enum rtgui_gesture_type type;
|
enum rtgui_gesture_type type;
|
||||||
|
|
||||||
|
rt_uint32_t win_acti_cnt; /* win id */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -359,6 +361,8 @@ struct rtgui_event_mouse
|
|||||||
/* id of touch session(from down to up). Different session should have
|
/* id of touch session(from down to up). Different session should have
|
||||||
* 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 */
|
||||||
};
|
};
|
||||||
#define RTGUI_MOUSE_BUTTON_LEFT 0x01
|
#define RTGUI_MOUSE_BUTTON_LEFT 0x01
|
||||||
#define RTGUI_MOUSE_BUTTON_RIGHT 0x02
|
#define RTGUI_MOUSE_BUTTON_RIGHT 0x02
|
||||||
@ -379,6 +383,8 @@ struct rtgui_event_kbd
|
|||||||
{
|
{
|
||||||
_RTGUI_EVENT_WIN_ELEMENTS
|
_RTGUI_EVENT_WIN_ELEMENTS
|
||||||
|
|
||||||
|
rt_uint32_t win_acti_cnt; /* win id */
|
||||||
|
|
||||||
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 */
|
||||||
rt_uint16_t mod; /* current key modifiers */
|
rt_uint16_t mod; /* current key modifiers */
|
||||||
|
@ -81,6 +81,8 @@ struct rtgui_app
|
|||||||
rtgui_idle_func_t on_idle;
|
rtgui_idle_func_t on_idle;
|
||||||
|
|
||||||
unsigned int window_cnt;
|
unsigned int window_cnt;
|
||||||
|
/* window activate count */
|
||||||
|
unsigned int win_acti_cnt;
|
||||||
|
|
||||||
void *user_data;
|
void *user_data;
|
||||||
};
|
};
|
||||||
@ -115,6 +117,9 @@ rt_err_t rtgui_app_set_as_wm(struct rtgui_app *app);
|
|||||||
void rtgui_app_set_main_win(struct rtgui_app *app, struct rtgui_win *win);
|
void rtgui_app_set_main_win(struct rtgui_app *app, struct rtgui_win *win);
|
||||||
struct rtgui_win* rtgui_app_get_main_win(struct rtgui_app *app);
|
struct rtgui_win* rtgui_app_get_main_win(struct rtgui_app *app);
|
||||||
|
|
||||||
|
/* get the topwin belong app window activate count */
|
||||||
|
unsigned int rtgui_app_get_win_acti_cnt(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -54,6 +54,8 @@ DECLARE_CLASS_TYPE(win);
|
|||||||
#define RTGUI_WIN_STYLE_ONBTM 0x0080 /* window is in the bottom layer */
|
#define RTGUI_WIN_STYLE_ONBTM 0x0080 /* window is in the bottom layer */
|
||||||
#define RTGUI_WIN_STYLE_MAINWIN 0x0106 /* window is a main window */
|
#define RTGUI_WIN_STYLE_MAINWIN 0x0106 /* window is a main window */
|
||||||
|
|
||||||
|
#define RTGUI_WIN_MAGIC 0xA5A55A5A /* win magic flag */
|
||||||
|
|
||||||
#define RTGUI_WIN_STYLE_DEFAULT (RTGUI_WIN_STYLE_CLOSEBOX | RTGUI_WIN_STYLE_MINIBOX)
|
#define RTGUI_WIN_STYLE_DEFAULT (RTGUI_WIN_STYLE_CLOSEBOX | RTGUI_WIN_STYLE_MINIBOX)
|
||||||
|
|
||||||
#define WINTITLE_HEIGHT 20
|
#define WINTITLE_HEIGHT 20
|
||||||
@ -143,6 +145,7 @@ struct rtgui_win
|
|||||||
|
|
||||||
/* app ref_count */
|
/* app ref_count */
|
||||||
rt_uint16_t app_ref_count;
|
rt_uint16_t app_ref_count;
|
||||||
|
|
||||||
/* win magic flag, magic value is 0xA5A55A5A */
|
/* win magic flag, magic value is 0xA5A55A5A */
|
||||||
rt_uint32_t magic;
|
rt_uint32_t magic;
|
||||||
};
|
};
|
||||||
|
@ -1689,6 +1689,13 @@ void rtgui_dc_get_rect(struct rtgui_dc *dc, rtgui_rect_t *rect)
|
|||||||
dc_hw = (struct rtgui_dc_hw *) dc;
|
dc_hw = (struct rtgui_dc_hw *) dc;
|
||||||
owner = dc_hw->owner;
|
owner = dc_hw->owner;
|
||||||
rtgui_widget_get_rect(owner, rect);
|
rtgui_widget_get_rect(owner, rect);
|
||||||
|
|
||||||
|
if (owner->extent.x1 + rect->x2 > dc_hw->hw_driver->width)
|
||||||
|
rect->x2 = dc_hw->hw_driver->width - owner->extent.x1;
|
||||||
|
|
||||||
|
if (owner->extent.y1 + rect->y2 > dc_hw->hw_driver->height)
|
||||||
|
rect->y2 = dc_hw->hw_driver->height - owner->extent.y1;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RTGUI_DC_BUFFER:
|
case RTGUI_DC_BUFFER:
|
||||||
@ -1806,7 +1813,7 @@ extern void rtgui_mouse_hide_cursor(void);
|
|||||||
struct rtgui_dc *rtgui_dc_begin_drawing(rtgui_widget_t *owner)
|
struct rtgui_dc *rtgui_dc_begin_drawing(rtgui_widget_t *owner)
|
||||||
{
|
{
|
||||||
struct rtgui_dc *dc;
|
struct rtgui_dc *dc;
|
||||||
struct rtgui_widget *widget;
|
struct rtgui_widget *widget, *parent;
|
||||||
struct rtgui_win *win;
|
struct rtgui_win *win;
|
||||||
|
|
||||||
RT_ASSERT(owner != RT_NULL);
|
RT_ASSERT(owner != RT_NULL);
|
||||||
@ -1815,11 +1822,18 @@ struct rtgui_dc *rtgui_dc_begin_drawing(rtgui_widget_t *owner)
|
|||||||
if (win == RT_NULL)
|
if (win == RT_NULL)
|
||||||
return RT_NULL;
|
return RT_NULL;
|
||||||
|
|
||||||
|
parent = (struct rtgui_widget *)win;
|
||||||
|
|
||||||
if (!(win->flag & RTGUI_WIN_FLAG_ACTIVATE) &&
|
if (!(win->flag & RTGUI_WIN_FLAG_ACTIVATE) &&
|
||||||
(win->outer_clip.extents.x1 == win->outer_clip.extents.x2 ||
|
(win->outer_clip.extents.x1 == win->outer_clip.extents.x2 ||
|
||||||
win->outer_clip.extents.y1 == win->outer_clip.extents.y2))
|
win->outer_clip.extents.y1 == win->outer_clip.extents.y2))
|
||||||
return RT_NULL;
|
return RT_NULL;
|
||||||
|
|
||||||
|
if (!(win->flag & RTGUI_WIN_FLAG_ACTIVATE) &&
|
||||||
|
(parent->clip.extents.x1 == parent->clip.extents.x2 ||
|
||||||
|
parent->clip.extents.y1 == parent->clip.extents.y2))
|
||||||
|
return RT_NULL;
|
||||||
|
|
||||||
/* increase drawing count */
|
/* increase drawing count */
|
||||||
if (win->drawing == 0)
|
if (win->drawing == 0)
|
||||||
{
|
{
|
||||||
|
@ -216,32 +216,22 @@ static void rtgui_dc_hw_fill_rect(struct rtgui_dc *self, struct rtgui_rect *rect
|
|||||||
return;
|
return;
|
||||||
if (x1 < dc->owner->extent.x1)
|
if (x1 < dc->owner->extent.x1)
|
||||||
x1 = dc->owner->extent.x1;
|
x1 = dc->owner->extent.x1;
|
||||||
if (x1 < 0)
|
|
||||||
x1 = 0;
|
|
||||||
|
|
||||||
x2 = rect->x2 + dc->owner->extent.x1;
|
x2 = rect->x2 + dc->owner->extent.x1;
|
||||||
if (x2 < dc->owner->extent.x1)
|
if (x2 < dc->owner->extent.x1)
|
||||||
return;
|
return;
|
||||||
if (x2 > dc->owner->extent.x2)
|
if (x2 > dc->owner->extent.x2)
|
||||||
x2 = dc->owner->extent.x2;
|
x2 = dc->owner->extent.x2;
|
||||||
if (x2 > dc->hw_driver->width)
|
|
||||||
x2 = dc->hw_driver->width;
|
|
||||||
|
|
||||||
y1 = rect->y1 + dc->owner->extent.y1;
|
y1 = rect->y1 + dc->owner->extent.y1;
|
||||||
if (y1 > dc->owner->extent.y2)
|
if (y1 > dc->owner->extent.y2)
|
||||||
return;
|
return;
|
||||||
if (y1 < dc->owner->extent.y1)
|
if (y1 < dc->owner->extent.y1)
|
||||||
y1 = dc->owner->extent.y1;
|
y1 = dc->owner->extent.y1;
|
||||||
if (y1 < 0)
|
|
||||||
y1 = 0;
|
|
||||||
|
|
||||||
y2 = rect->y2 + dc->owner->extent.y1;
|
y2 = rect->y2 + dc->owner->extent.y1;
|
||||||
if (y2 < dc->owner->extent.y1)
|
if (y2 < dc->owner->extent.y1)
|
||||||
return;
|
return;
|
||||||
if (y2 > dc->owner->extent.y2)
|
if (y2 > dc->owner->extent.y2)
|
||||||
y2 = dc->owner->extent.y2;
|
y2 = dc->owner->extent.y2;
|
||||||
if (y2 > dc->hw_driver->height)
|
|
||||||
y2 = dc->hw_driver->height;
|
|
||||||
|
|
||||||
/* fill rect */
|
/* fill rect */
|
||||||
for (; y1 < y2; y1++)
|
for (; y1 < y2; y1++)
|
||||||
|
@ -103,7 +103,7 @@ static void rtgui_bitmap_font_draw_text(struct rtgui_font *font, struct rtgui_dc
|
|||||||
|
|
||||||
RT_ASSERT(bmp_font != RT_NULL);
|
RT_ASSERT(bmp_font != RT_NULL);
|
||||||
|
|
||||||
rtgui_font_get_metrics(rtgui_dc_get_gc(dc)->font, text, &text_rect);
|
rtgui_font_get_metrics(font, text, &text_rect);
|
||||||
rtgui_rect_move_to_align(rect, &text_rect, RTGUI_DC_TEXTALIGN(dc));
|
rtgui_rect_move_to_align(rect, &text_rect, RTGUI_DC_TEXTALIGN(dc));
|
||||||
|
|
||||||
/* parameter check */
|
/* parameter check */
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include <rtgui/rtgui_system.h>
|
#include <rtgui/rtgui_system.h>
|
||||||
#include <rtgui/rtgui_app.h>
|
#include <rtgui/rtgui_app.h>
|
||||||
#include <rtgui/widgets/window.h>
|
#include <rtgui/widgets/window.h>
|
||||||
#include "topwin.h"
|
#include <topwin.h>
|
||||||
|
|
||||||
static void _rtgui_app_constructor(struct rtgui_app *app)
|
static void _rtgui_app_constructor(struct rtgui_app *app)
|
||||||
{
|
{
|
||||||
@ -43,6 +43,7 @@ static void _rtgui_app_constructor(struct rtgui_app *app)
|
|||||||
app->state_flag = RTGUI_APP_FLAG_EXITED;
|
app->state_flag = RTGUI_APP_FLAG_EXITED;
|
||||||
app->ref_count = 0;
|
app->ref_count = 0;
|
||||||
app->window_cnt = 0;
|
app->window_cnt = 0;
|
||||||
|
app->win_acti_cnt = 0;
|
||||||
app->exit_code = 0;
|
app->exit_code = 0;
|
||||||
app->tid = RT_NULL;
|
app->tid = RT_NULL;
|
||||||
app->mq = RT_NULL;
|
app->mq = RT_NULL;
|
||||||
@ -204,7 +205,7 @@ rt_inline rt_bool_t _rtgui_application_dest_handle(
|
|||||||
if (wevent->wid == RT_NULL)
|
if (wevent->wid == RT_NULL)
|
||||||
return RT_FALSE;
|
return RT_FALSE;
|
||||||
|
|
||||||
if (wevent->wid->magic != 0xA5A55A5A)
|
if (wevent->wid->magic != RTGUI_WIN_MAGIC)
|
||||||
{
|
{
|
||||||
return RT_FALSE;
|
return RT_FALSE;
|
||||||
}
|
}
|
||||||
@ -249,19 +250,55 @@ rt_bool_t rtgui_app_event_handler(struct rtgui_object *object, rtgui_event_t *ev
|
|||||||
|
|
||||||
switch (event->type)
|
switch (event->type)
|
||||||
{
|
{
|
||||||
case RTGUI_EVENT_PAINT:
|
case RTGUI_EVENT_KBD:
|
||||||
case RTGUI_EVENT_VPAINT_REQ:
|
{
|
||||||
|
struct rtgui_event_kbd *kbd = (struct rtgui_event_kbd*)event;
|
||||||
|
|
||||||
|
if (kbd->win_acti_cnt != app->win_acti_cnt)
|
||||||
|
break;
|
||||||
|
|
||||||
|
_rtgui_application_dest_handle(app, event);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case RTGUI_EVENT_MOUSE_BUTTON:
|
case RTGUI_EVENT_MOUSE_BUTTON:
|
||||||
case RTGUI_EVENT_MOUSE_MOTION:
|
case RTGUI_EVENT_MOUSE_MOTION:
|
||||||
case RTGUI_EVENT_CLIP_INFO:
|
{
|
||||||
|
struct rtgui_event_mouse *wevent = (struct rtgui_event_mouse *)event;
|
||||||
|
|
||||||
|
if (wevent->win_acti_cnt != app->win_acti_cnt)
|
||||||
|
break;
|
||||||
|
|
||||||
|
_rtgui_application_dest_handle(app, event);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RTGUI_EVENT_GESTURE:
|
||||||
|
{
|
||||||
|
struct rtgui_event_gesture *wevent = (struct rtgui_event_gesture *)event;
|
||||||
|
|
||||||
|
if (wevent->win_acti_cnt != app->win_acti_cnt)
|
||||||
|
break;
|
||||||
|
|
||||||
|
_rtgui_application_dest_handle(app, event);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case RTGUI_EVENT_WIN_ACTIVATE:
|
case RTGUI_EVENT_WIN_ACTIVATE:
|
||||||
|
{
|
||||||
|
app->win_acti_cnt++;
|
||||||
|
_rtgui_application_dest_handle(app, event);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RTGUI_EVENT_PAINT:
|
||||||
|
case RTGUI_EVENT_VPAINT_REQ:
|
||||||
|
case RTGUI_EVENT_CLIP_INFO:
|
||||||
case RTGUI_EVENT_WIN_DEACTIVATE:
|
case RTGUI_EVENT_WIN_DEACTIVATE:
|
||||||
case RTGUI_EVENT_WIN_CLOSE:
|
case RTGUI_EVENT_WIN_CLOSE:
|
||||||
case RTGUI_EVENT_WIN_MOVE:
|
case RTGUI_EVENT_WIN_MOVE:
|
||||||
case RTGUI_EVENT_WIN_SHOW:
|
case RTGUI_EVENT_WIN_SHOW:
|
||||||
case RTGUI_EVENT_WIN_HIDE:
|
case RTGUI_EVENT_WIN_HIDE:
|
||||||
case RTGUI_EVENT_KBD:
|
|
||||||
case RTGUI_EVENT_GESTURE:
|
|
||||||
_rtgui_application_dest_handle(app, event);
|
_rtgui_application_dest_handle(app, event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -507,3 +544,16 @@ struct rtgui_win *rtgui_app_get_main_win(struct rtgui_app *app)
|
|||||||
}
|
}
|
||||||
RTM_EXPORT(rtgui_app_get_main_win);
|
RTM_EXPORT(rtgui_app_get_main_win);
|
||||||
|
|
||||||
|
unsigned int rtgui_app_get_win_acti_cnt(void)
|
||||||
|
{
|
||||||
|
struct rtgui_app *app = rtgui_topwin_app_get_focus();
|
||||||
|
|
||||||
|
if (app)
|
||||||
|
{
|
||||||
|
return app->win_acti_cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
RTM_EXPORT(rtgui_app_get_win_acti_cnt);
|
||||||
|
|
||||||
|
@ -853,6 +853,19 @@ struct rtgui_topwin *rtgui_topwin_get_focus(void)
|
|||||||
return _rtgui_topwin_get_focus_from_list(&_rtgui_topwin_list);
|
return _rtgui_topwin_get_focus_from_list(&_rtgui_topwin_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct rtgui_app *rtgui_topwin_app_get_focus(void)
|
||||||
|
{
|
||||||
|
struct rtgui_app *topwin_app = RT_NULL;
|
||||||
|
struct rtgui_topwin *topwin = rtgui_topwin_get_focus();
|
||||||
|
|
||||||
|
if (topwin)
|
||||||
|
{
|
||||||
|
topwin_app = topwin->app;
|
||||||
|
}
|
||||||
|
|
||||||
|
return topwin_app;
|
||||||
|
}
|
||||||
|
|
||||||
static struct rtgui_topwin *_rtgui_topwin_get_wnd_from_tree(struct rt_list_node *list,
|
static struct rtgui_topwin *_rtgui_topwin_get_wnd_from_tree(struct rt_list_node *list,
|
||||||
int x, int y,
|
int x, int y,
|
||||||
rt_bool_t exclude_modaled)
|
rt_bool_t exclude_modaled)
|
||||||
@ -978,7 +991,8 @@ static void _rtgui_topwin_redraw_tree(struct rt_list_node *list,
|
|||||||
if (rtgui_rect_is_intersect(rect, &(topwin->extent)) == RT_EOK)
|
if (rtgui_rect_is_intersect(rect, &(topwin->extent)) == RT_EOK)
|
||||||
{
|
{
|
||||||
epaint->wid = topwin->wid;
|
epaint->wid = topwin->wid;
|
||||||
rtgui_send(topwin->app, &(epaint->parent), sizeof(*epaint));
|
// < XY do !!! >
|
||||||
|
//rtgui_send(topwin->app, &(epaint->parent), sizeof(*epaint));
|
||||||
}
|
}
|
||||||
|
|
||||||
_rtgui_topwin_redraw_tree(&topwin->child_list, rect, epaint);
|
_rtgui_topwin_redraw_tree(&topwin->child_list, rect, epaint);
|
||||||
@ -1026,7 +1040,8 @@ rt_err_t rtgui_topwin_modal_enter(struct rtgui_event_win_modal_enter *event)
|
|||||||
parent_top->flag |= WINTITLE_MODALED;
|
parent_top->flag |= WINTITLE_MODALED;
|
||||||
parent_top->wid->flag |= RTGUI_WIN_FLAG_UNDER_MODAL;
|
parent_top->wid->flag |= RTGUI_WIN_FLAG_UNDER_MODAL;
|
||||||
parent_top = parent_top->parent;
|
parent_top = parent_top->parent;
|
||||||
} while (parent_top);
|
}
|
||||||
|
while (parent_top);
|
||||||
|
|
||||||
topwin->flag &= ~WINTITLE_MODALED;
|
topwin->flag &= ~WINTITLE_MODALED;
|
||||||
topwin->wid->flag &= ~RTGUI_WIN_FLAG_UNDER_MODAL;
|
topwin->wid->flag &= ~RTGUI_WIN_FLAG_UNDER_MODAL;
|
||||||
|
@ -64,6 +64,9 @@ void rtgui_topwin_remove_monitor_rect(struct rtgui_win *wid, rtgui_rect_t *rect)
|
|||||||
/* get the topwin that is currently focused */
|
/* get the topwin that is currently focused */
|
||||||
struct rtgui_topwin *rtgui_topwin_get_focus(void);
|
struct rtgui_topwin *rtgui_topwin_get_focus(void);
|
||||||
|
|
||||||
|
/* get the topwin which app I belong */
|
||||||
|
struct rtgui_app *rtgui_topwin_app_get_focus(void);
|
||||||
|
|
||||||
struct rtgui_topwin *rtgui_topwin_get_topmost_window_shown_all(void);
|
struct rtgui_topwin *rtgui_topwin_get_topmost_window_shown_all(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -440,7 +440,7 @@ rt_base_t rtgui_win_show(struct rtgui_win *win, rt_bool_t is_modal)
|
|||||||
{
|
{
|
||||||
RTGUI_WIDGET_UNHIDE(win);
|
RTGUI_WIDGET_UNHIDE(win);
|
||||||
|
|
||||||
win->magic = 0xA5A55A5A;
|
win->magic = RTGUI_WIN_MAGIC;
|
||||||
|
|
||||||
if (is_modal)
|
if (is_modal)
|
||||||
win->flag |= RTGUI_WIN_FLAG_MODAL;
|
win->flag |= RTGUI_WIN_FLAG_MODAL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user