Simplify wxPersistentTLW code and avoid warnings in it

Use wxPoint and wxSize instead of individual "int" variables to make the code
slightly shorter and avoid clang warnings about "y" and "h" being possibly
uninitialized (which couldn't happen, but the compiler didn't understand it,
at least in non-optimized builds).
This commit is contained in:
Vadim Zeitlin
2016-12-13 15:43:17 +01:00
parent 62a8c4f7c4
commit 34f8ae85e0

View File

@@ -79,14 +79,13 @@ public:
{ {
wxTopLevelWindow * const tlw = Get(); wxTopLevelWindow * const tlw = Get();
int x wxDUMMY_INITIALIZE(-1), wxPoint pos;
y wxDUMMY_INITIALIZE(-1), wxSize size;
w wxDUMMY_INITIALIZE(-1),
h wxDUMMY_INITIALIZE(-1); const bool hasPos = RestoreValue(wxPERSIST_TLW_X, &pos.x) &&
const bool hasPos = RestoreValue(wxPERSIST_TLW_X, &x) && RestoreValue(wxPERSIST_TLW_Y, &pos.y);
RestoreValue(wxPERSIST_TLW_Y, &y); const bool hasSize = RestoreValue(wxPERSIST_TLW_W, &size.x) &&
const bool hasSize = RestoreValue(wxPERSIST_TLW_W, &w) && RestoreValue(wxPERSIST_TLW_H, &size.y);
RestoreValue(wxPERSIST_TLW_H, &h);
#ifdef __WXGTK20__ #ifdef __WXGTK20__
wxTopLevelWindowGTK::DecorSize decorSize; wxTopLevelWindowGTK::DecorSize decorSize;
if (tlw->m_decorSize.top == 0 && if (tlw->m_decorSize.top == 0 &&
@@ -108,17 +107,16 @@ public:
// NB: we should allow window position to be (slightly) off screen, // NB: we should allow window position to be (slightly) off screen,
// it's not uncommon to position the window so that its upper // it's not uncommon to position the window so that its upper
// left corner has slightly negative coordinate // left corner has slightly negative coordinate
if ( wxDisplay::GetFromPoint(wxPoint(x, y)) != wxNOT_FOUND || if ( wxDisplay::GetFromPoint(pos) != wxNOT_FOUND ||
(hasSize && wxDisplay::GetFromPoint( (hasSize && wxDisplay::GetFromPoint(pos + size) != wxNOT_FOUND) )
wxPoint(x + w, y + h)) != wxNOT_FOUND) )
{ {
tlw->Move(x, y, wxSIZE_ALLOW_MINUS_ONE); tlw->Move(pos, wxSIZE_ALLOW_MINUS_ONE);
} }
//else: should we try to adjust position/size somehow? //else: should we try to adjust position/size somehow?
} }
if ( hasSize ) if ( hasSize )
tlw->SetSize(w, h); tlw->SetSize(size);
// note that the window can be both maximized and iconized // note that the window can be both maximized and iconized
bool maximized; bool maximized;