_wayland dragging completed
This commit is contained in:
@@ -25,7 +25,7 @@ namespace FlaxEditor.GUI.Docking
|
||||
|
||||
private Rectangle _rLeft, _rRight, _rBottom, _rUpper, _rCenter;
|
||||
|
||||
private DockHintWindow(FloatWindowDockPanel toMove, bool lateDragStart)
|
||||
private DockHintWindow(FloatWindowDockPanel toMove, bool draggingTab)
|
||||
{
|
||||
_toMove = toMove;
|
||||
_toSet = DockState.Float;
|
||||
@@ -47,11 +47,7 @@ namespace FlaxEditor.GUI.Docking
|
||||
window.Restore();
|
||||
window.Position = Platform.MousePosition - mousePos * window.Size / previousSize;
|
||||
}
|
||||
|
||||
// Calculate dragging offset and move window to the destination position
|
||||
var mouseClientPosition = Platform.MousePosition;
|
||||
CalculateDragOffset(mouseClientPosition);
|
||||
|
||||
|
||||
// If the _toMove window was not focused when initializing this window, the result vector only contains zeros
|
||||
// and to prevent a failure, we need to perform an update for the drag offset at later time which will be done in the OnMouseMove event handler.
|
||||
//if (mouseScreenPosition != Float2.Zero)
|
||||
@@ -95,15 +91,20 @@ namespace FlaxEditor.GUI.Docking
|
||||
|
||||
// window.Show();
|
||||
|
||||
if (lateDragStart)
|
||||
if (draggingTab)
|
||||
{
|
||||
// The window needs some time to be fully ready for dragging
|
||||
//_lateDragStartTimer = 1.5f;
|
||||
window.StartDragging(_dragOffset);
|
||||
_dragOffset = new Float2(window.Size.X / 2, 10.0f);
|
||||
|
||||
window.StartDragging(_dragOffset, toMove.MasterPanel?.RootWindow.Window ?? Editor.Instance.Windows.MainWindow);
|
||||
}
|
||||
else
|
||||
window.StartDragging(_dragOffset);
|
||||
|
||||
{
|
||||
var mouseClientPosition = Platform.MousePosition;
|
||||
CalculateDragOffset(mouseClientPosition);
|
||||
|
||||
window.StartDragging(_dragOffset, window);
|
||||
}
|
||||
|
||||
//window.Show();
|
||||
//window.BringToFront();
|
||||
//window.Focus();
|
||||
@@ -520,12 +521,6 @@ namespace FlaxEditor.GUI.Docking
|
||||
private void OnUpdate()
|
||||
{
|
||||
//Editor.Log("OnUpdate");
|
||||
if (_lateDragStartTimer > 0)
|
||||
{
|
||||
_lateDragStartTimer -= Time.UnscaledDeltaTime;
|
||||
if (_lateDragStartTimer <= 0)
|
||||
_toMove.Window.Window.StartDragging(_dragOffset);
|
||||
}
|
||||
var mousePos = Platform.MousePosition;
|
||||
if (_mouse != mousePos)
|
||||
{
|
||||
|
||||
@@ -51,9 +51,9 @@ namespace FlaxEditor.GUI.Docking
|
||||
if (_window == null)
|
||||
return;
|
||||
|
||||
_window.Window.StartDragging(Float2.Zero);
|
||||
// Create docking hint window
|
||||
//DockHintWindow.Create(this);
|
||||
DockHintWindow.Create(this);
|
||||
//_window.Window.StartDragging(Float2.Zero);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1017,7 +1017,7 @@ namespace FlaxEditor.Modules
|
||||
if (_lastLayoutSaveTime.Ticks > 10 && now - _lastLayoutSaveTime >= TimeSpan.FromSeconds(10))
|
||||
{
|
||||
Profiler.BeginEvent("Save Layout");
|
||||
SaveCurrentLayout();
|
||||
//SaveCurrentLayout();
|
||||
Profiler.EndEvent();
|
||||
}
|
||||
|
||||
|
||||
@@ -741,7 +741,8 @@ public:
|
||||
/// Start dragging the window.
|
||||
/// </summary>
|
||||
/// <param name="offset">The position offset for drag from top-left corner.</param>
|
||||
API_FUNCTION() virtual void StartDragging(const Float2& offset)
|
||||
/// <param name="dragSourceWindow">The source window where the dragging is started from. For attached tabs, this is the parent window</param>
|
||||
API_FUNCTION() virtual void StartDragging(const Float2& offset, Window* dragSourceWindow)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -578,7 +578,8 @@ public:
|
||||
int64 ExitFlag = 0;
|
||||
StringView data;
|
||||
SDLWindow* window;
|
||||
SDLWindow* mainwindow;
|
||||
SDLWindow* dragSourceWindow;
|
||||
Float2 dragOffset = Float2::Zero;
|
||||
int64 dragOver = 0;
|
||||
int64 waitFlag = 0;
|
||||
|
||||
@@ -616,7 +617,7 @@ public:
|
||||
/*auto */dataDevice = wl_data_device_manager_get_data_device(wrappedManager, WaylandSeat);
|
||||
wl_data_device_add_listener(dataDevice, &WaylandDataDeviceListener, nullptr);
|
||||
wl_display_roundtrip(wrappedDisplay);
|
||||
wl_data_device_set_user_data(dataDevice, dragWindow ? mainwindow : window);
|
||||
wl_data_device_set_user_data(dataDevice, dragWindow ? dragSourceWindow : window);
|
||||
wrappedDataDevice = (wl_data_device*)wl_proxy_create_wrapper(dataDevice);
|
||||
wl_proxy_set_queue((wl_proxy*)wrappedDataDevice, WaylandQueue);
|
||||
}
|
||||
@@ -643,7 +644,7 @@ public:
|
||||
textData.Window = window;
|
||||
textData.dragOver = &dragOver;
|
||||
auto _window = window->GetSDLWindow();
|
||||
auto _mainwindow = mainwindow->GetSDLWindow();
|
||||
auto _mainwindow = dragSourceWindow->GetSDLWindow();
|
||||
//if (!window->IsVisible())
|
||||
// _window = mainwindow->GetSDLWindow();
|
||||
//wl_data_source_set_user_data(wrappedDataSource, &textData);
|
||||
@@ -679,8 +680,7 @@ public:
|
||||
wl_proxy_set_queue((wl_proxy*)wrappedToplevel, WaylandQueue);
|
||||
toplevelDrag = xdg_toplevel_drag_manager_v1_get_xdg_toplevel_drag(DragManager, dataSource);
|
||||
|
||||
Float2 offset(100, 240);
|
||||
Float2 scaledOffset = offset / window->GetDpiScale();
|
||||
Float2 scaledOffset = dragOffset / window->GetDpiScale();
|
||||
//xdg_toplevel_drag_v1_attach(toplevelDrag, toplevel, (int32)scaledOffset.X, (int32)scaledOffset.Y);
|
||||
|
||||
xdg_toplevel_drag_v1_attach(toplevelDrag, wrappedToplevel, (int32)scaledOffset.X, (int32)scaledOffset.Y);
|
||||
@@ -745,8 +745,7 @@ public:
|
||||
wl_proxy_set_queue((wl_proxy*)wrappedToplevel, WaylandQueue);
|
||||
toplevelDrag = xdg_toplevel_drag_manager_v1_get_xdg_toplevel_drag(DragManager, dataSource);
|
||||
|
||||
Float2 offset(100, 240);
|
||||
Float2 scaledOffset = offset / window->GetDpiScale();
|
||||
Float2 scaledOffset = dragOffset / window->GetDpiScale();
|
||||
//xdg_toplevel_drag_v1_attach(toplevelDrag, toplevel, (int32)scaledOffset.X, (int32)scaledOffset.Y);
|
||||
|
||||
xdg_toplevel_drag_v1_attach(toplevelDrag, wrappedToplevel, (int32)scaledOffset.X, (int32)scaledOffset.Y);
|
||||
@@ -811,7 +810,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
DragDropEffect Window::DoDragDropWayland(const StringView& data)
|
||||
DragDropEffect Window::DoDragDropWayland(const StringView& data, Window* dragSourceWindow, Float2 dragOffset)
|
||||
{
|
||||
// For drag-and-drop, we need to setup the event queue in separate thread to avoid racing issues
|
||||
// while SDL is dispatching the main Wayland event queue when receiving the data offer from us.
|
||||
@@ -854,8 +853,9 @@ DragDropEffect Window::DoDragDropWayland(const StringView& data)
|
||||
auto task = New<WaylandDragDropJob>();
|
||||
task->data = data;
|
||||
task->window = this;
|
||||
task->mainwindow = Engine::MainWindow;
|
||||
task->dragSourceWindow = dragSourceWindow; // Needs to be the parent window when dragging a tab to window
|
||||
task->dragOver = 0;
|
||||
task->dragOffset = dragOffset;
|
||||
Task::StartNew(task);
|
||||
while (task->GetState() == TaskState::Queued)
|
||||
Platform::Sleep(1);
|
||||
@@ -872,8 +872,8 @@ DragDropEffect Window::DoDragDropWayland(const StringView& data)
|
||||
while (Platform::AtomicRead(&task->dragOver) == 0)
|
||||
{
|
||||
SDLPlatform::Tick();
|
||||
//Scripting::Update(); // For docking updates
|
||||
//Engine::OnDraw();
|
||||
Engine::OnUpdate();//Scripting::Update(); // For docking updates
|
||||
Engine::OnDraw();
|
||||
|
||||
Platform::Sleep(1);
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ SDLWindow::SDLWindow(const CreateWindowSettings& settings)
|
||||
flags |= SDL_WINDOW_RESIZABLE;
|
||||
if (_settings.IsTopmost)
|
||||
flags |= SDL_WINDOW_ALWAYS_ON_TOP;
|
||||
if (_settings.SupportsTransparency)
|
||||
//if (_settings.SupportsTransparency)
|
||||
flags |= SDL_WINDOW_TRANSPARENT;
|
||||
|
||||
// Disable parenting of child windows as those are always on top of the parent window and never show up in taskbar
|
||||
@@ -406,7 +406,7 @@ SDLWindow* SDLWindow::GetWindowWithSDLWindow(SDL_Window* window)
|
||||
|
||||
void SDLWindow::HandleEvent(SDL_Event& event)
|
||||
{
|
||||
if (_isClosing || waylandDraggingActive)
|
||||
if (_isClosing)
|
||||
return;
|
||||
|
||||
switch (event.type)
|
||||
@@ -792,10 +792,10 @@ void SDLWindow::Show()
|
||||
}
|
||||
|
||||
SDL_ShowWindow(_window);
|
||||
/*if (_settings.AllowInput && _settings.ActivateWhenFirstShown)
|
||||
if (_settings.AllowInput && _settings.ActivateWhenFirstShown)
|
||||
Focus();
|
||||
else if (_settings.Parent == nullptr)
|
||||
BringToFront();*/
|
||||
BringToFront();
|
||||
|
||||
// Reused top-most windows (DockHintWindow) doesn't stay on top for some reason
|
||||
if (_settings.IsTopmost && _settings.Type != WindowType::Tooltip)
|
||||
@@ -1108,7 +1108,7 @@ String SDLWindow::GetTitle() const
|
||||
|
||||
void SDLWindow::SetTitle(const StringView& title)
|
||||
{
|
||||
//SDL_SetWindowTitle(_window, title.ToStringAnsi().Get());
|
||||
SDL_SetWindowTitle(_window, title.ToStringAnsi().Get());
|
||||
}
|
||||
|
||||
void SDLWindow::StartTrackingMouse(bool useMouseScreenOffset)
|
||||
@@ -1299,11 +1299,26 @@ void SDLWindow::UpdateCursor()
|
||||
wl_display_flush((wl_display*)SDL_GetPointerProperty(SDL_GetGlobalProperties(), SDL_PROP_GLOBAL_VIDEO_WAYLAND_WL_DISPLAY_POINTER, nullptr));
|
||||
}*/
|
||||
|
||||
void SDLWindow::StartDragging(const Float2& offset)
|
||||
void SDLWindow::StartDragging(const Float2& offset, Window* dragSourceWindow)
|
||||
{
|
||||
LOG(Info, "StartDragging {}", offset);
|
||||
|
||||
DoDragDropWayland(String("notawindow"));
|
||||
Float2 dragOffset = offset;
|
||||
if (_settings.HasBorder)
|
||||
{
|
||||
#if PLATFORM_LINUX
|
||||
if (SDLPlatform::UsesWayland() && dragSourceWindow == this)
|
||||
{
|
||||
// Wayland includes the decorations in the client-space coordinates, adjust the offset for it.
|
||||
// Assume the title decoration is 25px thick...
|
||||
float topOffset = 25.0f;
|
||||
dragOffset += Float2(0.0f, topOffset);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
SetOpacity(0.1f);
|
||||
DoDragDropWayland(String("notawindow"), dragSourceWindow, dragOffset);
|
||||
/*
|
||||
_dragOver = true;
|
||||
|
||||
@@ -1339,6 +1354,8 @@ void SDLWindow::StartDragging(const Float2& offset)
|
||||
void SDLWindow::StopDragging()
|
||||
{
|
||||
LOG(Info, "StopDragging");
|
||||
|
||||
SetOpacity(1.0f);
|
||||
/*
|
||||
wl_data_device_set_user_data(dataDevice, nullptr);
|
||||
_dragOver = false;
|
||||
|
||||
@@ -62,7 +62,7 @@ private:
|
||||
void UpdateCursor();
|
||||
|
||||
#if PLATFORM_LINUX
|
||||
DragDropEffect DoDragDropWayland(const StringView& data);
|
||||
DragDropEffect DoDragDropWayland(const StringView& data, Window* dragSourceWindow = nullptr, Float2 dragOffset = Float2::Zero);
|
||||
DragDropEffect DoDragDropX11(const StringView& data);
|
||||
#endif
|
||||
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
void StartClippingCursor(const Rectangle& bounds) override;
|
||||
void EndClippingCursor() override;
|
||||
void SetCursor(CursorType type) override;
|
||||
void StartDragging(const Float2& offset) override;
|
||||
void StartDragging(const Float2& offset, Window* dragSourceWindow) override;
|
||||
void StopDragging() override;
|
||||
|
||||
#if USE_EDITOR && PLATFORM_WINDOWS
|
||||
|
||||
Reference in New Issue
Block a user