diff --git a/Source/Editor/GUI/Docking/WindowDragHelper.cs b/Source/Editor/GUI/Docking/WindowDragHelper.cs
index 4d41b156d..9072dfea2 100644
--- a/Source/Editor/GUI/Docking/WindowDragHelper.cs
+++ b/Source/Editor/GUI/Docking/WindowDragHelper.cs
@@ -54,7 +54,7 @@ namespace FlaxEditor.GUI.Docking
window.MouseUp += OnMouseUp;
// Update rectangles
- UpdateRects();
+ UpdateRects(Platform.MousePosition);
_dragSourceWindow = dragSourceWindow;
if (_dragSourceWindow != null) // Detaching a tab from existing window
@@ -63,13 +63,14 @@ namespace FlaxEditor.GUI.Docking
// TODO: when detaching tab in floating window (not main window), the drag source window is still main window?
var dragSourceWindowWayland = toMove.MasterPanel?.RootWindow.Window ?? Editor.Instance.Windows.MainWindow;
- window.DoDragDrop("", _dragOffset, dragSourceWindowWayland);
+ window.DoDragDrop(window.Title, _dragOffset, dragSourceWindowWayland);
_dragSourceWindow.MouseUp += OnMouseUp; // The mouse up event is sent to the source window on Windows
}
else
{
- window.DoDragDrop("", _dragOffset, window);
+ _dragOffset = window.MousePosition;
+ window.DoDragDrop(window.Title, _dragOffset, window);
}
// Ensure the dragged window stays on top of every other window
@@ -163,7 +164,7 @@ namespace FlaxEditor.GUI.Docking
/// Start dragging a floating dock panel.
///
/// Floating dock panel to move.
- /// The dock hint window object.
+ /// The window drag helper object.
public static WindowDragHelper StartDragging(FloatWindowDockPanel toMove)
{
if (toMove == null)
@@ -176,7 +177,8 @@ namespace FlaxEditor.GUI.Docking
/// Start dragging a docked panel into a floating window.
///
/// Dock window to move.
- /// The dock hint window object.
+ /// The window where dragging started from.
+ /// The window drag helper object.
public static WindowDragHelper StartDragging(DockWindow toMove, Window dragSourceWindow)
{
if (toMove == null)
@@ -235,10 +237,10 @@ namespace FlaxEditor.GUI.Docking
_dockHintDown = _dockHintUp = _dockHintLeft = _dockHintRight = _dockHintCenter = null;
}
- private void UpdateRects()
+ private void UpdateRects(Float2 mousePos)
{
// Cache mouse position
- _mouse = Platform.MousePosition;
+ _mouse = mousePos;
// Check intersection with any dock panel
DockPanel dockPanel = null;
@@ -430,6 +432,9 @@ namespace FlaxEditor.GUI.Docking
private void OnUpdate()
{
var mousePos = Platform.MousePosition;
+ if (_toMove.Window.Window.IsFocused)
+ return; // Filter out mouse updates after dragging is over in dragged window
+
if (_mouse != mousePos)
OnMouseMove(mousePos);
}
@@ -437,9 +442,9 @@ namespace FlaxEditor.GUI.Docking
private void OnMouseMove(Float2 mousePos)
{
if (_dragSourceWindow != null)
- _toMove.Window.Window.Position = mousePos - _dragOffset;
+ _toMove.Window.Window.Position = mousePos - _dragOffset; // Ignored on Wayland
- UpdateRects();
+ UpdateRects(mousePos);
}
}
}
diff --git a/Source/Engine/Platform/SDL/SDLPlatform.cpp b/Source/Engine/Platform/SDL/SDLPlatform.cpp
index 7a55ff6fb..b83598d7d 100644
--- a/Source/Engine/Platform/SDL/SDLPlatform.cpp
+++ b/Source/Engine/Platform/SDL/SDLPlatform.cpp
@@ -82,9 +82,8 @@ bool SDLPlatform::Init()
SDL_SetHint(SDL_HINT_WINDOWS_RAW_KEYBOARD, "1");
SDL_SetHint(SDL_HINT_VIDEO_WAYLAND_SCALE_TO_DISPLAY, "1");
-
-//#if PLATFORM_WINDOWS
- //if (UsesWindows() || UsesX11())
+
+ if (UsesWindows() || UsesX11())
{
// Disable SDL clipboard support
SDL_SetEventEnabled(SDL_EVENT_CLIPBOARD_UPDATE, false);
@@ -96,7 +95,6 @@ bool SDLPlatform::Init()
SDL_SetEventEnabled(SDL_EVENT_DROP_COMPLETE, false);
SDL_SetEventEnabled(SDL_EVENT_DROP_POSITION, false);
}
-//#endif
//if (InitPlatform())
// return true;
diff --git a/Source/Engine/Platform/SDL/SDLWindow.cpp b/Source/Engine/Platform/SDL/SDLWindow.cpp
index a2830107f..2e7c5d2d9 100644
--- a/Source/Engine/Platform/SDL/SDLWindow.cpp
+++ b/Source/Engine/Platform/SDL/SDLWindow.cpp
@@ -572,7 +572,7 @@ void SDLWindow::HandleEvent(SDL_Event& event)
}
return;
}
-#if true
+#if PLATFORM_LINUX
case SDL_EVENT_CLIPBOARD_UPDATE:
{
LOG(Info, "SDL_EVENT_CLIPBOARD_UPDATE");
@@ -584,45 +584,48 @@ void SDLWindow::HandleEvent(SDL_Event& event)
case SDL_EVENT_DROP_TEXT:
case SDL_EVENT_DROP_COMPLETE:
{
- //LOG(Info, "SDL_EVENT_DROP_BEGIN");
+ if (SDLPlatform::UsesWayland())
+ {
+ static Float2 dragStartPosition = Float2::Zero;
- static Float2 dragStartPosition = Float2::Zero;
+ auto dpiScale = GetDpiScale();
+ //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;
- auto dpiScale = GetDpiScale();
- //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;
+ SDLDropTextData dropData;
- if (event.type == SDL_EVENT_DROP_BEGIN)
- {
- dragStartPosition = Platform::GetMousePosition();
- OnDragEnter(&dropData, mousePos, effect);
+ if (event.type == SDL_EVENT_DROP_BEGIN)
+ {
+ dragStartPosition = GetPosition();//Platform::GetMousePosition();
+ LOG(Info, "SDL_EVENT_DROP_BEGIN: {}, mousepos: {}", dragStartPosition, mousePos);
+ OnDragEnter(&dropData, mousePos, effect);
+ }
+ else if (event.type == SDL_EVENT_DROP_POSITION)
+ {
+ LOG(Info, "SDL_EVENT_DROP_POSITION: {}", mousePos);
+ 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);
+ mousePosition = ScreenToClient(mousePosition);
+
+ DragDropEffect effect;
+ SDLDropTextData dropData;
+ OnDragEnter(&dropData, mousePosition, effect);
+ OnDragOver(&dropData, mousePosition, 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);
- mousePosition = ScreenToClient(mousePosition);
-
- DragDropEffect effect;
- SDLDropTextData dropData;
- OnDragEnter(&dropData, mousePosition, effect);
- OnDragOver(&dropData, mousePosition, effect);*/
break;
}
/*case SDL_EVENT_DROP_POSITION: