From b30ab38ef21a8780e87fe46c8b9deca328990018 Mon Sep 17 00:00:00 2001 From: mafiesto4 Date: Mon, 8 Feb 2021 22:53:32 +0100 Subject: [PATCH] Window impl on Linux progress --- Source/Editor/Modules/WindowsModule.cs | 1 + .../Vulkan/GPUSwapChainVulkan.cpp | 6 ++++-- Source/Engine/Platform/Linux/LinuxPlatform.cpp | 17 ++++++++--------- Source/Engine/Platform/Linux/LinuxWindow.cpp | 5 +---- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Source/Editor/Modules/WindowsModule.cs b/Source/Editor/Modules/WindowsModule.cs index 222763152..0f12c442f 100644 --- a/Source/Editor/Modules/WindowsModule.cs +++ b/Source/Editor/Modules/WindowsModule.cs @@ -718,6 +718,7 @@ namespace FlaxEditor.Modules { settings.HasBorder = false; #if PLATFORM_WINDOWS + // Skip OS sizing frame and implement it using LeftButtonHit settings.HasSizingFrame = false; #endif } diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp index d90d8e59c..f4ad69c80 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp @@ -483,8 +483,9 @@ int32 GPUSwapChainVulkan::TryPresent(Function // Recreate swapchain ASSERT(_swapChain != VK_NULL_HANDLE); + int32 width = _width, height = _height; ReleaseGPU(); - CreateSwapChain(_width, _height); + CreateSwapChain(width, height); // Flush commands _device->GetMainContext()->Flush(); @@ -571,8 +572,9 @@ void GPUSwapChainVulkan::Present(bool vsync) } // Rebuild swapchain for the next present + int32 width = _width, height = _height; ReleaseGPU(); - CreateSwapChain(_width, _height); + CreateSwapChain(width, height); _device->GetMainContext()->Flush(); _device->WaitForGPU(); return; diff --git a/Source/Engine/Platform/Linux/LinuxPlatform.cpp b/Source/Engine/Platform/Linux/LinuxPlatform.cpp index 89eabe3f7..34c4b0a1f 100644 --- a/Source/Engine/Platform/Linux/LinuxPlatform.cpp +++ b/Source/Engine/Platform/Linux/LinuxPlatform.cpp @@ -1681,7 +1681,6 @@ void LinuxPlatform::Tick() switch (event.type) { case ClientMessage: - { // User requested the window to close if ((X11::Atom)event.xclient.data.l[0] == xAtomDeleteWindow) { @@ -1691,31 +1690,32 @@ void LinuxPlatform::Tick() window->Close(ClosingReason::User); } } - } break; case FocusIn: - { // Update input context focus X11::XSetICFocus(IC); - window = WindowsManager::GetByNativePtr((void*)event.xfocus.window); if (window) { window->OnGotFocus(); } - } break; case FocusOut: - { // Update input context focus X11::XUnsetICFocus(IC); - window = WindowsManager::GetByNativePtr((void*)event.xfocus.window); if (window) { window->OnLostFocus(); } - } + break; + case ConfigureNotify: + // Handle window resizing + window = WindowsManager::GetByNativePtr((void*)event.xclient.window); + if (window) + { + window->CheckForWindowResize(); + } break; case PropertyNotify: // Report minimize, maximize and restore events @@ -1736,7 +1736,6 @@ void LinuxPlatform::Tick() window = WindowsManager::GetByNativePtr((void*)event.xproperty.window); if (window == nullptr) continue; - X11::Atom* atoms = (X11::Atom*)data; bool foundHorz = false; diff --git a/Source/Engine/Platform/Linux/LinuxWindow.cpp b/Source/Engine/Platform/Linux/LinuxWindow.cpp index fcf3cae81..42f9f17a8 100644 --- a/Source/Engine/Platform/Linux/LinuxWindow.cpp +++ b/Source/Engine/Platform/Linux/LinuxWindow.cpp @@ -319,13 +319,10 @@ void LinuxWindow::SetClientBounds(const Rectangle& clientArea) { X11::XSizeHints hints; hints.flags = PMinSize | PMaxSize; - hints.min_height = height; hints.max_height = height; - hints.min_width = width; hints.max_width = width; - X11::XSetNormalHints(display, window, &hints); } @@ -605,7 +602,7 @@ void LinuxWindow::Maximize(bool enable) XSendEvent(display, X11_DefaultRootWindow(display), 0, SubstructureRedirectMask | SubstructureNotifyMask, &event); } - else + else if (enable) { X11::Atom states[2]; states[0] = wmMaxVert;