_wayland temp investigate
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-10 11:28:22 +02:00
parent 2fc6e95ec3
commit 387eb90576
12 changed files with 122 additions and 77 deletions

View File

@@ -29,7 +29,7 @@ namespace FlaxEditor.GUI.Docking
{
_toMove = toMove;
_toSet = DockState.Float;
var window = toMove.Window.Window;
var window = _toMove?.Window.Window ?? Editor.Instance.Windows.MainWindow;
// Remove focus from drag target
//_toMove.Focus();
@@ -62,7 +62,7 @@ namespace FlaxEditor.GUI.Docking
// Get initial size
_defaultWindowSize = window.Size;
//_defaultWindowSize = window.Size;
// Init proxy window
/*Proxy.Init(ref _defaultWindowSize);
@@ -72,7 +72,7 @@ namespace FlaxEditor.GUI.Docking
//FlaxEngine.Input.MouseMove += OnMouseMove;
FlaxEngine.Scripting.Update += OnUpdate;
_toMove.Window.Window.MouseUp += OnMouseUp;
window.MouseUp += OnMouseUp;
/*
Proxy.Window.MouseUp += OnMouseUp;
Proxy.Window.MouseMove += OnMouseMove;
@@ -92,8 +92,9 @@ namespace FlaxEditor.GUI.Docking
// Hide base window
//window.Hide();
window.Show();
if (lateDragStart)
{
// The window needs some time to be fully ready for dragging
@@ -102,7 +103,9 @@ namespace FlaxEditor.GUI.Docking
}
else
window.StartDragging(_dragOffset);
Dispose();
//window.Show();
//window.BringToFront();
//window.Focus();
@@ -110,8 +113,8 @@ namespace FlaxEditor.GUI.Docking
// Perform layout again
//windowGUI.PerformLayout();
// Start tracking mouse
//Proxy.Window.StartTrackingMouse(false);
}
@@ -140,9 +143,9 @@ namespace FlaxEditor.GUI.Docking
RemoveDockHints();
//FlaxEngine.Input.MouseMove -= OnMouseMove;
var window = _toMove?.Window?.Window ?? Editor.Instance.Windows.MainWindow;
FlaxEngine.Scripting.Update -= OnUpdate;
if (_toMove?.Window?.Window)
_toMove.Window.Window.MouseUp -= OnMouseUp;
window.MouseUp -= OnMouseUp;
if (_toMove == null)
return;
@@ -152,7 +155,6 @@ namespace FlaxEditor.GUI.Docking
// Check if window won't be docked
if (_toSet == DockState.Float)
{
var window = _toMove.Window?.Window;
if (window == null)
return;
var mouse = Platform.MousePosition;
@@ -242,7 +244,7 @@ namespace FlaxEditor.GUI.Docking
window.Window.Position = mouse - new Float2(8, 8);*/
// Get floating panel
var floatingPanelToMove = window.GetChild(0) as FloatWindowDockPanel;
var floatingPanelToMove = window?.GetChild(0) as FloatWindowDockPanel;
return new DockHintWindow(floatingPanelToMove, true);
}
@@ -282,7 +284,7 @@ namespace FlaxEditor.GUI.Docking
private void CalculateDragOffset(Float2 mouseScreenPosition)
{
var baseWinPos = _toMove.Window.Window.Position;
var baseWinPos = _toMove?.Window.Window.Position ?? Editor.Instance.Windows.MainWindow.Position;
_dragOffset = mouseScreenPosition - baseWinPos;
Editor.Log($"_dragOffset: {_dragOffset}, mouse: {mouseScreenPosition}, basewinpos: {baseWinPos}");
@@ -334,6 +336,9 @@ namespace FlaxEditor.GUI.Docking
// Cache mouse position
_mouse = Platform.MousePosition;
if (_toMove == null)
return;
// Check intersection with any dock panel
var uiMouse = _mouse;
var dockPanel = _toMove.MasterPanel.HitTest(ref uiMouse, _toMove);

View File

@@ -280,16 +280,49 @@ namespace FlaxEditor.GUI.Docking
_selectedTab = tab;
if (_selectedTab != null)
{
_selectedTab.UnlockChildrenRecursive();
//_selectedTab.UnlockChildrenRecursive();
_selectedTab.Parent = proxy;
if (autoFocus)
_selectedTab.Focus();
//if (autoFocus)
// _selectedTab.Focus();
}
OnSelectedTabChanged();
//OnSelectedTabChanged();
}
else if (autoFocus && _selectedTab != null && !_selectedTab.ContainsFocus)
{
_selectedTab.Focus();
//_selectedTab.Focus();
}
}
public void SelectTab2(DockWindow tab, bool autoFocus = true)
{
// Check if tab will change
if (_selectedTab != tab)
{
// Change
ContainerControl proxy;
if (_selectedTab != null)
{
proxy = _selectedTab.Parent;
_selectedTab.Parent = null;
}
else
{
CreateTabsProxy();
proxy = _tabsProxy;
}
_selectedTab = tab;
if (_selectedTab != null)
{
//_selectedTab.UnlockChildrenRecursive();
_selectedTab.Parent = proxy;
//if (autoFocus)
// _selectedTab.Focus();
}
//OnSelectedTabChanged();
}
else if (autoFocus && _selectedTab != null && !_selectedTab.ContainsFocus)
{
//_selectedTab.Focus();
}
}
@@ -601,7 +634,7 @@ namespace FlaxEditor.GUI.Docking
_tabs.Add(window);
window.ParentDockPanel = this;
if (autoSelect)
SelectTab(window);
SelectTab2(window);
}
private void CreateTabsProxy()

View File

@@ -185,19 +185,21 @@ namespace FlaxEditor.GUI.Docking
{
Undock();
// Create window
var winSize = size.LengthSquared > 4 ? size : DefaultSize;
var window = FloatWindowDockPanel.CreateFloatWindow(_masterPanel.Root, location, winSize, position, _title);
var windowGUI = window.GUI;
// Create dock panel for the window
var dockPanel = new FloatWindowDockPanel(_masterPanel, windowGUI);
dockPanel.DockWindowInternal(DockState.DockFill, this);
dockPanel.DockWindowInternal(DockState.DockFill, this, true);
/*
// Perform layout
Visible = true;
windowGUI.UnlockChildrenRecursive();
windowGUI.PerformLayout();
*/
// Show
/*FlaxEngine.Scripting.InvokeOnUpdate(() =>
@@ -465,10 +467,10 @@ namespace FlaxEditor.GUI.Docking
/// <inheritdoc />
public override void Focus()
{
base.Focus();
/*base.Focus();
SelectTab();
BringToFront();
BringToFront();*/
}
/// <inheritdoc />

View File

@@ -1017,7 +1017,7 @@ namespace FlaxEditor.Modules
if (_lastLayoutSaveTime.Ticks > 10 && now - _lastLayoutSaveTime >= TimeSpan.FromSeconds(10))
{
Profiler.BeginEvent("Save Layout");
SaveCurrentLayout();
//SaveCurrentLayout();
Profiler.EndEvent();
}

View File

@@ -576,14 +576,14 @@ public:
int64 ExitFlag = 0;
StringView data;
SDLWindow* window;
SDLWindow* mainwindow;
int64 dragOver = 0;
int64 waitFlag = 0;
// [ThreadPoolTask]
bool Run() override
{
Scripting::GetScriptsDomain()->Dispatch();
bool dragWindow = data == String("notawindow");
wl_display* wrappedDisplay = WaylandDisplay;//(wl_display*)wl_proxy_create_wrapper(WaylandDisplay);
//wl_proxy_set_queue((wl_proxy*)wrappedDisplay, queue);
@@ -614,7 +614,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, window);
wl_data_device_set_user_data(dataDevice, dragWindow ? mainwindow : window);
wrappedDataDevice = (wl_data_device*)wl_proxy_create_wrapper(dataDevice);
wl_proxy_set_queue((wl_proxy*)wrappedDataDevice, WaylandQueue);
}
@@ -623,7 +623,7 @@ public:
dataSource = wl_data_device_manager_create_data_source(wrappedManager);
wrappedDataSource = (wl_data_source*)wl_proxy_create_wrapper(dataSource);
wl_proxy_set_queue((wl_proxy*)wrappedDataSource, WaylandQueue);
if (data == String("awindow"))
if (dragWindow)
{
wl_data_source_offer(dataSource, "flaxengine/window");
wl_data_source_offer(dataSource, "text/plain;charset=utf-8"); // TODO: needs support for custom mime-types in SDL
@@ -641,6 +641,9 @@ public:
textData.Window = window;
textData.dragOver = &dragOver;
auto _window = window->GetSDLWindow();
auto _mainwindow = mainwindow->GetSDLWindow();
//if (!window->IsVisible())
// _window = mainwindow->GetSDLWindow();
//wl_data_source_set_user_data(wrappedDataSource, &textData);
wl_data_source_add_listener(dataSource, &WaylandDataSourceListener, &textData);
@@ -660,13 +663,13 @@ public:
xdg_toplevel* wrappedToplevel = nullptr;
{
wl_surface* origin = (wl_surface*)SDL_GetPointerProperty(SDL_GetWindowProperties(_window), SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER, nullptr);
wl_surface* origin = (wl_surface*)SDL_GetPointerProperty(SDL_GetWindowProperties(_mainwindow), SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER, nullptr);
wl_surface* icon = nullptr;
uint32 id = ImplicitGrabSerial;
//id = (uint32)SDL_GetNumberProperty(SDL_GetGlobalProperties(), "wayland.serial", 0);
wl_data_device_start_drag((wl_data_device*)SDL_GetPointerProperty(SDL_GetGlobalProperties(), "wayland.data_device", wrappedDataDevice), dataSource, origin, icon, id);
if (data == String("awindow"))
if (dragWindow)
{
if (toplevel != nullptr)
{
@@ -729,7 +732,7 @@ public:
if (wl_display_roundtrip_queue(wrappedDisplay, WaylandQueue) == -1)
LOG(Warning, "err wl_display_roundtrip_queue: {}", errno);
if (toplevel == nullptr && data == String("awindow"))
if (toplevel == nullptr && dragWindow)
{
if (Platform::AtomicRead(&waitFlag) != 0)
{
@@ -816,6 +819,7 @@ DragDropEffect Window::DoDragDropWayland(const StringView& data)
auto task = New<WaylandDragDropJob>();
task->data = data;
task->window = this;
task->mainwindow = Engine::MainWindow;
task->dragOver = 0;
Task::StartNew(task);
while (task->GetState() == TaskState::Queued)
@@ -826,15 +830,15 @@ DragDropEffect Window::DoDragDropWayland(const StringView& data)
Platform::Sleep(1);
}
Show();
//Show();
//Focus();
int counter = 100;
while (Platform::AtomicRead(&task->dragOver) == 0)
{
SDLPlatform::Tick();
Engine::OnUpdate(); // For docking updates
Engine::OnDraw();
//Scripting::Update(); // For docking updates
//Engine::OnDraw();
Platform::Sleep(1);
@@ -1720,7 +1724,7 @@ void WaylandRegistryGlobal(void* data, wl_registry *registry, uint32 id, const c
StringAnsi interfaceStr(interface);
//LOG(Info, "WaylandRegistryGlobal id: {}, interface: {}", id, String(interface));
if (interfaceStr == "xdg_toplevel_drag_manager_v1")
DragManager = (xdg_toplevel_drag_manager_v1*)wl_registry_bind(registry, id, &xdg_toplevel_drag_manager_v1_interface, 1U);
DragManager = (xdg_toplevel_drag_manager_v1*)wl_registry_bind(registry, id, &xdg_toplevel_drag_manager_v1_interface, Math::Min(1U, version));
else if (interfaceStr == "wl_seat")
{
WaylandSeat = (wl_seat*)wl_registry_bind(registry, id, &wl_seat_interface, Math::Min(9U, version));

View File

@@ -175,7 +175,7 @@ void SDLPlatform::Tick()
}
else
{
#if PLATFORM_LINUX
/*#if PLATFORM_LINUX
String dockHintWindow("DockHint.Window");
Window* window = nullptr;
WindowsManager::WindowsLocker.Lock();
@@ -197,7 +197,7 @@ void SDLPlatform::Tick()
mousePos += Float2(static_cast<float>(left), static_cast<float>(-top));
Input::Mouse->OnMouseMove(mousePos, window);
}
#endif
#endif*/
}
}

View File

@@ -144,8 +144,8 @@ SDLWindow::SDLWindow(const CreateWindowSettings& settings)
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
//if (_settings.Parent != nullptr && (_settings.Type != WindowType::Tooltip && _settings.Type != WindowType::Popup))
// _settings.Parent = nullptr;
if (_settings.Parent != nullptr && (_settings.Type != WindowType::Tooltip && _settings.Type != WindowType::Popup))
_settings.Parent = nullptr;
if (_settings.Parent != nullptr && _settings.Parent->_settings.Type != WindowType::Regular && (_settings.Type == WindowType::Tooltip || _settings.Type == WindowType::Popup))
{
@@ -406,7 +406,7 @@ SDLWindow* SDLWindow::GetWindowWithSDLWindow(SDL_Window* window)
void SDLWindow::HandleEvent(SDL_Event& event)
{
if (_isClosing)
if (_isClosing || waylandDraggingActive)
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)
@@ -925,10 +925,10 @@ bool SDLWindow::IsForegroundWindow() const
void SDLWindow::BringToFront(bool force)
{
auto activateWhenRaised = SDL_GetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED);
/*auto activateWhenRaised = SDL_GetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED);
SDL_SetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, "0");
SDL_RaiseWindow(_window);
SDL_SetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, activateWhenRaised);
SDL_SetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, activateWhenRaised);*/
}
void SDLWindow::SetClientBounds(const Rectangle& clientArea)
@@ -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)
@@ -1303,7 +1303,7 @@ void SDLWindow::StartDragging(const Float2& offset)
{
LOG(Info, "StartDragging {}", offset);
DoDragDropWayland(String("awindow"));
DoDragDropWayland(String("notawindow"));
/*
_dragOver = true;

View File

@@ -424,7 +424,7 @@ namespace FlaxEngine.GUI
if (!IsDisposing)
{
// Arrange child controls
PerformLayout();
//PerformLayout();
}
}
@@ -454,7 +454,7 @@ namespace FlaxEngine.GUI
// Add child
_children.Add(child);
OnChildrenChanged();
//OnChildrenChanged();
}
/// <summary>
@@ -468,7 +468,7 @@ namespace FlaxEngine.GUI
// Remove child
_children.Remove(child);
OnChildrenChanged();
// OnChildrenChanged();
}
/// <summary>
@@ -679,11 +679,11 @@ namespace FlaxEngine.GUI
_containsFocus = result;
if (result)
{
OnStartContainsFocus();
//OnStartContainsFocus();
}
else
{
OnEndContainsFocus();
//OnEndContainsFocus();
}
}
}
@@ -1337,7 +1337,7 @@ namespace FlaxEngine.GUI
bool wasLayoutLocked = _isLayoutLocked;
_isLayoutLocked = true;
base.OnSizeChanged();
//base.OnSizeChanged();
// Fire event
for (int i = 0; i < _children.Count; i++)
@@ -1346,7 +1346,7 @@ namespace FlaxEngine.GUI
}
// Restore state
_isLayoutLocked = wasLayoutLocked;
//_isLayoutLocked = wasLayoutLocked;
// Arrange child controls
PerformLayout();

View File

@@ -122,7 +122,7 @@ namespace FlaxEngine.GUI
if (_parent == value)
return;
Defocus();
//Defocus();
Float2 oldParentSize;
if (_parent != null)
@@ -133,20 +133,20 @@ namespace FlaxEngine.GUI
else
{
oldParentSize = Float2.Zero;
ClearState();
//ClearState();
}
_parent = value;
_parent?.AddChildInternal(this);
CacheRootHandle();
OnParentChangedInternal();
/*OnParentChangedInternal();
// Check if parent size has been changed
if (_parent != null && !_parent.Size.Equals(ref oldParentSize))
{
OnParentResized();
}
}*/
}
}
@@ -461,13 +461,13 @@ namespace FlaxEngine.GUI
/// </summary>
public virtual void ClearState()
{
Defocus();
/*Defocus();
if (_isMouseOver)
OnMouseLeave();
if (_isDragOver)
OnDragLeave();
while (_touchOvers != null && _touchOvers.Count != 0)
OnTouchLeave(_touchOvers[0]);
OnTouchLeave(_touchOvers[0]);*/
}
#region Focus
@@ -1347,8 +1347,8 @@ namespace FlaxEngine.GUI
/// </summary>
protected virtual void OnSizeChanged()
{
SizeChanged?.Invoke(this);
_parent?.OnChildResized(this);
//SizeChanged?.Invoke(this);
//_parent?.OnChildResized(this);
}
/// <summary>
@@ -1422,12 +1422,12 @@ namespace FlaxEngine.GUI
/// </summary>
internal virtual void CacheRootHandle()
{
if (_root != null)
RemoveUpdateCallbacks(_root);
//if (_root != null)
// RemoveUpdateCallbacks(_root);
_root = _parent?.Root;
if (_root != null)
AddUpdateCallbacks(_root);
//if (_root != null)
// AddUpdateCallbacks(_root);
}
/// <summary>

View File

@@ -150,7 +150,7 @@ namespace FlaxEngine.GUI
Profiler.BeginEvent("RootControl.Update");
for (int i = 0; i < UpdateCallbacks.Count; i++)
{
UpdateCallbacks[i](deltaTime);
//UpdateCallbacks[i](deltaTime);
}
}
finally

View File

@@ -56,6 +56,7 @@ namespace FlaxEngine.GUI
/// <param name="targetArea">Tooltip target area of interest.</param>
public void Show(Control target, Float2 location, Rectangle targetArea)
{
return;
if (target == null)
throw new ArgumentNullException();

View File

@@ -69,7 +69,7 @@ namespace FlaxEngine.GUI
/// </summary>
public void Show()
{
_window.Show();
//_window.Show();
}
/// <summary>
@@ -77,7 +77,7 @@ namespace FlaxEngine.GUI
/// </summary>
public void Hide()
{
_window.Hide();
//_window.Hide();
}
/// <summary>
@@ -85,7 +85,7 @@ namespace FlaxEngine.GUI
/// </summary>
public void Minimize()
{
_window.Minimize();
//_window.Minimize();
}
/// <summary>
@@ -93,7 +93,7 @@ namespace FlaxEngine.GUI
/// </summary>
public void Maximize()
{
_window.Maximize();
//_window.Maximize();
}
/// <summary>
@@ -101,7 +101,7 @@ namespace FlaxEngine.GUI
/// </summary>
public void Restore()
{
_window.Restore();
//_window.Restore();
}
/// <summary>
@@ -119,7 +119,7 @@ namespace FlaxEngine.GUI
/// <param name="force">True if move to the front by force, otherwise false.</param>
public void BringToFront(bool force = false)
{
_window.BringToFront(force);
//_window.BringToFront(force);
}
/// <summary>
@@ -127,7 +127,7 @@ namespace FlaxEngine.GUI
/// </summary>
public void FlashWindow()
{
_window.FlashWindow();
//_window.FlashWindow();
}
/// <summary>
@@ -179,7 +179,7 @@ namespace FlaxEngine.GUI
_trackingControl = control;
_window.StartTrackingMouse(useMouseScreenOffset);
//_window.StartTrackingMouse(useMouseScreenOffset);
}
/// <inheritdoc />
@@ -191,7 +191,7 @@ namespace FlaxEngine.GUI
_trackingControl = null;
control.OnEndMouseCapture();
_window.EndTrackingMouse();
//_window.EndTrackingMouse();
}
}
@@ -246,7 +246,7 @@ namespace FlaxEngine.GUI
/// <inheritdoc />
public override void Focus()
{
_window.Focus();
//_window.Focus();
}
/// <inheritdoc />