fix bug when set focus of background window

This commit is contained in:
lixianjing 2021-08-17 17:24:53 +08:00
parent adbf4771d8
commit 305114d041
3 changed files with 13 additions and 0 deletions

View File

@ -1,5 +1,8 @@
# 最新动态
2021/08/17
* 修复设置后台窗口焦点导致的问题。
2021/08/16
* check button允许使用radio属性控制单选多选。
* scroll bar允许使用is_mobile属性控制mobile/desktop

View File

@ -725,7 +725,14 @@ ret_t widget_set_floating(widget_t* widget, bool_t floating) {
}
ret_t widget_set_focused_internal(widget_t* widget, bool_t focused) {
widget_t* win = widget_get_window(widget);
int32_t stage = widget_get_prop_int(win, WIDGET_PROP_STAGE, WINDOW_STAGE_NONE);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
if (WINDOW_STAGE_SUSPEND == stage) {
log_debug("You can not set focus of a widget when window is in background");
return RET_FAIL;
}
if (widget->focused != focused) {
widget->focused = focused;

View File

@ -393,6 +393,9 @@ ret_t window_base_on_event(widget_t* widget, event_t* e) {
window_base_load_theme_obj(widget);
widget_update_style_recursive(widget);
widget_layout(widget);
if (widget->sensitive) {
widget_set_focused_internal(widget, TRUE);
}
} else if (e->type == EVT_WINDOW_OPEN) {
win->stage = WINDOW_STAGE_OPENED;
if (widget->sensitive) {