From e676c754591d3f5598e49e0495ccb69a4629de75 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Mon, 20 Jan 2025 20:12:06 +0200 Subject: [PATCH] clean --- Source/Engine/Platform/SDL/SDLPlatform.cpp | 70 +--------------------- 1 file changed, 2 insertions(+), 68 deletions(-) diff --git a/Source/Engine/Platform/SDL/SDLPlatform.cpp b/Source/Engine/Platform/SDL/SDLPlatform.cpp index 814a6f134..b16e33585 100644 --- a/Source/Engine/Platform/SDL/SDLPlatform.cpp +++ b/Source/Engine/Platform/SDL/SDLPlatform.cpp @@ -218,18 +218,6 @@ void SDLPlatform::Tick() SDLWindow* window = SDLWindow::GetWindowFromEvent(*event); if (event->type == SDL_EVENT_WINDOW_EXPOSED) { - /*SDL_Event mouseDownEvent{ 0 }; - mouseDownEvent.button.type = SDL_EVENT_MOUSE_BUTTON_DOWN; - mouseDownEvent.button.down = true; - mouseDownEvent.button.timestamp = SDL_GetTicksNS(); - mouseDownEvent.button.windowID = SDL_GetWindowID(window->GetSDLWindow()); - mouseDownEvent.button.button = SDL_BUTTON_LEFT; - mouseDownEvent.button.clicks = 1; - mouseDownEvent.button.x = 0;//static_cast(static_cast(WINDOWS_GET_X_LPARAM(msg->lParam))); - mouseDownEvent.button.y = 0;//static_cast(static_cast(WINDOWS_GET_Y_LPARAM(msg->lParam))); - if (window) - window->HandleEvent(*event);*/ - Engine::OnUpdate();//Scripting::Update(); // For docking updates Engine::OnDraw(); return false; @@ -248,17 +236,12 @@ void SDLPlatform::Tick() return false; } - /*else if (event->type == SDL_EVENT_MOUSE_BUTTON_UP) - { - LOG(Info, "ate SDL_EVENT_MOUSE_BUTTON_UP"); - return false; - }*/ else if (event->type == SDL_EVENT_WINDOW_MOVED) { Float2 start = draggedWindowStartPosition; Float2 newPos = Float2(static_cast(event->window.data1), static_cast(event->window.data2)); Float2 offset = newPos - start; - Float2 mousePos = draggedWindowMousePosition/* + offset*/; + Float2 mousePos = draggedWindowMousePosition; SDL_Event mouseMovedEvent { 0 }; mouseMovedEvent.motion.type = SDL_EVENT_MOUSE_MOTION; @@ -277,59 +260,10 @@ void SDLPlatform::Tick() if (window) window->HandleEvent(*event); - /*bool* dragging = (bool*)userdata; - if (event->type == SDL_EVENT_WINDOW_EXPOSED) - { - // This event is usually sent when the window is focused and requires redrawing, - // but we are more interested in these events when the window is being dragged, - // blocking the main thread during the drag operation. Assume the window is being - // dragged when we have received the event more than once per cycle. - - bool result = true; - if (*dragging) - { - // Send a simulated mouse button down event, we can't tell when - // the real button down event arrives... - SDLWindow* window = SDLWindow::GetWindowFromEvent(*event); - SDL_Event mouseDownEvent{ 0 }; - mouseDownEvent.button.type = SDL_EVENT_MOUSE_BUTTON_DOWN; - mouseDownEvent.button.down = true; - mouseDownEvent.button.timestamp = SDL_GetTicksNS(); - mouseDownEvent.button.windowID = SDL_GetWindowID(window->GetSDLWindow()); - mouseDownEvent.button.button = SDL_BUTTON_LEFT; - mouseDownEvent.button.clicks = 1; - mouseDownEvent.button.x = 0;//static_cast(static_cast(WINDOWS_GET_X_LPARAM(msg->lParam))); - mouseDownEvent.button.y = 0;//static_cast(static_cast(WINDOWS_GET_Y_LPARAM(msg->lParam))); - if (window) - window->HandleEvent(*event); - - Engine::OnUpdate();//Scripting::Update(); // For docking updates - Engine::OnDraw(); - return false; - } - else - *dragging = true; - return true; - }*/ - /*else if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN && *dragging) - { - SDLWindow* window = SDLWindow::GetWindowFromEvent(*event); - if (window) - window->HandleEvent(*event); - return false; - }*/ - - /*if (dragging) - { - LOG(Info, "events during dragging: {}", event->type); // usually SDL_EVENT_WINDOW_MOVED - }*/ - return true; }; - bool suc = SDL_AddEventWatch(watch, &draggedWindow); - if (!suc) - suc = suc; + SDL_AddEventWatch(watch, &draggedWindow); SDL_PumpEvents(); SDL_Event events[32];