Skip to content

Commit

Permalink
support drag native window when native window without title on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
xianjimli committed Dec 2, 2024
1 parent 423ef10 commit 3722bec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

2024/12/02
* 修正 edit 未处理 key down 事件时不应返回 RET_STOP 的问题(感谢朝泽提供补丁)
* Windows 下原生窗口无标题栏时允许拖动原生窗口(感谢俊杰提供补丁)

2024/11/30
* 增加函数 main\_loop\_post\_touch\_event
Expand Down
10 changes: 8 additions & 2 deletions src/main_loop/main_loop_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "base/timer.h"
#include "base/system_info.h"
#include <SDL.h>

#include <SDL_syswm.h>
#include <stdio.h>
#include "awtk_global.h"
#include "tkc/time_now.h"
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand Down

0 comments on commit 3722bec

Please sign in to comment.