_drag release offset investigation
Some checks failed
Build Android / Game (Android, Release ARM64) (push) Has been cancelled
Build iOS / Game (iOS, Release ARM64) (push) Has been cancelled
Build Linux / Editor (Linux, Development x64) (push) Has been cancelled
Build Linux / Game (Linux, Release x64) (push) Has been cancelled
Build macOS / Editor (Mac, Development ARM64) (push) Has been cancelled
Build macOS / Game (Mac, Release ARM64) (push) Has been cancelled
Build Windows / Editor (Windows, Development x64) (push) Has been cancelled
Build Windows / Game (Windows, Release x64) (push) Has been cancelled
Cooker / Cook (Mac) (push) Has been cancelled
Tests / Tests (Linux) (push) Has been cancelled
Tests / Tests (Windows) (push) Has been cancelled

This commit is contained in:
2025-01-12 22:15:38 +02:00
parent 1b9c9436bc
commit ed4d5a5397
4 changed files with 54 additions and 40 deletions

View File

@@ -342,7 +342,7 @@ namespace FlaxEditor.GUI.Docking
if (dockPanel != _toDock)
{
//Editor.Log($"UpdateRects: {_mouse}, panel: {dockPanel?.RootWindow?.Window?.Title}");
Editor.Log($"UpdateRects: {_mouse}, panel: {dockPanel?.RootWindow?.Window?.Title}");
_toDock?.RootWindow.Window.RemoveDockHints();
RemoveDockHints();
@@ -422,8 +422,8 @@ namespace FlaxEditor.GUI.Docking
hoveredSizeOverride = new Float2(size.X, size.Y);
}
if (toSet != DockState.Float)
Editor.Log($"docking: {toSet}");
//if (toSet != DockState.Float)
_toSet = toSet;
}
@@ -431,6 +431,8 @@ namespace FlaxEditor.GUI.Docking
{
_toSet = DockState.Float;
}
Editor.Log($"docking: {_toSet}, pos: {_mouse}");
// Calculate proxy/dock/window rectangles
if (_toDock == null)
@@ -524,6 +526,7 @@ namespace FlaxEditor.GUI.Docking
var mousePos = Platform.MousePosition;
if (_mouse != mousePos)
{
Editor.Log($"mouse pos {_mouse} -> {mousePos}");
OnMouseMove(mousePos);
}
}

View File

@@ -1,5 +1,6 @@
// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
#include "Engine/Engine/Engine.h"
#if PLATFORM_SDL
#include "SDLInput.h"
@@ -496,14 +497,17 @@ bool SDLInput::HandleEvent(SDLWindow* window, SDL_Event& event)
}
return true;
}
case SDL_EVENT_DROP_POSITION:
/*case SDL_EVENT_DROP_POSITION:
{
// We are not receiving mouse motion events during drag-and-drop
auto dpiScale = window->GetDpiScale();
const Float2 mousePos = window->ClientToScreen({ event.drop.x * dpiScale, event.drop.y * dpiScale});
//const Float2 mousePos(event.drop.x * dpiScale, event.drop.y * dpiScale);// = window->ClientToScreen({ event.drop.x * dpiScale, event.drop.y * dpiScale});
Float2 mousePos = window->ClientToScreen({ event.drop.x * dpiScale, event.drop.y * dpiScale});
if (window != Engine::MainWindow)
mousePos = window->GetPosition() - mousePos;
Input::Mouse->OnMouseMove(mousePos, window);
return true;
}
}*/
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
{
Input::Mouse->OnMouseLeave(window);

View File

@@ -499,8 +499,8 @@ void WaylandDataSource_Cancelled(void* data, wl_data_source *source)
wl_data_source_destroy(source);
// The mouse up event was ignored earlier, release the button now
SDLWindow* window = ((LinuxDropTextData*)inputData)->Window;
Input::Mouse->OnMouseUp(Platform::GetMousePosition(), MouseButton::Left, window);
//SDLWindow* window = ((LinuxDropTextData*)inputData)->Window;
//Input::Mouse->OnMouseUp(Platform::GetMousePosition(), MouseButton::Left, window);
/*if (DragTargetWindow != nullptr)
{
@@ -517,7 +517,7 @@ void WaylandDataSource_DnDDropPerformed(void *data,
{
// The destination is being asked to begin DnD, asking confirmation with ASK actionh
//SDLWindow* window = static_cast<SDLWindow*>(data);
//LOG(Info, "WaylandDataSource_DnDDropPerformed");
LOG(Info, "WaylandDataSource_DnDDropPerformed");
}
void WaylandDataSource_DnDFinished(void *data,
@@ -533,8 +533,8 @@ void WaylandDataSource_DnDFinished(void *data,
wl_data_source_destroy(wl_data_source);
// The mouse up event was ignored earlier, release the button now
SDLWindow* window = ((LinuxDropTextData*)inputData)->Window;
Input::Mouse->OnMouseUp(Platform::GetMousePosition(), MouseButton::Left, window);
//SDLWindow* window = ((LinuxDropTextData*)inputData)->Window;
//Input::Mouse->OnMouseUp(Platform::GetMousePosition(), MouseButton::Left, window);
/*if (DragTargetWindow != nullptr)
{
@@ -886,6 +886,9 @@ DragDropEffect Window::DoDragDropWayland(const StringView& data, Window* dragSou
}
}
// The mouse up event was ignored earlier, release the button now
Input::Mouse->OnMouseUp(Platform::GetMousePosition(), MouseButton::Left, this);
Platform::AtomicStore(&task->ExitFlag, 1);
task->Wait();

View File

@@ -640,16 +640,41 @@ void SDLWindow::HandleEvent(SDL_Event& event)
return;
}
case SDL_EVENT_DROP_BEGIN:
case SDL_EVENT_DROP_POSITION:
case SDL_EVENT_DROP_FILE:
case SDL_EVENT_DROP_TEXT:
case SDL_EVENT_DROP_COMPLETE:
{
LOG(Info, "SDL_EVENT_DROP_BEGIN");
//LOG(Info, "SDL_EVENT_DROP_BEGIN");
static Float2 dragStartPosition = Float2::Zero;
auto dpiScale = GetDpiScale();
const Float2 mousePos = ClientToScreen({ event.drop.x * dpiScale, event.drop.y * dpiScale});
//const Float2 mousePos = ClientToScreen({ event.drop.x * dpiScale, event.drop.y * dpiScale});
const Float2 mousePos = dragStartPosition + Float2(event.drop.x * dpiScale, event.drop.y * dpiScale);
DragDropEffect effect = DragDropEffect::None;
auto daata = event.drop.data;
SDLDropTextData dropData;
OnDragEnter(&dropData, mousePos, effect);
if (event.type == SDL_EVENT_DROP_BEGIN)
{
dragStartPosition = Platform::GetMousePosition();
OnDragEnter(&dropData, mousePos, effect);
}
else if (event.type == SDL_EVENT_DROP_POSITION)
{
Input::Mouse->OnMouseMove(mousePos, this);
OnDragOver(&dropData, mousePos, effect);
}
else if (event.type == SDL_EVENT_DROP_FILE)
OnDragDrop(&dropData, mousePos, effect);
else if (event.type == SDL_EVENT_DROP_TEXT)
OnDragDrop(&dropData, mousePos, effect);
else if (event.type == SDL_EVENT_DROP_COMPLETE)
OnDragLeave();
/*Focus();
Float2 mousePosition;
SDL_GetGlobalMouseState(&mousePosition.X, &mousePosition.Y);
@@ -659,21 +684,19 @@ void SDLWindow::HandleEvent(SDL_Event& event)
SDLDropTextData dropData;
OnDragEnter(&dropData, mousePosition, effect);
OnDragOver(&dropData, mousePosition, effect);*/
return;
break;
}
case SDL_EVENT_DROP_POSITION:
/*case SDL_EVENT_DROP_POSITION:
{
auto dpiScale = GetDpiScale();
const Float2 mousePos = ClientToScreen({ event.drop.x * dpiScale, event.drop.y * dpiScale});
//const Float2 mousePos = ClientToScreen({ event.drop.x * dpiScale, event.drop.y * dpiScale});
const Float2 mousePos(event.drop.x * dpiScale, event.drop.y * dpiScale);
DragDropEffect effect = DragDropEffect::None;
auto daata = event.drop.data;
SDLDropTextData dropData;
OnDragOver(&dropData, mousePos, effect);
/*DragDropEffect effect = DragDropEffect::None;
SDLDropTextData dropData;
OnDragOver(&dropData, Float2(static_cast<float>(event.drop.x), static_cast<float>(event.drop.y)), effect);*/
break;
}
case SDL_EVENT_DROP_FILE:
@@ -688,16 +711,7 @@ void SDLWindow::HandleEvent(SDL_Event& event)
OnDragDrop(&dropData, mousePos, effect);
/*SDLDropFilesData dropData;
dropData.Files.Add(StringAnsi(event.drop.data).ToString()); // TODO: collect multiple files at once?
Focus();
Float2 mousePosition;
SDL_GetGlobalMouseState(&mousePosition.X, &mousePosition.Y);
mousePosition = ScreenToClient(mousePosition);
DragDropEffect effect = DragDropEffect::None;
OnDragDrop(&dropData, mousePosition, effect);*/
return;
}
case SDL_EVENT_DROP_TEXT:
@@ -713,16 +727,6 @@ void SDLWindow::HandleEvent(SDL_Event& event)
SDLDropTextData dropData;
OnDragDrop(&dropData, mousePos, effect);
/*SDLDropTextData dropData;
String str = StringAnsi(event.drop.data).ToString();
dropData.Text = StringView(str);
Focus();
Float2 mousePosition;
SDL_GetGlobalMouseState(&mousePosition.X, &mousePosition.Y);
mousePosition = ScreenToClient(mousePosition);
DragDropEffect effect = DragDropEffect::None;
OnDragDrop(&dropData, mousePosition, effect);*/
return;
}
case SDL_EVENT_DROP_COMPLETE:
@@ -740,7 +744,7 @@ void SDLWindow::HandleEvent(SDL_Event& event)
//_dragOver = false;
}
return;
}
}*/
#endif
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
{