mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
Added SDL_WINDOWEVENT_HIT_TEST.
This lets windows know when they are dropping a mouse event because their hit test reported something other than SDL_HITTEST_NORMAL. It lets them know exactly where in the event queue this happened. This patch is based on work in Unreal Engine 4's fork of SDL, compliments of Epic Games.
This commit is contained in:
parent
d4aedf9951
commit
aa4952fdef
@ -160,8 +160,8 @@ typedef enum
|
|||||||
SDL_WINDOWEVENT_LEAVE, /**< Window has lost mouse focus */
|
SDL_WINDOWEVENT_LEAVE, /**< Window has lost mouse focus */
|
||||||
SDL_WINDOWEVENT_FOCUS_GAINED, /**< Window has gained keyboard focus */
|
SDL_WINDOWEVENT_FOCUS_GAINED, /**< Window has gained keyboard focus */
|
||||||
SDL_WINDOWEVENT_FOCUS_LOST, /**< Window has lost keyboard focus */
|
SDL_WINDOWEVENT_FOCUS_LOST, /**< Window has lost keyboard focus */
|
||||||
SDL_WINDOWEVENT_CLOSE /**< The window manager requests that the
|
SDL_WINDOWEVENT_CLOSE, /**< The window manager requests that the window be closed */
|
||||||
window be closed */
|
SDL_WINDOWEVENT_HIT_TEST /** Window had a hit test that wasn't SDL_HITTEST_NORMAL. */
|
||||||
} SDL_WindowEventID;
|
} SDL_WindowEventID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -852,6 +852,7 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ([self processHitTest:theEvent]) {
|
if ([self processHitTest:theEvent]) {
|
||||||
|
SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_HIT_TEST, 0, 0);
|
||||||
return; /* dragging, drop event. */
|
return; /* dragging, drop event. */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -894,6 +895,7 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
|
|||||||
int button;
|
int button;
|
||||||
|
|
||||||
if ([self processHitTest:theEvent]) {
|
if ([self processHitTest:theEvent]) {
|
||||||
|
SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_HIT_TEST, 0, 0);
|
||||||
return; /* stopped dragging, drop event. */
|
return; /* stopped dragging, drop event. */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -937,6 +939,7 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
|
|||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
if ([self processHitTest:theEvent]) {
|
if ([self processHitTest:theEvent]) {
|
||||||
|
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_HIT_TEST, 0, 0);
|
||||||
return; /* dragging, drop event. */
|
return; /* dragging, drop event. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -928,15 +928,17 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
const SDL_Point point = { (int) winpoint.x, (int) winpoint.y };
|
const SDL_Point point = { (int) winpoint.x, (int) winpoint.y };
|
||||||
const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data);
|
const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data);
|
||||||
switch (rc) {
|
switch (rc) {
|
||||||
case SDL_HITTEST_DRAGGABLE: return HTCAPTION;
|
#define POST_HIT_TEST(ret) { SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIT_TEST, 0, 0); return ret; }
|
||||||
case SDL_HITTEST_RESIZE_TOPLEFT: return HTTOPLEFT;
|
case SDL_HITTEST_DRAGGABLE: POST_HIT_TEST(HTCAPTION);
|
||||||
case SDL_HITTEST_RESIZE_TOP: return HTTOP;
|
case SDL_HITTEST_RESIZE_TOPLEFT: POST_HIT_TEST(HTTOPLEFT);
|
||||||
case SDL_HITTEST_RESIZE_TOPRIGHT: return HTTOPRIGHT;
|
case SDL_HITTEST_RESIZE_TOP: POST_HIT_TEST(HTTOP);
|
||||||
case SDL_HITTEST_RESIZE_RIGHT: return HTRIGHT;
|
case SDL_HITTEST_RESIZE_TOPRIGHT: POST_HIT_TEST(HTTOPRIGHT);
|
||||||
case SDL_HITTEST_RESIZE_BOTTOMRIGHT: return HTBOTTOMRIGHT;
|
case SDL_HITTEST_RESIZE_RIGHT: POST_HIT_TEST(HTRIGHT);
|
||||||
case SDL_HITTEST_RESIZE_BOTTOM: return HTBOTTOM;
|
case SDL_HITTEST_RESIZE_BOTTOMRIGHT: POST_HIT_TEST(HTBOTTOMRIGHT);
|
||||||
case SDL_HITTEST_RESIZE_BOTTOMLEFT: return HTBOTTOMLEFT;
|
case SDL_HITTEST_RESIZE_BOTTOM: POST_HIT_TEST(HTBOTTOM);
|
||||||
case SDL_HITTEST_RESIZE_LEFT: return HTLEFT;
|
case SDL_HITTEST_RESIZE_BOTTOMLEFT: POST_HIT_TEST(HTBOTTOMLEFT);
|
||||||
|
case SDL_HITTEST_RESIZE_LEFT: POST_HIT_TEST(HTLEFT);
|
||||||
|
#undef POST_HIT_TEST
|
||||||
case SDL_HITTEST_NORMAL: return HTCLIENT;
|
case SDL_HITTEST_NORMAL: return HTCLIENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1011,6 +1011,7 @@ X11_DispatchEvent(_THIS)
|
|||||||
int button = xevent.xbutton.button;
|
int button = xevent.xbutton.button;
|
||||||
if(button == Button1) {
|
if(button == Button1) {
|
||||||
if (ProcessHitTest(_this, data, &xevent)) {
|
if (ProcessHitTest(_this, data, &xevent)) {
|
||||||
|
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIT_TEST, 0, 0);
|
||||||
break; /* don't pass this event on to app. */
|
break; /* don't pass this event on to app. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user