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:
Edênis Freindorfer Azevedo 2019-06-04 23:29:40 -03:00 committed by Rafael Kitover
parent dcc0afa0d4
commit f6bfe67632
4 changed files with 43 additions and 14 deletions

View File

@ -243,8 +243,9 @@ int videoOption;
int vsync;
int wasPaused = 0;
uint32_t windowHeight;
int windowPositionX;
int windowPositionY;
int windowMaximized;
int windowPositionX, bkpPosX = 0;
int windowPositionY, bkpPosY = 0;
uint32_t windowWidth;
int winFlashSize;
int winGbBorderOn;
@ -555,6 +556,7 @@ void LoadConfig()
videoOption = ReadPref("video", 2); // VIDEO_3X = 2
vsync = ReadPref("vsync", false);
windowHeight = ReadPref("windowHeight", 0);
windowMaximized = ReadPref("windowMaximized", 0);
windowPositionX = ReadPref("windowX", -1);
windowPositionY = ReadPref("windowY", -1);
windowWidth = ReadPref("windowWidth", 0);

View File

@ -133,8 +133,9 @@ extern int videoOption;
extern int vsync;
extern int wasPaused;
extern uint32_t windowHeight;
extern int windowPositionX;
extern int windowPositionY;
extern int windowMaximized;
extern int windowPositionX, bkpPosX;
extern int windowPositionY, bkpPosY;
extern uint32_t windowWidth;
extern int winFlashSize;
extern int winGbBorderOn;

View File

@ -277,6 +277,7 @@ opt_desc opts[] = {
/// Geometry
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/windowWidth", "Width", wxTRANSLATE("Window width at startup"), windowWidth, 0, 99999),
INTOPT("geometry/windowX", "X", wxTRANSLATE("Window axis X position at startup"), windowPositionX, -1, 99999),

View File

@ -408,6 +408,7 @@ bool wxvbamApp::OnInit()
int width = windowWidth;
int height = windowHeight;
int isFullscreen = fullScreen;
int isMaximized = windowMaximized;
frame = wxDynamicCast(xr->LoadFrame(NULL, wxT("MainFrame")), MainFrame);
if (!frame) {
@ -422,9 +423,13 @@ bool wxvbamApp::OnInit()
if (x >= 0 && y >= 0 && width > 0 && height > 0)
frame->SetSize(x, y, width, height);
if (isMaximized)
frame->Maximize();
if (isFullscreen && wxGetApp().pending_load != wxEmptyString)
frame->ShowFullScreen(isFullscreen);
frame->Show(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
// 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
// Windows, TODO: this needs to be fixed properly
//
@ -761,10 +766,20 @@ void MainFrame::OnMove(wxMoveEvent& event)
(void)event; // unused params
wxPoint pos = GetScreenPosition();
int x = pos.x, y = pos.y;
if (x >= 0 && y >= 0 && !IsFullScreen())
if (!IsFullScreen() && !IsMaximized())
{
windowPositionX = x;
windowPositionY = y;
if (x >= 0 && y >= 0)
{
bkpPosX = windowPositionX;
bkpPosY = windowPositionY;
windowPositionX = x;
windowPositionY = y;
}
}
else
{
windowPositionX = bkpPosX;
windowPositionY = bkpPosY;
}
update_opts();
}
@ -777,16 +792,26 @@ void MainFrame::OnSize(wxSizeEvent& event)
int height = pos.GetHeight(), width = pos.GetWidth();
int x = windowPos.x, y = windowPos.y;
bool isFullscreen = IsFullScreen();
if (height > 0 && width > 0 && !isFullscreen)
bool isMaximized = IsMaximized();
if (!isFullscreen && !isMaximized)
{
windowHeight = height;
windowWidth = width;
if (height > 0 && width > 0)
{
windowHeight = height;
windowWidth = width;
}
if (x >= 0 && y >= 0)
{
windowPositionX = x;
windowPositionY = y;
}
}
if (x >= 0 && y >= 0 && !isFullscreen)
else
{
windowPositionX = x;
windowPositionY = y;
windowPositionX = bkpPosX;
windowPositionY = bkpPosY;
}
windowMaximized = isMaximized;
fullScreen = isFullscreen;
update_opts();
}