Fix popup and context menus not working on Wayland

This commit is contained in:
2024-07-28 17:47:56 +03:00
committed by Ari Vuollet
parent f4f756e310
commit e96ef49f09
3 changed files with 79 additions and 19 deletions

View File

@@ -218,13 +218,20 @@ namespace FlaxEditor.GUI.ContextMenu
desc.AllowMaximize = false;
desc.AllowDragAndDrop = false;
desc.IsTopmost = true;
desc.Type = WindowType.Utility;
desc.Type = WindowType.Popup;
//desc.Parent = parentWin.Window;
desc.HasSizingFrame = false;
OnWindowCreating(ref desc);
_window = Platform.CreateWindow(ref desc);
_window.GotFocus += OnWindowGotFocus;
_window.LostFocus += OnWindowLostFocus;
#if USE_IS_FOREGROUND && USE_SDL_WORKAROUNDS
// The focus between popup and parent windows doesn't change, force hide the popup when clicked on parent
parentWin.Window.MouseDown += OnWindowMouseDown;
_window.Closed += () => parentWin.Window.MouseDown -= OnWindowMouseDown;
#endif
// Attach to the window
_parentCM = parent as ContextMenuBase;
Parent = _window.GUI;
@@ -383,6 +390,12 @@ namespace FlaxEditor.GUI.ContextMenu
private void OnWindowGotFocus()
{
}
private void OnWindowMouseDown(ref Float2 mousePosition, MouseButton button, ref bool handled)
{
// The user clicked outside the popup window
Hide();
}
#else
private void OnWindowGotFocus()
{