[XConfig] Implementation of XConfig
This commit is contained in:
committed by
Radosław Gliński
parent
f88bfbe41e
commit
99ea6da18a
@@ -16,6 +16,9 @@
|
||||
#include "xenia/ui/imgui_drawer.h"
|
||||
#include "xenia/ui/presenter.h"
|
||||
|
||||
DEFINE_int32(window_size_x, 1280, "Xenia window width", "UI");
|
||||
DEFINE_int32(window_size_y, 720, "Xenia window height", "UI");
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
|
||||
@@ -242,6 +245,7 @@ void Window::SetFullscreen(bool new_fullscreen) {
|
||||
if (!CanApplyState()) {
|
||||
return;
|
||||
}
|
||||
|
||||
WindowDestructionReceiver destruction_receiver(this);
|
||||
ApplyNewFullscreen();
|
||||
if (destruction_receiver.IsWindowDestroyedOrStateInapplicable()) {
|
||||
@@ -499,6 +503,7 @@ void Window::OnUsbDeviceChanged(
|
||||
|
||||
bool Window::OnActualSizeUpdate(
|
||||
uint32_t new_physical_width, uint32_t new_physical_height,
|
||||
WindowResizeAction cause_action,
|
||||
WindowDestructionReceiver& destruction_receiver) {
|
||||
if (actual_physical_width_ == new_physical_width &&
|
||||
actual_physical_height_ == new_physical_height) {
|
||||
@@ -508,6 +513,13 @@ bool Window::OnActualSizeUpdate(
|
||||
actual_physical_height_ = new_physical_height;
|
||||
// The listeners may reference the presenter, update the presenter first.
|
||||
if (presenter_surface_) {
|
||||
// Update variable only if window isn't in fullscreen mode.
|
||||
if (!fullscreen_ && cause_action == WindowResizeAction::kManual) {
|
||||
// Write new window size only if we know that window is present.
|
||||
OVERRIDE_int32(window_size_x, SizeToLogical(new_physical_width));
|
||||
OVERRIDE_int32(window_size_y, SizeToLogical(new_physical_height));
|
||||
}
|
||||
|
||||
presenter_->OnSurfaceResizeFromUIThread();
|
||||
}
|
||||
UISetupEvent e(this);
|
||||
|
||||
@@ -152,6 +152,12 @@ class Window {
|
||||
kHidden,
|
||||
};
|
||||
|
||||
enum class WindowResizeAction {
|
||||
kManual,
|
||||
kAutoMaximize,
|
||||
kAutoMinimize,
|
||||
};
|
||||
|
||||
static std::unique_ptr<Window> Create(WindowedAppContext& app_context,
|
||||
const std::string_view title,
|
||||
uint32_t desired_logical_width,
|
||||
@@ -572,6 +578,7 @@ class Window {
|
||||
// explicitly.
|
||||
bool OnActualSizeUpdate(uint32_t new_physical_width,
|
||||
uint32_t new_physical_height,
|
||||
WindowResizeAction cause_action,
|
||||
WindowDestructionReceiver& destruction_receiver);
|
||||
void OnDesiredFullscreenUpdate(bool new_fullscreen) {
|
||||
fullscreen_ = new_fullscreen;
|
||||
|
||||
@@ -124,7 +124,7 @@ bool GTKWindow::OpenImpl() {
|
||||
gtk_widget_get_allocation(drawing_area_, &drawing_area_allocation);
|
||||
OnActualSizeUpdate(uint32_t(drawing_area_allocation.width),
|
||||
uint32_t(drawing_area_allocation.height),
|
||||
destruction_receiver);
|
||||
WindowResizeAction::kManual, destruction_receiver);
|
||||
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
|
||||
return true;
|
||||
}
|
||||
@@ -311,7 +311,7 @@ void GTKWindow::HandleSizeUpdate(
|
||||
gtk_widget_get_allocation(drawing_area_, &drawing_area_allocation);
|
||||
OnActualSizeUpdate(uint32_t(drawing_area_allocation.width),
|
||||
uint32_t(drawing_area_allocation.height),
|
||||
destruction_receiver);
|
||||
WindowResizeAction::kManual, destruction_receiver);
|
||||
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ bool Win32Window::OpenImpl() {
|
||||
if (GetClientRect(hwnd_, &shown_client_rect)) {
|
||||
OnActualSizeUpdate(uint32_t(shown_client_rect.right),
|
||||
uint32_t(shown_client_rect.bottom),
|
||||
destruction_receiver);
|
||||
WindowResizeAction::kManual, destruction_receiver);
|
||||
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
|
||||
return true;
|
||||
}
|
||||
@@ -722,7 +722,7 @@ void Win32Window::ApplyFullscreenEntry(
|
||||
}
|
||||
|
||||
void Win32Window::HandleSizeUpdate(
|
||||
WindowDestructionReceiver& destruction_receiver) {
|
||||
WindowDestructionReceiver& destruction_receiver, DWORD cause_action) {
|
||||
if (!hwnd_) {
|
||||
// Batched size update ended when the window has already been closed, for
|
||||
// instance.
|
||||
@@ -767,7 +767,10 @@ void Win32Window::HandleSizeUpdate(
|
||||
RECT client_rect;
|
||||
if (GetClientRect(hwnd_, &client_rect)) {
|
||||
OnActualSizeUpdate(uint32_t(client_rect.right),
|
||||
uint32_t(client_rect.bottom), destruction_receiver);
|
||||
uint32_t(client_rect.bottom),
|
||||
cause_action == 0 ? WindowResizeAction::kManual
|
||||
: WindowResizeAction::kAutoMaximize,
|
||||
destruction_receiver);
|
||||
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
|
||||
return;
|
||||
}
|
||||
@@ -792,7 +795,7 @@ void Win32Window::EndBatchedSizeUpdate(
|
||||
// handle the deferred messages twice.
|
||||
if (batched_size_update_contained_wm_size_) {
|
||||
batched_size_update_contained_wm_size_ = false;
|
||||
HandleSizeUpdate(destruction_receiver);
|
||||
HandleSizeUpdate(destruction_receiver, 0);
|
||||
if (destruction_receiver.IsWindowDestroyed()) {
|
||||
return;
|
||||
}
|
||||
@@ -1064,7 +1067,7 @@ LRESULT Win32Window::WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
batched_size_update_contained_wm_size_ = true;
|
||||
} else {
|
||||
WindowDestructionReceiver destruction_receiver(this);
|
||||
HandleSizeUpdate(destruction_receiver);
|
||||
HandleSizeUpdate(destruction_receiver, wParam);
|
||||
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,8 @@ class Win32Window : public Window {
|
||||
|
||||
void ApplyFullscreenEntry(WindowDestructionReceiver& destruction_receiver);
|
||||
|
||||
void HandleSizeUpdate(WindowDestructionReceiver& destruction_receiver);
|
||||
void HandleSizeUpdate(WindowDestructionReceiver& destruction_receiver,
|
||||
DWORD cause_action);
|
||||
// For updating multiple factors that may influence the window size at once,
|
||||
// without handling WM_SIZE multiple times (that may not only result in wasted
|
||||
// handling, but also in the state potentially changed to an inconsistent one
|
||||
|
||||
Reference in New Issue
Block a user