From 271c91e1157ef2e788a1d365a9860348d27204e1 Mon Sep 17 00:00:00 2001 From: Sandy Carter Date: Sun, 27 Jan 2019 11:39:21 -0500 Subject: [PATCH] [ui gtk] Fix init, resize and destroy Prevent Vulkan Swap before display context is assigned. Prevent resize while fullscreen (like in windows impl). Use superclass Resize implementation to reduce code duplication. Remove recursive call to GTKWindow::Close(). Destroy xcb window after superclass Close(). Set hwnd to null after closing on windows implementation. --- .../gpu/vulkan/vulkan_graphics_system.cc | 2 +- src/xenia/ui/window_gtk.cc | 23 +++++++++++-------- src/xenia/ui/window_win.cc | 1 + 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/xenia/gpu/vulkan/vulkan_graphics_system.cc b/src/xenia/gpu/vulkan/vulkan_graphics_system.cc index 0980e7f9e..2a9e16a7a 100644 --- a/src/xenia/gpu/vulkan/vulkan_graphics_system.cc +++ b/src/xenia/gpu/vulkan/vulkan_graphics_system.cc @@ -260,7 +260,7 @@ VulkanGraphicsSystem::CreateCommandProcessor() { } void VulkanGraphicsSystem::Swap(xe::ui::UIEvent* e) { - if (!command_processor_) { + if (!command_processor_ || !display_context_) { return; } diff --git a/src/xenia/ui/window_gtk.cc b/src/xenia/ui/window_gtk.cc index a785af2df..a53aacabb 100644 --- a/src/xenia/ui/window_gtk.cc +++ b/src/xenia/ui/window_gtk.cc @@ -138,8 +138,6 @@ void GTKWindow::OnDestroy() { super::OnDestroy(); } void GTKWindow::OnClose() { if (!closing_ && window_) { closing_ = true; - gtk_widget_destroy(window_); - window_ = nullptr; } super::OnClose(); } @@ -213,19 +211,23 @@ void GTKWindow::set_focus(bool value) { } void GTKWindow::Resize(int32_t width, int32_t height) { - width_ = width; - height_ = height; + if (is_fullscreen()) { + // Cannot resize while in fullscreen. + return; + } gtk_window_resize(GTK_WINDOW(window_), width, height); + super::Resize(width, height); } void GTKWindow::Resize(int32_t left, int32_t top, int32_t right, int32_t bottom) { - int32_t width = right - left; - int32_t height = bottom - top; - width_ = width; - height_ = height; + if (is_fullscreen()) { + // Cannot resize while in fullscreen. + return; + } gtk_window_move(GTK_WINDOW(window_), left, top); - gtk_window_resize(GTK_WINDOW(window_), width, height); + gtk_window_resize(GTK_WINDOW(window_), right - left, bottom - top); + super::Resize(left, top, right, bottom); } void GTKWindow::OnResize(UIEvent* e) { super::OnResize(e); } @@ -240,8 +242,9 @@ void GTKWindow::Close() { return; } closing_ = true; - Close(); OnClose(); + gtk_widget_destroy(window_); + window_ = nullptr; } void GTKWindow::OnMainMenuChange() { diff --git a/src/xenia/ui/window_win.cc b/src/xenia/ui/window_win.cc index 954502364..853f14030 100644 --- a/src/xenia/ui/window_win.cc +++ b/src/xenia/ui/window_win.cc @@ -446,6 +446,7 @@ void Win32Window::Close() { closing_ = true; OnClose(); DestroyWindow(hwnd_); + hwnd_ = 0; } void Win32Window::OnMainMenuChange() {