Have better support for maximized window.
Currently, if we maximize the window, our windowPosition{X,Y} become 0. When reopening the app, we have a window with the same size of a maximized, but without this property toggled on. This is not intuitive for users, since it is expected to have the last non-maximized size to be restored.
This commit is contained in:
parent
dcc0afa0d4
commit
f6bfe67632
|
@ -243,8 +243,9 @@ int videoOption;
|
||||||
int vsync;
|
int vsync;
|
||||||
int wasPaused = 0;
|
int wasPaused = 0;
|
||||||
uint32_t windowHeight;
|
uint32_t windowHeight;
|
||||||
int windowPositionX;
|
int windowMaximized;
|
||||||
int windowPositionY;
|
int windowPositionX, bkpPosX = 0;
|
||||||
|
int windowPositionY, bkpPosY = 0;
|
||||||
uint32_t windowWidth;
|
uint32_t windowWidth;
|
||||||
int winFlashSize;
|
int winFlashSize;
|
||||||
int winGbBorderOn;
|
int winGbBorderOn;
|
||||||
|
@ -555,6 +556,7 @@ void LoadConfig()
|
||||||
videoOption = ReadPref("video", 2); // VIDEO_3X = 2
|
videoOption = ReadPref("video", 2); // VIDEO_3X = 2
|
||||||
vsync = ReadPref("vsync", false);
|
vsync = ReadPref("vsync", false);
|
||||||
windowHeight = ReadPref("windowHeight", 0);
|
windowHeight = ReadPref("windowHeight", 0);
|
||||||
|
windowMaximized = ReadPref("windowMaximized", 0);
|
||||||
windowPositionX = ReadPref("windowX", -1);
|
windowPositionX = ReadPref("windowX", -1);
|
||||||
windowPositionY = ReadPref("windowY", -1);
|
windowPositionY = ReadPref("windowY", -1);
|
||||||
windowWidth = ReadPref("windowWidth", 0);
|
windowWidth = ReadPref("windowWidth", 0);
|
||||||
|
|
|
@ -133,8 +133,9 @@ extern int videoOption;
|
||||||
extern int vsync;
|
extern int vsync;
|
||||||
extern int wasPaused;
|
extern int wasPaused;
|
||||||
extern uint32_t windowHeight;
|
extern uint32_t windowHeight;
|
||||||
extern int windowPositionX;
|
extern int windowMaximized;
|
||||||
extern int windowPositionY;
|
extern int windowPositionX, bkpPosX;
|
||||||
|
extern int windowPositionY, bkpPosY;
|
||||||
extern uint32_t windowWidth;
|
extern uint32_t windowWidth;
|
||||||
extern int winFlashSize;
|
extern int winFlashSize;
|
||||||
extern int winGbBorderOn;
|
extern int winGbBorderOn;
|
||||||
|
|
|
@ -277,6 +277,7 @@ opt_desc opts[] = {
|
||||||
|
|
||||||
/// Geometry
|
/// Geometry
|
||||||
INTOPT("geometry/fullScreen", "Fullscreen", wxTRANSLATE("Enter fullscreen mode at startup"), fullScreen, 0, 1),
|
INTOPT("geometry/fullScreen", "Fullscreen", wxTRANSLATE("Enter fullscreen mode at startup"), fullScreen, 0, 1),
|
||||||
|
INTOPT("geometry/isMaximized", "Maximized", wxTRANSLATE("Window maximized"), windowMaximized, 0, 1),
|
||||||
UINTOPT("geometry/windowHeight", "Height", wxTRANSLATE("Window height at startup"), windowHeight, 0, 99999),
|
UINTOPT("geometry/windowHeight", "Height", wxTRANSLATE("Window height at startup"), windowHeight, 0, 99999),
|
||||||
UINTOPT("geometry/windowWidth", "Width", wxTRANSLATE("Window width at startup"), windowWidth, 0, 99999),
|
UINTOPT("geometry/windowWidth", "Width", wxTRANSLATE("Window width at startup"), windowWidth, 0, 99999),
|
||||||
INTOPT("geometry/windowX", "X", wxTRANSLATE("Window axis X position at startup"), windowPositionX, -1, 99999),
|
INTOPT("geometry/windowX", "X", wxTRANSLATE("Window axis X position at startup"), windowPositionX, -1, 99999),
|
||||||
|
|
|
@ -408,6 +408,7 @@ bool wxvbamApp::OnInit()
|
||||||
int width = windowWidth;
|
int width = windowWidth;
|
||||||
int height = windowHeight;
|
int height = windowHeight;
|
||||||
int isFullscreen = fullScreen;
|
int isFullscreen = fullScreen;
|
||||||
|
int isMaximized = windowMaximized;
|
||||||
frame = wxDynamicCast(xr->LoadFrame(NULL, wxT("MainFrame")), MainFrame);
|
frame = wxDynamicCast(xr->LoadFrame(NULL, wxT("MainFrame")), MainFrame);
|
||||||
|
|
||||||
if (!frame) {
|
if (!frame) {
|
||||||
|
@ -422,9 +423,13 @@ bool wxvbamApp::OnInit()
|
||||||
if (x >= 0 && y >= 0 && width > 0 && height > 0)
|
if (x >= 0 && y >= 0 && width > 0 && height > 0)
|
||||||
frame->SetSize(x, y, width, height);
|
frame->SetSize(x, y, width, height);
|
||||||
|
|
||||||
|
if (isMaximized)
|
||||||
|
frame->Maximize();
|
||||||
|
|
||||||
if (isFullscreen && wxGetApp().pending_load != wxEmptyString)
|
if (isFullscreen && wxGetApp().pending_load != wxEmptyString)
|
||||||
frame->ShowFullScreen(isFullscreen);
|
frame->ShowFullScreen(isFullscreen);
|
||||||
frame->Show(true);
|
frame->Show(true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -706,7 +711,7 @@ EVT_SIZE(MainFrame::OnSize)
|
||||||
// This is a feature most people don't like, and it causes problems with
|
// This is a feature most people don't like, and it causes problems with
|
||||||
// keyboard game keys on mac, so we will disable it for now.
|
// keyboard game keys on mac, so we will disable it for now.
|
||||||
//
|
//
|
||||||
// On Winodws, there will still be a pause because of how the windows event
|
// On Windows, there will still be a pause because of how the windows event
|
||||||
// model works, in addition the audio will loop with SDL, so we still pause on
|
// model works, in addition the audio will loop with SDL, so we still pause on
|
||||||
// Windows, TODO: this needs to be fixed properly
|
// Windows, TODO: this needs to be fixed properly
|
||||||
//
|
//
|
||||||
|
@ -761,10 +766,20 @@ void MainFrame::OnMove(wxMoveEvent& event)
|
||||||
(void)event; // unused params
|
(void)event; // unused params
|
||||||
wxPoint pos = GetScreenPosition();
|
wxPoint pos = GetScreenPosition();
|
||||||
int x = pos.x, y = pos.y;
|
int x = pos.x, y = pos.y;
|
||||||
if (x >= 0 && y >= 0 && !IsFullScreen())
|
if (!IsFullScreen() && !IsMaximized())
|
||||||
{
|
{
|
||||||
windowPositionX = x;
|
if (x >= 0 && y >= 0)
|
||||||
windowPositionY = y;
|
{
|
||||||
|
bkpPosX = windowPositionX;
|
||||||
|
bkpPosY = windowPositionY;
|
||||||
|
windowPositionX = x;
|
||||||
|
windowPositionY = y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
windowPositionX = bkpPosX;
|
||||||
|
windowPositionY = bkpPosY;
|
||||||
}
|
}
|
||||||
update_opts();
|
update_opts();
|
||||||
}
|
}
|
||||||
|
@ -777,16 +792,26 @@ void MainFrame::OnSize(wxSizeEvent& event)
|
||||||
int height = pos.GetHeight(), width = pos.GetWidth();
|
int height = pos.GetHeight(), width = pos.GetWidth();
|
||||||
int x = windowPos.x, y = windowPos.y;
|
int x = windowPos.x, y = windowPos.y;
|
||||||
bool isFullscreen = IsFullScreen();
|
bool isFullscreen = IsFullScreen();
|
||||||
if (height > 0 && width > 0 && !isFullscreen)
|
bool isMaximized = IsMaximized();
|
||||||
|
if (!isFullscreen && !isMaximized)
|
||||||
{
|
{
|
||||||
windowHeight = height;
|
if (height > 0 && width > 0)
|
||||||
windowWidth = width;
|
{
|
||||||
|
windowHeight = height;
|
||||||
|
windowWidth = width;
|
||||||
|
}
|
||||||
|
if (x >= 0 && y >= 0)
|
||||||
|
{
|
||||||
|
windowPositionX = x;
|
||||||
|
windowPositionY = y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (x >= 0 && y >= 0 && !isFullscreen)
|
else
|
||||||
{
|
{
|
||||||
windowPositionX = x;
|
windowPositionX = bkpPosX;
|
||||||
windowPositionY = y;
|
windowPositionY = bkpPosY;
|
||||||
}
|
}
|
||||||
|
windowMaximized = isMaximized;
|
||||||
fullScreen = isFullscreen;
|
fullScreen = isFullscreen;
|
||||||
update_opts();
|
update_opts();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue