_windows window and tab dragging done
This commit is contained in:
@@ -7,10 +7,20 @@
|
||||
#include "Engine/Core/Collections/Array.h"
|
||||
#include "Engine/Platform/WindowsManager.h"
|
||||
#include "Engine/Platform/Win32/IncludeWindowsHeaders.h"
|
||||
#include "Engine/Input/Mouse.h"
|
||||
|
||||
#include <SDL3/SDL_hints.h>
|
||||
#include <SDL3/SDL_init.h>
|
||||
#include <SDL3/SDL_system.h>
|
||||
#include <SDL3/SDL_timer.h>
|
||||
#include "SDLInput.h"
|
||||
#include <Engine/Core/Log.h>
|
||||
|
||||
#if true
|
||||
|
||||
Window* draggedWindow = nullptr;
|
||||
Float2 draggedWindowStartPosition = Float2::Zero;
|
||||
Float2 draggedWindowMousePosition = Float2::Zero;
|
||||
|
||||
// The events for releasing the mouse during window dragging are missing, handle the mouse release event here
|
||||
bool SDLCALL SDLPlatform::EventMessageHook(void* userdata, MSG* msg)
|
||||
@@ -31,23 +41,73 @@ bool SDLCALL SDLPlatform::EventMessageHook(void* userdata, MSG* msg)
|
||||
ASSERT((window) != nullptr); \
|
||||
} while (false)
|
||||
|
||||
if (draggedWindow != nullptr)
|
||||
{
|
||||
LOG(Info, "event hook message: {}", msg->message);
|
||||
}
|
||||
|
||||
if (msg->message == WM_NCLBUTTONDOWN)
|
||||
{
|
||||
Window* window;
|
||||
GET_WINDOW_WITH_HWND(window, msg->hwnd);
|
||||
draggedWindow = window;
|
||||
|
||||
draggedWindowStartPosition = draggedWindow->GetClientPosition();
|
||||
draggedWindowMousePosition.X = static_cast<float>(static_cast<LONG>(WINDOWS_GET_X_LPARAM(msg->lParam)));
|
||||
draggedWindowMousePosition.Y = static_cast<float>(static_cast<LONG>(WINDOWS_GET_Y_LPARAM(msg->lParam)));
|
||||
draggedWindowMousePosition -= draggedWindowStartPosition;
|
||||
//auto hit = static_cast<WindowHitCodes>(msg->wParam);
|
||||
//if (SDLPlatform::CheckWindowDragging(window, hit))
|
||||
// return false;
|
||||
//bool result = false;
|
||||
//window->OnLeftButtonHit(static_cast<WindowHitCodes>(msg->wParam), result);
|
||||
//if (result)
|
||||
// return false;
|
||||
|
||||
auto hit = static_cast<WindowHitCodes>(msg->wParam);
|
||||
if (SDLPlatform::CheckWindowDragging(window, hit))
|
||||
return false;
|
||||
//::ClientToScreen(static_cast<HWND>(window->GetNativePtr()), &p);
|
||||
//const Float2 mousePos(static_cast<float>(p.x), static_cast<float>(p.y));
|
||||
|
||||
SDL_Event event{0};
|
||||
event.button.type = SDL_EVENT_MOUSE_BUTTON_DOWN;
|
||||
event.button.down = true;
|
||||
event.button.timestamp = SDL_GetTicksNS();
|
||||
event.button.windowID = SDL_GetWindowID(window->GetSDLWindow());
|
||||
event.button.button = SDL_BUTTON_LEFT;
|
||||
event.button.clicks = 1;
|
||||
event.button.x = draggedWindowMousePosition.X;
|
||||
event.button.y = draggedWindowMousePosition.Y;
|
||||
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
/*else if (msg->message == WM_NCLBUTTONUP || msg->message == WM_CAPTURECHANGED)
|
||||
{
|
||||
windowDragging = false;
|
||||
Window* window;
|
||||
GET_WINDOW_WITH_HWND(window, msg->hwnd);
|
||||
|
||||
SDL_Event event{ 0 };
|
||||
event.button.type = SDL_EVENT_MOUSE_BUTTON_UP;
|
||||
event.button.down = false;
|
||||
event.button.timestamp = SDL_GetTicksNS();
|
||||
event.button.windowID = SDL_GetWindowID(window->GetSDLWindow());
|
||||
event.button.button = SDL_BUTTON_LEFT;
|
||||
event.button.clicks = 1;
|
||||
event.button.x = static_cast<float>(static_cast<LONG>(WINDOWS_GET_X_LPARAM(msg->lParam)));
|
||||
event.button.y = static_cast<float>(static_cast<LONG>(WINDOWS_GET_Y_LPARAM(msg->lParam)));
|
||||
|
||||
SDL_PushEvent(&event);
|
||||
}*/
|
||||
return true;
|
||||
#undef GET_WINDOW_WITH_HWND
|
||||
}
|
||||
#endif
|
||||
|
||||
bool SDLPlatform::InitPlatform()
|
||||
{
|
||||
#if true
|
||||
// Workaround required for handling window dragging events properly for DockHintWindow
|
||||
SDL_SetWindowsMessageHook(&EventMessageHook, nullptr);
|
||||
#endif
|
||||
|
||||
if (WindowsPlatform::Init())
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user