diff --git a/docs/changes.md b/docs/changes.md index 48f45d483..e98eb6598 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -2,6 +2,7 @@ 2024/12/02 * 修正 edit 未处理 key down 事件时不应返回 RET_STOP 的问题(感谢朝泽提供补丁) + * Windows 下原生窗口无标题栏时允许拖动原生窗口(感谢俊杰提供补丁) 2024/11/30 * 增加函数 main\_loop\_post\_touch\_event diff --git a/src/main_loop/main_loop_sdl.c b/src/main_loop/main_loop_sdl.c index 28e9e649a..630b9afe4 100644 --- a/src/main_loop/main_loop_sdl.c +++ b/src/main_loop/main_loop_sdl.c @@ -30,7 +30,7 @@ #include "base/timer.h" #include "base/system_info.h" #include - +#include #include #include "awtk_global.h" #include "tkc/time_now.h" @@ -162,6 +162,7 @@ static ret_t main_loop_sdl2_dispatch_mouse_event(main_loop_simple_t* loop, SDL_E pointer_event_t event; int type = sdl_event->type; widget_t* widget = loop->base.wm; + SDL_SysWMinfo sdl_info; memset(&event, 0x00, sizeof(event)); switch (type) { @@ -173,8 +174,13 @@ static ret_t main_loop_sdl2_dispatch_mouse_event(main_loop_simple_t* loop, SDL_E event.button = sdl_event->button.button; event.pressed = loop->pressed; event.e.native_window_handle = SDL_GetWindowFromID(sdl_event->button.windowID); - SDL_CaptureMouse(TRUE); + SDL_GetWindowWMInfo(event.e.native_window_handle, &sdl_info); + if (sdl_event->button.x < loop->w && sdl_event->button.y < loop->h) { +#ifdef WIN32 + SendMessage(sdl_info.info.win.window, WM_NCLBUTTONDOWN, HTCAPTION, 0); +#endif + } window_manager_dispatch_input_event(widget, (event_t*)&event); } else if (sdl_event->button.button == 2) { key_event_init(&key_event, EVT_KEY_DOWN, widget, TK_KEY_WHEEL);