From 587a510028a3157b71f967a0a7ee883bc3f9fd51 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 22 May 2018 23:23:49 +0200 Subject: [PATCH] Remove unnecessary wxUSE_DISPLAY preprocessor checks Most of the methods of wxDisplay are always available, they just only support primary display when wxUSE_DISPLAY==0, so there is no need to check for wxUSE_DISPLAY before using them as they already contain the only possible fallback anyhow and such checks are useless. This incidentally closes #18115, due to removing "#if wxUSE_DISPLAY" around wx/display.h inclusion. --- src/common/dlgcmn.cpp | 6 ------ src/msw/toplevel.cpp | 19 ++++++------------- src/stc/PlatWX.cpp | 8 +------- 3 files changed, 7 insertions(+), 26 deletions(-) diff --git a/src/common/dlgcmn.cpp b/src/common/dlgcmn.cpp index 9914266c05..55e37cc2e6 100644 --- a/src/common/dlgcmn.cpp +++ b/src/common/dlgcmn.cpp @@ -44,9 +44,7 @@ #include "wx/textwrapper.h" #include "wx/modalhook.h" -#if wxUSE_DISPLAY #include "wx/display.h" -#endif extern WXDLLEXPORT_DATA(const char) wxDialogNameStr[] = "dialog"; @@ -873,11 +871,7 @@ int wxStandardDialogLayoutAdapter::DoMustScroll(wxDialog* dialog, wxSize& window wxSize minWindowSize = dialog->GetSizer()->GetMinSize(); windowSize = dialog->GetSize(); windowSize = wxSize(wxMax(windowSize.x, minWindowSize.x), wxMax(windowSize.y, minWindowSize.y)); -#if wxUSE_DISPLAY displaySize = wxDisplay(wxDisplay::GetFromWindow(dialog)).GetClientArea().GetSize(); -#else - displaySize = wxGetClientDisplayRect().GetSize(); -#endif int flags = 0; diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index a7d4bac9b6..d2b89ccc97 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -905,20 +905,13 @@ bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style) // change our window style to be compatible with full-screen mode updateStyle.Apply(); - wxRect rect; -#if wxUSE_DISPLAY - // resize to the size of the display containing us + // resize to the size of the display containing us, falling back to the + // primary one int dpy = wxDisplay::GetFromWindow(this); - if ( dpy != wxNOT_FOUND ) - { - rect = wxDisplay(dpy).GetGeometry(); - } - else // fall back to the main desktop -#endif // wxUSE_DISPLAY - { - // resize to the size of the desktop - wxCopyRECTToRect(wxGetWindowRect(::GetDesktopWindow()), rect); - } + if ( dpy == wxNOT_FOUND ) + dpy = 0; + + const wxRect rect = wxDisplay(dpy).GetGeometry(); SetSize(rect); diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 1efb9d9de0..a836c2cfc4 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -1953,17 +1953,11 @@ void Window::SetTitle(const char *s) { // Returns rectangle of monitor pt is on PRectangle Window::GetMonitorRect(Point pt) { - wxRect rect; if (! wid) return PRectangle(); -#if wxUSE_DISPLAY // Get the display the point is found on int n = wxDisplay::GetFromPoint(wxPoint(wxRound(pt.x), wxRound(pt.y))); wxDisplay dpy(n == wxNOT_FOUND ? 0 : n); - rect = dpy.GetGeometry(); -#else - wxUnusedVar(pt); -#endif - return PRectangleFromwxRect(rect); + return PRectangleFromwxRect(dpy.GetGeometry()); } //----------------------------------------------------------------------