Skip to content

Commit

Permalink
add EVT_NATIVE_WINDOW_FOCUS_GAINED
Browse files Browse the repository at this point in the history
  • Loading branch information
xianjimli committed Dec 13, 2024
1 parent ba105c0 commit 2621b56
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion docs/changes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# 最新动态

2024/12/13
* 增加EVT\_NATIVE\_WINDOW\_FOCUS\_GAINED(感谢兆坤提供补丁)

2024/12/10
* 修复scroll_bar_d不指定max时控件内的dragger不显示的问题(感谢雨欣提供补丁)
* 修复scroll\_bar\_d不指定max时控件内的dragger不显示的问题(感谢雨欣提供补丁)
* 修复 dialog 对话框在退出过程中还会被传递事件的问题 (感谢高源提供补丁)

2024/12/08
Expand Down
1 change: 1 addition & 0 deletions src/base/native_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ typedef enum _native_window_event_type_t {
EVT_NATIVE_WINDOW_DESTROY,
EVT_NATIVE_WINDOW_ENTER,
EVT_NATIVE_WINDOW_LEAVE,
EVT_NATIVE_WINDOW_FOCUS_GAINED,
EVT_NATIVE_WINDOW_FOCUS_LOST,
} native_window_event_type_t;

Expand Down
7 changes: 6 additions & 1 deletion src/main_loop/main_loop_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,14 @@ static ret_t main_loop_sdl2_dispatch_window_event(main_loop_simple_t* loop, SDL_
window_manager_dispatch_native_window_event(l->wm, &e, win);
break;
}
case SDL_WINDOWEVENT_FOCUS_GAINED:
case SDL_WINDOWEVENT_FOCUS_GAINED: {
event_t e = event_init(EVT_NATIVE_WINDOW_FOCUS_GAINED, NULL);
SDL_Window* win = SDL_GetWindowFromID(event->window.windowID);

log_debug("Window %d gained keyboard focus\n", event->window.windowID);
window_manager_dispatch_native_window_event(l->wm, &e, win);
break;
}
case SDL_WINDOWEVENT_FOCUS_LOST: {
event_t e = event_init(EVT_NATIVE_WINDOW_FOCUS_LOST, NULL);
SDL_Window* win = SDL_GetWindowFromID(event->window.windowID);
Expand Down
3 changes: 3 additions & 0 deletions src/window_manager/window_manager_default.c
Original file line number Diff line number Diff line change
Expand Up @@ -1885,8 +1885,11 @@ static ret_t window_manager_default_dispatch_native_window_event(widget_t* widge
input_device_status_on_pointer_enter(ids, widget, x, y);
} else if (e->type == EVT_NATIVE_WINDOW_LEAVE) {
input_device_status_on_pointer_leave(ids, widget);
} else if (e->type == EVT_NATIVE_WINDOW_FOCUS_GAINED) {
widget_dispatch_simple_event(widget, EVT_FOCUS);
} else if (e->type == EVT_NATIVE_WINDOW_FOCUS_LOST) {
input_device_status_abort_keys_and_mouse(ids);
widget_dispatch_simple_event(widget, EVT_BLUR);
}

return RET_OK;
Expand Down

0 comments on commit 2621b56

Please sign in to comment.