[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.
This commit is contained in:
parent
0b5ff8332e
commit
271c91e115
|
@ -260,7 +260,7 @@ VulkanGraphicsSystem::CreateCommandProcessor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanGraphicsSystem::Swap(xe::ui::UIEvent* e) {
|
void VulkanGraphicsSystem::Swap(xe::ui::UIEvent* e) {
|
||||||
if (!command_processor_) {
|
if (!command_processor_ || !display_context_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,8 +138,6 @@ void GTKWindow::OnDestroy() { super::OnDestroy(); }
|
||||||
void GTKWindow::OnClose() {
|
void GTKWindow::OnClose() {
|
||||||
if (!closing_ && window_) {
|
if (!closing_ && window_) {
|
||||||
closing_ = true;
|
closing_ = true;
|
||||||
gtk_widget_destroy(window_);
|
|
||||||
window_ = nullptr;
|
|
||||||
}
|
}
|
||||||
super::OnClose();
|
super::OnClose();
|
||||||
}
|
}
|
||||||
|
@ -213,19 +211,23 @@ void GTKWindow::set_focus(bool value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GTKWindow::Resize(int32_t width, int32_t height) {
|
void GTKWindow::Resize(int32_t width, int32_t height) {
|
||||||
width_ = width;
|
if (is_fullscreen()) {
|
||||||
height_ = height;
|
// Cannot resize while in fullscreen.
|
||||||
|
return;
|
||||||
|
}
|
||||||
gtk_window_resize(GTK_WINDOW(window_), width, height);
|
gtk_window_resize(GTK_WINDOW(window_), width, height);
|
||||||
|
super::Resize(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GTKWindow::Resize(int32_t left, int32_t top, int32_t right,
|
void GTKWindow::Resize(int32_t left, int32_t top, int32_t right,
|
||||||
int32_t bottom) {
|
int32_t bottom) {
|
||||||
int32_t width = right - left;
|
if (is_fullscreen()) {
|
||||||
int32_t height = bottom - top;
|
// Cannot resize while in fullscreen.
|
||||||
width_ = width;
|
return;
|
||||||
height_ = height;
|
}
|
||||||
gtk_window_move(GTK_WINDOW(window_), left, top);
|
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); }
|
void GTKWindow::OnResize(UIEvent* e) { super::OnResize(e); }
|
||||||
|
@ -240,8 +242,9 @@ void GTKWindow::Close() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
closing_ = true;
|
closing_ = true;
|
||||||
Close();
|
|
||||||
OnClose();
|
OnClose();
|
||||||
|
gtk_widget_destroy(window_);
|
||||||
|
window_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GTKWindow::OnMainMenuChange() {
|
void GTKWindow::OnMainMenuChange() {
|
||||||
|
|
|
@ -446,6 +446,7 @@ void Win32Window::Close() {
|
||||||
closing_ = true;
|
closing_ = true;
|
||||||
OnClose();
|
OnClose();
|
||||||
DestroyWindow(hwnd_);
|
DestroyWindow(hwnd_);
|
||||||
|
hwnd_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Win32Window::OnMainMenuChange() {
|
void Win32Window::OnMainMenuChange() {
|
||||||
|
|
Loading…
Reference in New Issue