From bac28b95cdae86d1800e7e93ab5f31a0639c5b5d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 22 May 2018 23:10:45 +0200 Subject: [PATCH 01/17] Move wx/display_impl.h to wx/private/display.h This shows more clearly that this header is private to wxWidgets and can't be included by user code. No real changes. --- build/bakefiles/files.bkl | 1 - build/cmake/files.cmake | 1 - build/files | 1 - build/msw/wx_core.vcxproj | 1 - build/msw/wx_core.vcxproj.filters | 3 --- build/msw/wx_vc7_core.vcproj | 3 --- build/msw/wx_vc8_core.vcproj | 4 ---- build/msw/wx_vc9_core.vcproj | 4 ---- include/wx/{display_impl.h => private/display.h} | 9 ++++----- src/common/dpycmn.cpp | 2 +- src/gtk/display.cpp | 2 +- src/msw/display.cpp | 2 +- src/osx/core/display.cpp | 2 +- src/qt/display.cpp | 2 +- src/unix/displayx11.cpp | 2 +- 15 files changed, 10 insertions(+), 29 deletions(-) rename include/wx/{display_impl.h => private/display.h} (96%) diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index 27339536a8..80b3217f79 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -1124,7 +1124,6 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! wx/dialup.h wx/dirctrl.h wx/display.h - wx/display_impl.h wx/dnd.h wx/docmdi.h wx/docview.h diff --git a/build/cmake/files.cmake b/build/cmake/files.cmake index 7749731579..5af3d5ac77 100644 --- a/build/cmake/files.cmake +++ b/build/cmake/files.cmake @@ -1032,7 +1032,6 @@ set(GUI_CMN_HDR wx/dialup.h wx/dirctrl.h wx/display.h - wx/display_impl.h wx/dnd.h wx/docmdi.h wx/docview.h diff --git a/build/files b/build/files index ef98625be1..abe00f1361 100644 --- a/build/files +++ b/build/files @@ -967,7 +967,6 @@ GUI_CMN_HDR = wx/dirctrl.h wx/dirdlg.h wx/display.h - wx/display_impl.h wx/dnd.h wx/docmdi.h wx/docview.h diff --git a/build/msw/wx_core.vcxproj b/build/msw/wx_core.vcxproj index 6c83436a0b..bf3ea86b5a 100644 --- a/build/msw/wx_core.vcxproj +++ b/build/msw/wx_core.vcxproj @@ -1280,7 +1280,6 @@ - diff --git a/build/msw/wx_core.vcxproj.filters b/build/msw/wx_core.vcxproj.filters index d83e645ce5..7e17bd7ad0 100644 --- a/build/msw/wx_core.vcxproj.filters +++ b/build/msw/wx_core.vcxproj.filters @@ -1267,9 +1267,6 @@ Common Headers - - Common Headers - Common Headers diff --git a/build/msw/wx_vc7_core.vcproj b/build/msw/wx_vc7_core.vcproj index 558ebba9fc..f64feb56e0 100644 --- a/build/msw/wx_vc7_core.vcproj +++ b/build/msw/wx_vc7_core.vcproj @@ -2270,9 +2270,6 @@ - - diff --git a/build/msw/wx_vc8_core.vcproj b/build/msw/wx_vc8_core.vcproj index 59890d3916..b734aa02bd 100644 --- a/build/msw/wx_vc8_core.vcproj +++ b/build/msw/wx_vc8_core.vcproj @@ -3528,10 +3528,6 @@ RelativePath="..\..\include\wx\display.h" > - - diff --git a/build/msw/wx_vc9_core.vcproj b/build/msw/wx_vc9_core.vcproj index 0443a4194b..0b33c64c19 100644 --- a/build/msw/wx_vc9_core.vcproj +++ b/build/msw/wx_vc9_core.vcproj @@ -3524,10 +3524,6 @@ RelativePath="..\..\include\wx\display.h" > - - diff --git a/include/wx/display_impl.h b/include/wx/private/display.h similarity index 96% rename from include/wx/display_impl.h rename to include/wx/private/display.h index 40b4827885..cbaa3a2690 100644 --- a/include/wx/display_impl.h +++ b/include/wx/private/display.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/display_impl.h +// Name: wx/private/display.h // Purpose: wxDisplayImpl class declaration // Author: Vadim Zeitlin // Created: 2006-03-15 @@ -7,8 +7,8 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifndef _WX_DISPLAY_IMPL_H_BASE_ -#define _WX_DISPLAY_IMPL_H_BASE_ +#ifndef _WX_PRIVATE_DISPLAY_H_ +#define _WX_PRIVATE_DISPLAY_H_ #include "wx/gdicmn.h" // for wxRect @@ -105,5 +105,4 @@ public: virtual int GetFromPoint(const wxPoint& pt) wxOVERRIDE; }; -#endif // _WX_DISPLAY_IMPL_H_BASE_ - +#endif // _WX_PRIVATE_DISPLAY_H_ diff --git a/src/common/dpycmn.cpp b/src/common/dpycmn.cpp index ecc744d4aa..ca4b1377a9 100644 --- a/src/common/dpycmn.cpp +++ b/src/common/dpycmn.cpp @@ -30,7 +30,7 @@ #endif //WX_PRECOMP #include "wx/display.h" -#include "wx/display_impl.h" +#include "wx/private/display.h" #if wxUSE_DISPLAY diff --git a/src/gtk/display.cpp b/src/gtk/display.cpp index d3fc6e465c..cc00c499dd 100644 --- a/src/gtk/display.cpp +++ b/src/gtk/display.cpp @@ -10,7 +10,7 @@ #if wxUSE_DISPLAY #include "wx/display.h" - #include "wx/display_impl.h" + #include "wx/private/display.h" #endif #include "wx/utils.h" // wxClientDisplayRect diff --git a/src/msw/display.cpp b/src/msw/display.cpp index 3256c65cbc..b096d1895d 100644 --- a/src/msw/display.cpp +++ b/src/msw/display.cpp @@ -39,7 +39,7 @@ #include "wx/dynlib.h" #include "wx/sysopt.h" -#include "wx/display_impl.h" +#include "wx/private/display.h" #include "wx/msw/missing.h" #include "wx/msw/private.h" #include "wx/msw/private/hiddenwin.h" diff --git a/src/osx/core/display.cpp b/src/osx/core/display.cpp index fa4fec60a8..679312274b 100644 --- a/src/osx/core/display.cpp +++ b/src/osx/core/display.cpp @@ -33,7 +33,7 @@ #include "wx/gdicmn.h" #endif -#include "wx/display_impl.h" +#include "wx/private/display.h" #include "wx/scopedarray.h" #include "wx/osx/private.h" diff --git a/src/qt/display.cpp b/src/qt/display.cpp index 28cc87358f..5b5dc228b9 100644 --- a/src/qt/display.cpp +++ b/src/qt/display.cpp @@ -9,7 +9,7 @@ #include "wx/wxprec.h" #include "wx/display.h" -#include "wx/display_impl.h" +#include "wx/private/display.h" #include #include #include "wx/qt/private/converter.h" diff --git a/src/unix/displayx11.cpp b/src/unix/displayx11.cpp index 5b709ca0ff..41ab88060b 100644 --- a/src/unix/displayx11.cpp +++ b/src/unix/displayx11.cpp @@ -40,7 +40,7 @@ #if wxUSE_DISPLAY #include "wx/display.h" -#include "wx/display_impl.h" +#include "wx/private/display.h" #ifndef __WXGTK20__ From 587a510028a3157b71f967a0a7ee883bc3f9fd51 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 22 May 2018 23:23:49 +0200 Subject: [PATCH 02/17] 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()); } //---------------------------------------------------------------------- From 141d7b826da1d6feb2b2a28b69d5c25d3c1c6972 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 22 May 2018 23:25:45 +0200 Subject: [PATCH 03/17] Fix weird indentation in X11 display code No real changes. --- src/unix/displayx11.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/displayx11.cpp b/src/unix/displayx11.cpp index 41ab88060b..5c740ef4b0 100644 --- a/src/unix/displayx11.cpp +++ b/src/unix/displayx11.cpp @@ -44,9 +44,9 @@ #ifndef __WXGTK20__ - #include +#include - typedef XineramaScreenInfo ScreenInfo; +typedef XineramaScreenInfo ScreenInfo; // ---------------------------------------------------------------------------- // helper class storing information about all screens From 77e33d9e1beb86bff2133b536777312abfeb58f6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 29 Sep 2018 23:01:36 +0200 Subject: [PATCH 04/17] Micro optimization in wxDisplay ctor Don't check for the index validity if it's 0, which is the most common case, as index 0 is always valid and so we can avoid calling GetCount(), which might have a non-trivial cost, completely. --- src/common/dpycmn.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/dpycmn.cpp b/src/common/dpycmn.cpp index ca4b1377a9..e7cb12aee5 100644 --- a/src/common/dpycmn.cpp +++ b/src/common/dpycmn.cpp @@ -115,7 +115,7 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxDisplayModule, wxModule); wxDisplay::wxDisplay(unsigned n) { - wxASSERT_MSG( n < GetCount(), + wxASSERT_MSG( n == 0 || n < GetCount(), wxT("An invalid index was passed to wxDisplay") ); m_impl = Factory().CreateDisplay(n); From 9f37d91498b9313ddef10de5ceea0954c8840c80 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 29 Sep 2018 23:08:05 +0200 Subject: [PATCH 05/17] Fix wrong comment before wxDisplayFactorySingle::CreateDisplay() This method is not static. --- src/common/dpycmn.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/common/dpycmn.cpp b/src/common/dpycmn.cpp index e7cb12aee5..8e14dde43f 100644 --- a/src/common/dpycmn.cpp +++ b/src/common/dpycmn.cpp @@ -241,7 +241,6 @@ int wxDisplayFactory::GetFromWindow(const wxWindow *window) // wxDisplayFactorySingle implementation // ============================================================================ -/* static */ wxDisplayImpl *wxDisplayFactorySingle::CreateDisplay(unsigned n) { // we recognize the main display only From 961995072183ea698911b6ffef65e40144ef00d6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 29 Sep 2018 23:10:24 +0200 Subject: [PATCH 06/17] Use wxOVERRIDE for wxDisplay-related classes in wxQt No real changes. --- src/qt/display.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/qt/display.cpp b/src/qt/display.cpp index 5b5dc228b9..6e2fa75774 100644 --- a/src/qt/display.cpp +++ b/src/qt/display.cpp @@ -19,12 +19,12 @@ class wxDisplayImplQt : public wxDisplayImpl public: wxDisplayImplQt( unsigned n ); - virtual wxRect GetGeometry() const; - virtual wxString GetName() const; + virtual wxRect GetGeometry() const wxOVERRIDE; + virtual wxString GetName() const wxOVERRIDE; - virtual wxArrayVideoModes GetModes(const wxVideoMode& mode) const; - virtual wxVideoMode GetCurrentMode() const; - virtual bool ChangeMode(const wxVideoMode& mode); + virtual wxArrayVideoModes GetModes(const wxVideoMode& mode) const wxOVERRIDE; + virtual wxVideoMode GetCurrentMode() const wxOVERRIDE; + virtual bool ChangeMode(const wxVideoMode& mode) wxOVERRIDE; }; wxDisplayImplQt::wxDisplayImplQt( unsigned n ) @@ -69,9 +69,9 @@ class wxDisplayFactoryQt : public wxDisplayFactory public: wxDisplayFactoryQt(); - virtual wxDisplayImpl *CreateDisplay(unsigned n); - virtual unsigned GetCount(); - virtual int GetFromPoint(const wxPoint& pt); + virtual wxDisplayImpl *CreateDisplay(unsigned n) wxOVERRIDE; + virtual unsigned GetCount() wxOVERRIDE; + virtual int GetFromPoint(const wxPoint& pt) wxOVERRIDE; }; From b4aaa1003247535675f21b69cf800353012ca81c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 30 Sep 2018 00:24:32 +0200 Subject: [PATCH 07/17] Fix wx/display.h compilation when it's the first included header Include wx/defs.h to ensure that wxUSE_DISPLAY is defined before it is checked for. --- include/wx/display.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/wx/display.h b/include/wx/display.h index 4678672138..1c8d04379d 100644 --- a/include/wx/display.h +++ b/include/wx/display.h @@ -10,6 +10,8 @@ #ifndef _WX_DISPLAY_H_BASE_ #define _WX_DISPLAY_H_BASE_ +#include "wx/defs.h" + // NB: no #if wxUSE_DISPLAY here, the display geometry part of this class (but // not the video mode stuff) is always available but if wxUSE_DISPLAY == 0 // it becomes just a trivial wrapper around the old wxDisplayXXX() functions From d6793893c044477f8ae55f8f4624f5d4a873956a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 30 Sep 2018 00:29:02 +0200 Subject: [PATCH 08/17] Add a simple benchmark of wxDisplaySize() and related functions This benchmark shows that wxGetDisplaySize() has only minimal overhead compared to wxDisplaySize(), but wxDisplay().GetGeometry() is almost 3 times slower (under wxGTK). --- tests/benchmarks/Makefile.in | 4 +++ tests/benchmarks/bench.bkl | 1 + tests/benchmarks/bench_vc7_bench_gui.vcproj | 3 +++ tests/benchmarks/bench_vc8_bench_gui.vcproj | 4 +++ tests/benchmarks/bench_vc9_bench_gui.vcproj | 4 +++ tests/benchmarks/display.cpp | 30 +++++++++++++++++++++ tests/benchmarks/makefile.bcc | 4 +++ tests/benchmarks/makefile.gcc | 4 +++ tests/benchmarks/makefile.vc | 4 +++ 9 files changed, 58 insertions(+) create mode 100644 tests/benchmarks/display.cpp diff --git a/tests/benchmarks/Makefile.in b/tests/benchmarks/Makefile.in index 401b6e54b8..ab8a00ec9d 100644 --- a/tests/benchmarks/Makefile.in +++ b/tests/benchmarks/Makefile.in @@ -64,6 +64,7 @@ BENCH_GUI_CXXFLAGS = -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \ BENCH_GUI_OBJECTS = \ $(__bench_gui___win32rc) \ bench_gui_bench.o \ + bench_gui_display.o \ bench_gui_image.o BENCH_GRAPHICS_CXXFLAGS = -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \ $(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \ @@ -306,6 +307,9 @@ bench_gui_sample_rc.o: $(srcdir)/../../samples/sample.rc bench_gui_bench.o: $(srcdir)/bench.cpp $(CXXC) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(srcdir)/bench.cpp +bench_gui_display.o: $(srcdir)/display.cpp + $(CXXC) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(srcdir)/display.cpp + bench_gui_image.o: $(srcdir)/image.cpp $(CXXC) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(srcdir)/image.cpp diff --git a/tests/benchmarks/bench.bkl b/tests/benchmarks/bench.bkl index acf774a861..f3efa94295 100644 --- a/tests/benchmarks/bench.bkl +++ b/tests/benchmarks/bench.bkl @@ -36,6 +36,7 @@ bench.cpp + display.cpp image.cpp core diff --git a/tests/benchmarks/bench_vc7_bench_gui.vcproj b/tests/benchmarks/bench_vc7_bench_gui.vcproj index 6556d7d2cf..d5393ca7ff 100644 --- a/tests/benchmarks/bench_vc7_bench_gui.vcproj +++ b/tests/benchmarks/bench_vc7_bench_gui.vcproj @@ -286,6 +286,9 @@ + + diff --git a/tests/benchmarks/bench_vc8_bench_gui.vcproj b/tests/benchmarks/bench_vc8_bench_gui.vcproj index 323f786d9f..fe30ed5fd1 100644 --- a/tests/benchmarks/bench_vc8_bench_gui.vcproj +++ b/tests/benchmarks/bench_vc8_bench_gui.vcproj @@ -810,6 +810,10 @@ RelativePath=".\bench.cpp" > + + diff --git a/tests/benchmarks/bench_vc9_bench_gui.vcproj b/tests/benchmarks/bench_vc9_bench_gui.vcproj index 45fc9f54ac..6f9f17cf00 100644 --- a/tests/benchmarks/bench_vc9_bench_gui.vcproj +++ b/tests/benchmarks/bench_vc9_bench_gui.vcproj @@ -782,6 +782,10 @@ RelativePath=".\bench.cpp" > + + diff --git a/tests/benchmarks/display.cpp b/tests/benchmarks/display.cpp new file mode 100644 index 0000000000..d9ad2cb7d5 --- /dev/null +++ b/tests/benchmarks/display.cpp @@ -0,0 +1,30 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: tests/benchmarks/display.cpp +// Purpose: wxDisplay benchmarks +// Author: Vadim Zeitlin +// Created: 2018-09-30 +// Copyright: (c) 2018 Vadim Zeitlin +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#include "wx/display.h" +#include "wx/gdicmn.h" + +#include "bench.h" + +BENCHMARK_FUNC(DisplaySize) +{ + int w, h; + wxDisplaySize(&w, &h); + return w > 0; +} + +BENCHMARK_FUNC(GetDisplaySize) +{ + return wxGetDisplaySize().x > 0; +} + +BENCHMARK_FUNC(DisplayGetGeometry) +{ + return wxDisplay().GetGeometry().GetSize().x > 0; +} diff --git a/tests/benchmarks/makefile.bcc b/tests/benchmarks/makefile.bcc index b34d95adee..be62ce066f 100644 --- a/tests/benchmarks/makefile.bcc +++ b/tests/benchmarks/makefile.bcc @@ -54,6 +54,7 @@ BENCH_GUI_CXXFLAGS = $(__RUNTIME_LIBS) -I$(BCCDIR)\include $(__DEBUGINFO) \ $(__DLLFLAG_p) -I.\..\..\samples -DNOPCH $(CPPFLAGS) $(CXXFLAGS) BENCH_GUI_OBJECTS = \ $(OBJS)\bench_gui_bench.obj \ + $(OBJS)\bench_gui_display.obj \ $(OBJS)\bench_gui_image.obj BENCH_GRAPHICS_CXXFLAGS = $(__RUNTIME_LIBS) -I$(BCCDIR)\include $(__DEBUGINFO) \ $(__OPTIMIZEFLAG) $(__THREADSFLAG_1) -D__WXMSW__ $(__WXUNIV_DEFINE_p) \ @@ -340,6 +341,9 @@ $(OBJS)\bench_gui_sample.res: .\..\..\samples\sample.rc $(OBJS)\bench_gui_bench.obj: .\bench.cpp $(CXX) -q -c -P -o$@ $(BENCH_GUI_CXXFLAGS) .\bench.cpp +$(OBJS)\bench_gui_display.obj: .\display.cpp + $(CXX) -q -c -P -o$@ $(BENCH_GUI_CXXFLAGS) .\display.cpp + $(OBJS)\bench_gui_image.obj: .\image.cpp $(CXX) -q -c -P -o$@ $(BENCH_GUI_CXXFLAGS) .\image.cpp diff --git a/tests/benchmarks/makefile.gcc b/tests/benchmarks/makefile.gcc index 54948a8494..6546847f3f 100644 --- a/tests/benchmarks/makefile.gcc +++ b/tests/benchmarks/makefile.gcc @@ -49,6 +49,7 @@ BENCH_GUI_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) \ BENCH_GUI_OBJECTS = \ $(OBJS)\bench_gui_sample_rc.o \ $(OBJS)\bench_gui_bench.o \ + $(OBJS)\bench_gui_display.o \ $(OBJS)\bench_gui_image.o BENCH_GRAPHICS_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) \ $(GCCFLAGS) -DHAVE_W32API_H -D__WXMSW__ $(__WXUNIV_DEFINE_p) \ @@ -318,6 +319,9 @@ $(OBJS)\bench_gui_sample_rc.o: ./../../samples/sample.rc $(OBJS)\bench_gui_bench.o: ./bench.cpp $(CXX) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\bench_gui_display.o: ./display.cpp + $(CXX) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\bench_gui_image.o: ./image.cpp $(CXX) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(CPPDEPS) $< diff --git a/tests/benchmarks/makefile.vc b/tests/benchmarks/makefile.vc index 784e045c6c..3dbf2a2da8 100644 --- a/tests/benchmarks/makefile.vc +++ b/tests/benchmarks/makefile.vc @@ -51,6 +51,7 @@ BENCH_GUI_CXXFLAGS = /M$(__RUNTIME_LIBS_26)$(__DEBUGRUNTIME) /DWIN32 \ /DNOPCH /D_CONSOLE $(__RTTIFLAG) $(__EXCEPTIONSFLAG) $(CPPFLAGS) $(CXXFLAGS) BENCH_GUI_OBJECTS = \ $(OBJS)\bench_gui_bench.obj \ + $(OBJS)\bench_gui_display.obj \ $(OBJS)\bench_gui_image.obj BENCH_GUI_RESOURCES = \ $(OBJS)\bench_gui_sample.res @@ -512,6 +513,9 @@ $(OBJS)\bench_gui_sample.res: .\..\..\samples\sample.rc $(OBJS)\bench_gui_bench.obj: .\bench.cpp $(CXX) /c /nologo /TP /Fo$@ $(BENCH_GUI_CXXFLAGS) .\bench.cpp +$(OBJS)\bench_gui_display.obj: .\display.cpp + $(CXX) /c /nologo /TP /Fo$@ $(BENCH_GUI_CXXFLAGS) .\display.cpp + $(OBJS)\bench_gui_image.obj: .\image.cpp $(CXX) /c /nologo /TP /Fo$@ $(BENCH_GUI_CXXFLAGS) .\image.cpp From 990c8bfd733577885baad419025fc0580557ba8c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 30 Sep 2018 00:53:59 +0200 Subject: [PATCH 09/17] Cache wxDisplayImpl object for faster access Avoid a heap allocation on every wxDisplay creation by caching the wxDisplayImpl objects once they're created. Currently we never invalidate the cache, but we should add a way to do it in the future. This speeds up wxDisplay::GetGeometry() benchmark by a factor of 4. --- include/wx/display.h | 1 - include/wx/private/display.h | 31 ++++++++++++++++++++++++++----- src/common/dpycmn.cpp | 16 ++++++++++------ 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/include/wx/display.h b/include/wx/display.h index 1c8d04379d..3213d79d97 100644 --- a/include/wx/display.h +++ b/include/wx/display.h @@ -50,7 +50,6 @@ public: // dtor is not virtual as this is a concrete class not meant to be derived // from - ~wxDisplay(); // return the number of available displays, valid parameters to diff --git a/include/wx/private/display.h b/include/wx/private/display.h index cbaa3a2690..9e0f399c28 100644 --- a/include/wx/private/display.h +++ b/include/wx/private/display.h @@ -11,6 +11,7 @@ #define _WX_PRIVATE_DISPLAY_H_ #include "wx/gdicmn.h" // for wxRect +#include "wx/vector.h" // ---------------------------------------------------------------------------- // wxDisplayFactory: allows to create wxDisplay objects @@ -20,12 +21,20 @@ class WXDLLIMPEXP_CORE wxDisplayFactory { public: wxDisplayFactory() { } - virtual ~wxDisplayFactory() { } + virtual ~wxDisplayFactory(); - // create a new display object - // - // it can return a NULL pointer if the display creation failed - virtual wxDisplayImpl *CreateDisplay(unsigned n) = 0; + // Create the display if necessary using CreateDisplay(), otherwise just + // get it from cache. + wxDisplayImpl* GetDisplay(unsigned n) + { + if ( m_impls.empty() ) + m_impls.resize(GetCount()); + else if ( m_impls[n] ) + return m_impls[n]; + + m_impls[n] = CreateDisplay(n); + return m_impls[n]; + } // get the total number of displays virtual unsigned GetCount() = 0; @@ -37,6 +46,18 @@ public: // // the window pointer must not be NULL (i.e. caller should check it) virtual int GetFromWindow(const wxWindow *window); + +protected: + // create a new display object + // + // it can return a NULL pointer if the display creation failed + virtual wxDisplayImpl *CreateDisplay(unsigned n) = 0; + +private: + // On-demand populated vector of wxDisplayImpl objects. + wxVector m_impls; + + wxDECLARE_NO_COPY_CLASS(wxDisplayFactory); }; // ---------------------------------------------------------------------------- diff --git a/src/common/dpycmn.cpp b/src/common/dpycmn.cpp index 8e14dde43f..9e59f0aeba 100644 --- a/src/common/dpycmn.cpp +++ b/src/common/dpycmn.cpp @@ -118,12 +118,7 @@ wxDisplay::wxDisplay(unsigned n) wxASSERT_MSG( n == 0 || n < GetCount(), wxT("An invalid index was passed to wxDisplay") ); - m_impl = Factory().CreateDisplay(n); -} - -wxDisplay::~wxDisplay() -{ - delete m_impl; + m_impl = Factory().GetDisplay(n); } // ---------------------------------------------------------------------------- @@ -230,6 +225,15 @@ bool wxDisplay::ChangeMode(const wxVideoMode& mode) // wxDisplayFactory implementation // ============================================================================ +wxDisplayFactory::~wxDisplayFactory() +{ + for ( size_t n = 0; n < m_impls.size(); ++n ) + { + // It can be null, that's ok. + delete m_impls[n]; + } +} + int wxDisplayFactory::GetFromWindow(const wxWindow *window) { // consider that the window belongs to the display containing its centre From 1d40b629a2cf61fda0a239e46bae8fd8c89fcd8f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 30 Sep 2018 15:30:53 +0200 Subject: [PATCH 10/17] Remove the unused msw.display.directdraw system option This should have been part of 16e4586527d89f78c665efbc218dc32f7e19c4ca which removed the code this option pertained to. See #12387. --- configure | 8 -------- configure.in | 3 --- interface/wx/sysopt.h | 3 --- samples/display/display.cpp | 7 ------- 4 files changed, 21 deletions(-) diff --git a/configure b/configure index 47205af945..30fed661f2 100755 --- a/configure +++ b/configure @@ -27521,14 +27521,6 @@ fi $as_echo "$as_me: WARNING: Xinerama not found; disabling wxDisplay" >&2;} wxUSE_DISPLAY="no" fi - elif test "$wxUSE_MSW" = 1; then - ac_fn_c_check_header_compile "$LINENO" "ddraw.h" "ac_cv_header_ddraw_h" "#include -" -if test "x$ac_cv_header_ddraw_h" = xyes; then : - -fi - - fi fi diff --git a/configure.in b/configure.in index 4ffb373d47..91a36fedd6 100644 --- a/configure.in +++ b/configure.in @@ -3472,9 +3472,6 @@ if test "$wxUSE_DISPLAY" = "yes"; then AC_MSG_WARN([Xinerama not found; disabling wxDisplay]) wxUSE_DISPLAY="no" fi - elif test "$wxUSE_MSW" = 1; then - dnl DirectDraw for MSW - optionally used by WxDisplay. - AC_CHECK_HEADER([ddraw.h], [], [], [#include ]) fi fi diff --git a/interface/wx/sysopt.h b/interface/wx/sysopt.h index cb789b3c04..47ac09624d 100644 --- a/interface/wx/sysopt.h +++ b/interface/wx/sysopt.h @@ -66,9 +66,6 @@ Setting this to 0 causes more flicker, but allows applications to paint graphics on the parent of a static box (the optimized refresh causes any such drawing to disappear). - @flag{msw.display.directdraw} - If set to 1, use DirectDraw-based implementation of wxDisplay. - By default the standard Win32 functions are used. @flag{msw.font.no-proof-quality} If set to 1, use default fonts quality instead of proof quality when creating fonts. With proof quality the fonts have slightly better diff --git a/samples/display/display.cpp b/samples/display/display.cpp index 4f4be39b64..5ecdcfbb9b 100644 --- a/samples/display/display.cpp +++ b/samples/display/display.cpp @@ -170,13 +170,6 @@ bool MyApp::OnInit() if ( !wxApp::OnInit() ) return false; -#ifdef __WXMSW__ - if ( argc == 2 && !wxStricmp(argv[1], "/dx") ) - { - wxSystemOptions::SetOption("msw.display.directdraw", 1); - } -#endif // __WXMSW__ - // create the main application window MyFrame *frame = new MyFrame(_("Display wxWidgets Sample"), wxDefaultPosition, wxDefaultSize); From 58a1ee1633df30f50878fc2c55768d2c946192fd Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 30 Sep 2018 15:36:40 +0200 Subject: [PATCH 11/17] Show the result of wxDisplay::IsPrimary() in the sample too Just add a quick test of this function. --- samples/display/display.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/samples/display/display.cpp b/samples/display/display.cpp index 5ecdcfbb9b..a362ac0255 100644 --- a/samples/display/display.cpp +++ b/samples/display/display.cpp @@ -278,6 +278,10 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, sizer->Add(new wxStaticText(page, wxID_ANY, "Name: ")); sizer->Add(new wxStaticText(page, wxID_ANY, display.GetName())); + sizer->Add(new wxStaticText(page, wxID_ANY, "Primary: ")); + sizer->Add(new wxStaticText(page, wxID_ANY, + display.IsPrimary() ? "yes" : "no")); + wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL); sizerTop->Add(sizer, 1, wxALL | wxEXPAND, 10); From 6883cd4b960b209ea2189fdec271850be53c6442 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 30 Sep 2018 15:37:46 +0200 Subject: [PATCH 12/17] Fix harmless variable shadowing warning in the display sample Use different names to avoid warning C4456 given by MSVC 14. --- samples/display/display.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/display/display.cpp b/samples/display/display.cpp index a362ac0255..7c97a54c34 100644 --- a/samples/display/display.cpp +++ b/samples/display/display.cpp @@ -235,8 +235,8 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, wxPanel *panel = new wxPanel(this, wxID_ANY); m_book = new wxBookCtrl(panel, wxID_ANY); - const size_t count = wxDisplay::GetCount(); - for ( size_t nDpy = 0; nDpy < count; nDpy++ ) + const size_t countDpy = wxDisplay::GetCount(); + for ( size_t nDpy = 0; nDpy < countDpy; nDpy++ ) { wxDisplay display(nDpy); @@ -288,8 +288,8 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, #if wxUSE_DISPLAY wxChoice *choiceModes = new wxChoice(page, Display_ChangeMode); const wxArrayVideoModes modes = display.GetModes(); - const size_t count = modes.GetCount(); - for ( size_t nMode = 0; nMode < count; nMode++ ) + const size_t countModes = modes.GetCount(); + for ( size_t nMode = 0; nMode < countModes; nMode++ ) { const wxVideoMode& mode = modes[nMode]; From 771e01cc731ccd4185b7f38595bdbbc5aa56493d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 30 Sep 2018 16:59:40 +0200 Subject: [PATCH 13/17] Remove unnecessary trivial wxDisplayFactoryQt default ctor No real changes, just remove useless lines. --- src/qt/display.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/qt/display.cpp b/src/qt/display.cpp index 6e2fa75774..a5d1d829dd 100644 --- a/src/qt/display.cpp +++ b/src/qt/display.cpp @@ -67,18 +67,11 @@ bool wxDisplayImplQt::ChangeMode(const wxVideoMode& WXUNUSED(mode)) class wxDisplayFactoryQt : public wxDisplayFactory { public: - wxDisplayFactoryQt(); - virtual wxDisplayImpl *CreateDisplay(unsigned n) wxOVERRIDE; virtual unsigned GetCount() wxOVERRIDE; virtual int GetFromPoint(const wxPoint& pt) wxOVERRIDE; }; - -wxDisplayFactoryQt::wxDisplayFactoryQt() -{ -} - wxDisplayImpl *wxDisplayFactoryQt::CreateDisplay(unsigned n) { return new wxDisplayImplQt( n ); From c98d504b6d636365fd7543d74bcb646eecfc5d17 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 30 Sep 2018 17:06:34 +0200 Subject: [PATCH 14/17] Implement wxDisplay::GetClientArea() for wxQt too This is as simple as implementing GetGeometry(), so just do it. --- src/qt/display.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/qt/display.cpp b/src/qt/display.cpp index a5d1d829dd..9a39545451 100644 --- a/src/qt/display.cpp +++ b/src/qt/display.cpp @@ -20,6 +20,8 @@ public: wxDisplayImplQt( unsigned n ); virtual wxRect GetGeometry() const wxOVERRIDE; + virtual wxRect GetClientArea() const wxOVERRIDE; + virtual wxString GetName() const wxOVERRIDE; virtual wxArrayVideoModes GetModes(const wxVideoMode& mode) const wxOVERRIDE; @@ -37,6 +39,11 @@ wxRect wxDisplayImplQt::GetGeometry() const return wxQtConvertRect( QApplication::desktop()->screenGeometry( GetIndex() )); } +wxRect wxDisplayImplQt::GetClientArea() const +{ + return wxQtConvertRect( QApplication::desktop()->availableGeometry( GetIndex() )); +} + wxString wxDisplayImplQt::GetName() const { return wxString(); From c2162792cf24f2d59024bd06a921fd1ffde4f937 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 29 Sep 2018 22:18:02 +0200 Subject: [PATCH 15/17] Implement wxDisplaySize() and wxClientDisplayRect() via wxDisplay Instead of forwarding to these functions from wxDisplay implementation in wxUSE_DISPLAY==0 case, make the functions themselves wrappers around wxDisplay, which may, or not, depending on the platform, have a simpler implementation in wxUSE_DISPLAY==0 case, but is always available in any case. As part of this change, only use src/osx/core/display.cpp in macOS builds, not iOS ones and update the Xcode project accordingly too. This cuts down on code duplication, especially in wxGTK, and facilitates further additions to wxDisplay API. --- Makefile.in | 53 +++----- build/bakefiles/files.bkl | 2 +- build/cmake/files.cmake | 2 +- build/files | 2 +- build/osx/wxiphone.xcodeproj/project.pbxproj | 4 - include/wx/private/display.h | 52 +++++++- src/common/dpycmn.cpp | 62 +--------- src/common/gdicmn.cpp | 32 ++++- src/dfb/utils.cpp | 44 ++++--- src/gtk/display.cpp | 122 +++++++++---------- src/gtk/utilsgtk.cpp | 16 --- src/motif/utils.cpp | 11 -- src/msw/display.cpp | 60 ++++++--- src/msw/utilsgui.cpp | 11 -- src/osx/cocoa/utils.mm | 14 +-- src/osx/core/display.cpp | 68 ++++++++--- src/osx/iphone/utils.mm | 90 ++++++-------- src/osx/utils_osx.cpp | 11 -- src/qt/display.cpp | 24 ++++ src/qt/utils.cpp | 18 --- src/unix/displayx11.cpp | 91 +++++++++----- src/x11/utils.cpp | 11 -- 22 files changed, 406 insertions(+), 394 deletions(-) diff --git a/Makefile.in b/Makefile.in index 342a4d4a29..66087484d8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -3783,7 +3783,6 @@ COND_USE_GUI_1_ALL_GUI_HEADERS = \ wx/dialup.h \ wx/dirctrl.h \ wx/display.h \ - wx/display_impl.h \ wx/dnd.h \ wx/docmdi.h \ wx/docview.h \ @@ -5606,7 +5605,8 @@ COND_TOOLKIT_OSX_COCOA___GUI_SRC_OBJECTS = \ monodll_timectrl_osx.o \ monodll_taskbarcmn.o \ monodll_cocoa_activityindicator.o \ - monodll_cocoa_statbmp.o + monodll_cocoa_statbmp.o \ + monodll_core_display.o @COND_TOOLKIT_OSX_COCOA@__GUI_SRC_OBJECTS = $(COND_TOOLKIT_OSX_COCOA___GUI_SRC_OBJECTS) COND_TOOLKIT_OSX_IPHONE___GUI_SRC_OBJECTS = \ $(__OSX_COMMON_SRC_OBJECTS) \ @@ -7571,7 +7571,8 @@ COND_TOOLKIT_OSX_COCOA___GUI_SRC_OBJECTS_1 = \ monolib_timectrl_osx.o \ monolib_taskbarcmn.o \ monolib_cocoa_activityindicator.o \ - monolib_cocoa_statbmp.o + monolib_cocoa_statbmp.o \ + monolib_core_display.o @COND_TOOLKIT_OSX_COCOA@__GUI_SRC_OBJECTS_1 = $(COND_TOOLKIT_OSX_COCOA___GUI_SRC_OBJECTS_1) COND_TOOLKIT_OSX_IPHONE___GUI_SRC_OBJECTS_1 = \ $(__OSX_COMMON_SRC_OBJECTS_0) \ @@ -9683,7 +9684,8 @@ COND_TOOLKIT_OSX_COCOA___GUI_SRC_OBJECTS_2 = \ coredll_timectrl_osx.o \ coredll_taskbarcmn.o \ coredll_cocoa_activityindicator.o \ - coredll_cocoa_statbmp.o + coredll_cocoa_statbmp.o \ + coredll_core_display.o @COND_TOOLKIT_OSX_COCOA@__GUI_SRC_OBJECTS_2 = $(COND_TOOLKIT_OSX_COCOA___GUI_SRC_OBJECTS_2) COND_TOOLKIT_OSX_IPHONE___GUI_SRC_OBJECTS_2 = \ $(__OSX_COMMON_SRC_OBJECTS_8) \ @@ -11390,7 +11392,8 @@ COND_TOOLKIT_OSX_COCOA___GUI_SRC_OBJECTS_3 = \ corelib_timectrl_osx.o \ corelib_taskbarcmn.o \ corelib_cocoa_activityindicator.o \ - corelib_cocoa_statbmp.o + corelib_cocoa_statbmp.o \ + corelib_core_display.o @COND_TOOLKIT_OSX_COCOA@__GUI_SRC_OBJECTS_3 = $(COND_TOOLKIT_OSX_COCOA___GUI_SRC_OBJECTS_3) COND_TOOLKIT_OSX_IPHONE___GUI_SRC_OBJECTS_3 = \ $(__OSX_COMMON_SRC_OBJECTS_9) \ @@ -13193,7 +13196,6 @@ COND_PLATFORM_MACOSX_1___OSX_LOWLEVEL_SRC_OBJECTS = \ monodll_core_bitmap.o \ monodll_core_colour.o \ monodll_core_dcmemory.o \ - monodll_core_display.o \ monodll_core_fontenum.o \ monodll_hid.o \ monodll_printmac.o \ @@ -13337,7 +13339,6 @@ COND_PLATFORM_MACOSX_1___OSX_LOWLEVEL_SRC_OBJECTS_17 = \ monolib_core_bitmap.o \ monolib_core_colour.o \ monolib_core_dcmemory.o \ - monolib_core_display.o \ monolib_core_fontenum.o \ monolib_hid.o \ monolib_printmac.o \ @@ -13481,7 +13482,6 @@ COND_PLATFORM_MACOSX_1___OSX_LOWLEVEL_SRC_OBJECTS_1_1 = \ coredll_core_bitmap.o \ coredll_core_colour.o \ coredll_core_dcmemory.o \ - coredll_core_display.o \ coredll_core_fontenum.o \ coredll_hid.o \ coredll_printmac.o \ @@ -13622,7 +13622,6 @@ COND_PLATFORM_MACOSX_1___OSX_LOWLEVEL_SRC_OBJECTS_1_4 = \ corelib_core_bitmap.o \ corelib_core_colour.o \ corelib_core_dcmemory.o \ - corelib_core_display.o \ corelib_core_fontenum.o \ corelib_hid.o \ corelib_printmac.o \ @@ -16471,6 +16470,9 @@ monodll_cocoa_activityindicator.o: $(srcdir)/src/osx/cocoa/activityindicator.mm monodll_cocoa_statbmp.o: $(srcdir)/src/osx/cocoa/statbmp.mm $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/statbmp.mm +monodll_core_display.o: $(srcdir)/src/osx/core/display.cpp $(MONODLL_ODEP) + $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/core/display.cpp + monodll_regiong.o: $(srcdir)/src/generic/regiong.cpp $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/generic/regiong.cpp @@ -18748,12 +18750,6 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@monodll_core_dcmemory.o: $(srcdir)/src/osx/core/dcmemory.cpp $(MONODLL_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/core/dcmemory.cpp -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@monodll_core_display.o: $(srcdir)/src/osx/core/display.cpp $(MONODLL_ODEP) -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/core/display.cpp - -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@monodll_core_display.o: $(srcdir)/src/osx/core/display.cpp $(MONODLL_ODEP) -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/core/display.cpp - @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@monodll_core_fontenum.o: $(srcdir)/src/osx/core/fontenum.cpp $(MONODLL_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/core/fontenum.cpp @@ -21721,6 +21717,9 @@ monolib_cocoa_activityindicator.o: $(srcdir)/src/osx/cocoa/activityindicator.mm monolib_cocoa_statbmp.o: $(srcdir)/src/osx/cocoa/statbmp.mm $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/statbmp.mm +monolib_core_display.o: $(srcdir)/src/osx/core/display.cpp $(MONOLIB_ODEP) + $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/core/display.cpp + monolib_regiong.o: $(srcdir)/src/generic/regiong.cpp $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/generic/regiong.cpp @@ -23998,12 +23997,6 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@monolib_core_dcmemory.o: $(srcdir)/src/osx/core/dcmemory.cpp $(MONOLIB_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/core/dcmemory.cpp -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@monolib_core_display.o: $(srcdir)/src/osx/core/display.cpp $(MONOLIB_ODEP) -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/core/display.cpp - -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@monolib_core_display.o: $(srcdir)/src/osx/core/display.cpp $(MONOLIB_ODEP) -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/core/display.cpp - @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@monolib_core_fontenum.o: $(srcdir)/src/osx/core/fontenum.cpp $(MONOLIB_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/core/fontenum.cpp @@ -27634,6 +27627,9 @@ coredll_cocoa_activityindicator.o: $(srcdir)/src/osx/cocoa/activityindicator.mm coredll_cocoa_statbmp.o: $(srcdir)/src/osx/cocoa/statbmp.mm $(COREDLL_ODEP) $(CXXC) -c -o $@ $(COREDLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/statbmp.mm +coredll_core_display.o: $(srcdir)/src/osx/core/display.cpp $(COREDLL_ODEP) + $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/core/display.cpp + coredll_regiong.o: $(srcdir)/src/generic/regiong.cpp $(COREDLL_ODEP) $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/generic/regiong.cpp @@ -29341,12 +29337,6 @@ coredll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(COREDLL_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@coredll_core_dcmemory.o: $(srcdir)/src/osx/core/dcmemory.cpp $(COREDLL_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/core/dcmemory.cpp -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@coredll_core_display.o: $(srcdir)/src/osx/core/display.cpp $(COREDLL_ODEP) -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/core/display.cpp - -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@coredll_core_display.o: $(srcdir)/src/osx/core/display.cpp $(COREDLL_ODEP) -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/core/display.cpp - @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@coredll_core_fontenum.o: $(srcdir)/src/osx/core/fontenum.cpp $(COREDLL_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/core/fontenum.cpp @@ -31879,6 +31869,9 @@ corelib_cocoa_activityindicator.o: $(srcdir)/src/osx/cocoa/activityindicator.mm corelib_cocoa_statbmp.o: $(srcdir)/src/osx/cocoa/statbmp.mm $(CORELIB_ODEP) $(CXXC) -c -o $@ $(CORELIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/statbmp.mm +corelib_core_display.o: $(srcdir)/src/osx/core/display.cpp $(CORELIB_ODEP) + $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/core/display.cpp + corelib_regiong.o: $(srcdir)/src/generic/regiong.cpp $(CORELIB_ODEP) $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/generic/regiong.cpp @@ -33586,12 +33579,6 @@ corelib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(CORELIB_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@corelib_core_dcmemory.o: $(srcdir)/src/osx/core/dcmemory.cpp $(CORELIB_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/core/dcmemory.cpp -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@corelib_core_display.o: $(srcdir)/src/osx/core/display.cpp $(CORELIB_ODEP) -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/core/display.cpp - -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@corelib_core_display.o: $(srcdir)/src/osx/core/display.cpp $(CORELIB_ODEP) -@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/core/display.cpp - @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@corelib_core_fontenum.o: $(srcdir)/src/osx/core/fontenum.cpp $(CORELIB_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/core/fontenum.cpp diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index 80b3217f79..1ed7be89a5 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -2381,7 +2381,6 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/osx/core/bitmap.cpp src/osx/core/colour.cpp src/osx/core/dcmemory.cpp - src/osx/core/display.cpp src/osx/core/fontenum.cpp src/osx/core/hid.cpp src/osx/core/printmac.cpp @@ -2628,6 +2627,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/common/taskbarcmn.cpp src/osx/cocoa/activityindicator.mm src/osx/cocoa/statbmp.mm + src/osx/core/display.cpp wx/osx/cocoa/chkconf.h diff --git a/build/cmake/files.cmake b/build/cmake/files.cmake index 5af3d5ac77..5b80c492bd 100644 --- a/build/cmake/files.cmake +++ b/build/cmake/files.cmake @@ -2258,7 +2258,6 @@ set(OSX_LOWLEVEL_SRC src/osx/core/bitmap.cpp src/osx/core/colour.cpp src/osx/core/dcmemory.cpp - src/osx/core/display.cpp src/osx/core/fontenum.cpp src/osx/core/hid.cpp src/osx/core/printmac.cpp @@ -2500,6 +2499,7 @@ set(OSX_COCOA_SRC src/osx/datectrl_osx.cpp src/osx/core/sound.cpp src/osx/cocoa/statbmp.mm + src/osx/core/display.cpp ) set(OSX_COCOA_HDR diff --git a/build/files b/build/files index abe00f1361..1150ec1f6e 100644 --- a/build/files +++ b/build/files @@ -2246,7 +2246,6 @@ OSX_LOWLEVEL_SRC = src/osx/core/bitmap.cpp src/osx/core/colour.cpp src/osx/core/dcmemory.cpp - src/osx/core/display.cpp src/osx/core/fontenum.cpp src/osx/core/hid.cpp src/osx/core/printmac.cpp @@ -2477,6 +2476,7 @@ OSX_COCOA_SRC = src/osx/cocoa/toolbar.mm src/osx/cocoa/tooltip.mm src/osx/cocoa/window.mm + src/osx/core/display.cpp src/osx/core/hidjoystick.cpp src/osx/core/sound.cpp src/osx/dataview_osx.cpp diff --git a/build/osx/wxiphone.xcodeproj/project.pbxproj b/build/osx/wxiphone.xcodeproj/project.pbxproj index 422f721df1..0b90d8c331 100644 --- a/build/osx/wxiphone.xcodeproj/project.pbxproj +++ b/build/osx/wxiphone.xcodeproj/project.pbxproj @@ -803,7 +803,6 @@ F0B3F484C38C3BA0B9927CD9 /* docmdi.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ECC9F5C21ACB31A0B24AEE35 /* docmdi.cpp */; }; F0D892C2618130FEAD46BB86 /* panel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 00969CBE3B8F32C78C195619 /* panel.cpp */; }; F1E4D7CA634E33808AE3B522 /* fontenumcmn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 373242CD08F330208A7CF438 /* fontenumcmn.cpp */; }; - F1F484DD591337399FCD0463 /* display.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5617D10CB7136EC9A4194EF /* display.cpp */; }; F22C401903993639AE05A295 /* xh_stbox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 147800BBCB80346798B35D75 /* xh_stbox.cpp */; }; F24F637D59F637CA9A7E23C9 /* xh_filectrl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 60EE4448A28D38F5ADE17B5A /* xh_filectrl.cpp */; }; F2813BF297C73A3ABD02EC98 /* glcanvas_osx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA59091E3ED83FB781FB9659 /* glcanvas_osx.cpp */; }; @@ -1402,7 +1401,6 @@ A46D50BEBF523B3F88831086 /* LexAsn1.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = LexAsn1.cxx; path = ../../src/stc/scintilla/lexers/LexAsn1.cxx; sourceTree = ""; }; A4A745D1821A32D591D76650 /* imagiff.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = imagiff.cpp; path = ../../src/common/imagiff.cpp; sourceTree = ""; }; A54B80C17F823CB5900AD2E8 /* framecmn.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = framecmn.cpp; path = ../../src/common/framecmn.cpp; sourceTree = ""; }; - A5617D10CB7136EC9A4194EF /* display.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = display.cpp; path = ../../src/osx/core/display.cpp; sourceTree = ""; }; A5794CD687013AF8A20A691A /* headerctrlcmn.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = headerctrlcmn.cpp; path = ../../src/common/headerctrlcmn.cpp; sourceTree = ""; }; A57CF60203F53459A03951A9 /* arrstr.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = arrstr.cpp; path = ../../src/common/arrstr.cpp; sourceTree = ""; }; A5BBC1E494D33D028CA547FF /* jddctmgr.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = jddctmgr.c; path = ../../src/jpeg/jddctmgr.c; sourceTree = ""; }; @@ -1953,7 +1951,6 @@ A1A53EC3A3463EFDB7614E93 /* bitmap.cpp */, 9D1F14339D1C331087650931 /* colour.cpp */, 343D4FDD5CC030618EF24729 /* dcmemory.cpp */, - A5617D10CB7136EC9A4194EF /* display.cpp */, 36E1DBA275AD325DB759C180 /* fontenum.cpp */, 160EB9744CB63A0B81DC651F /* hid.cpp */, 5CC5C13F8AA1387BADB7E60C /* printmac.cpp */, @@ -3008,7 +3005,6 @@ 03BF1610E2FC3BD5ACB754F0 /* bitmap.cpp in Sources */, FF50EC0EC5F23DF890C6E95F /* colour.cpp in Sources */, BD2B17EB72E73A6EB6E0B26F /* dcmemory.cpp in Sources */, - F1F484DD591337399FCD0463 /* display.cpp in Sources */, 371809DA4AD1382F8B532878 /* fontenum.cpp in Sources */, 86BE5213D3F131D8A6862679 /* hid.cpp in Sources */, AB58406CEBA13BC4A2A83B66 /* printmac.cpp in Sources */, diff --git a/include/wx/private/display.h b/include/wx/private/display.h index 9e0f399c28..2635758fe8 100644 --- a/include/wx/private/display.h +++ b/include/wx/private/display.h @@ -10,6 +10,7 @@ #ifndef _WX_PRIVATE_DISPLAY_H_ #define _WX_PRIVATE_DISPLAY_H_ +#include "wx/display.h" #include "wx/gdicmn.h" // for wxRect #include "wx/vector.h" @@ -112,18 +113,63 @@ protected: wxDECLARE_NO_COPY_CLASS(wxDisplayImpl); }; +// ---------------------------------------------------------------------------- +// wxDisplayImplSingle: the simplest possible impl for the main display only +// ---------------------------------------------------------------------------- + +// Note that this is still an ABC and GetGeometry() and GetClientArea() methods +// must be implemented in the derived classes. + +class WXDLLEXPORT wxDisplayImplSingle : public wxDisplayImpl +{ +public: + wxDisplayImplSingle() : wxDisplayImpl(0) { } + + virtual wxString GetName() const wxOVERRIDE { return wxString(); } + +#if wxUSE_DISPLAY + // no video modes support for us, provide just the stubs + virtual wxArrayVideoModes + GetModes(const wxVideoMode& WXUNUSED(mode)) const wxOVERRIDE + { + return wxArrayVideoModes(); + } + + virtual wxVideoMode GetCurrentMode() const wxOVERRIDE + { + return wxVideoMode(); + } + + virtual bool ChangeMode(const wxVideoMode& WXUNUSED(mode)) wxOVERRIDE + { + return false; + } +#endif // wxUSE_DISPLAY + + wxDECLARE_NO_COPY_CLASS(wxDisplayImplSingle); +}; + // ---------------------------------------------------------------------------- // wxDisplayFactorySingle // ---------------------------------------------------------------------------- -// this is a stub implementation using single/main display only, it is -// available even if wxUSE_DISPLAY == 0 +// This is the simplest implementation of wxDisplayFactory using single/main +// display only. It is used when wxUSE_DISPLAY == 0 because getting the size of +// the main display is always needed. +// +// Note that this is still an ABC and derived classes must implement +// CreateSingleDisplay(). + class WXDLLIMPEXP_CORE wxDisplayFactorySingle : public wxDisplayFactory { public: - virtual wxDisplayImpl *CreateDisplay(unsigned n) wxOVERRIDE; virtual unsigned GetCount() wxOVERRIDE { return 1; } virtual int GetFromPoint(const wxPoint& pt) wxOVERRIDE; + +protected: + virtual wxDisplayImpl *CreateDisplay(unsigned n) wxOVERRIDE; + + virtual wxDisplayImpl *CreateSingleDisplay() = 0; }; #endif // _WX_PRIVATE_DISPLAY_H_ diff --git a/src/common/dpycmn.cpp b/src/common/dpycmn.cpp index 9e59f0aeba..cd49ae60ec 100644 --- a/src/common/dpycmn.cpp +++ b/src/common/dpycmn.cpp @@ -29,7 +29,6 @@ #include "wx/module.h" #endif //WX_PRECOMP -#include "wx/display.h" #include "wx/private/display.h" #if wxUSE_DISPLAY @@ -50,43 +49,6 @@ const wxVideoMode wxDefaultVideoMode; // created on demand and destroyed by wxDisplayModule static wxDisplayFactory *gs_factory = NULL; -// ---------------------------------------------------------------------------- -// wxDisplayImplSingle: trivial implementation working for main display only -// ---------------------------------------------------------------------------- - -class WXDLLEXPORT wxDisplayImplSingle : public wxDisplayImpl -{ -public: - wxDisplayImplSingle() : wxDisplayImpl(0) { } - - virtual wxRect GetGeometry() const wxOVERRIDE - { - wxRect r; - wxDisplaySize(&r.width, &r.height); - return r; - } - - virtual wxRect GetClientArea() const wxOVERRIDE { return wxGetClientDisplayRect(); } - - virtual wxString GetName() const wxOVERRIDE { return wxString(); } - -#if wxUSE_DISPLAY - // no video modes support for us, provide just the stubs - - virtual wxArrayVideoModes GetModes(const wxVideoMode& WXUNUSED(mode)) const wxOVERRIDE - { - return wxArrayVideoModes(); - } - - virtual wxVideoMode GetCurrentMode() const wxOVERRIDE { return wxVideoMode(); } - - virtual bool ChangeMode(const wxVideoMode& WXUNUSED(mode)) wxOVERRIDE { return false; } -#endif // wxUSE_DISPLAY - - - wxDECLARE_NO_COPY_CLASS(wxDisplayImplSingle); -}; - // ---------------------------------------------------------------------------- // wxDisplayModule is used to cleanup gs_factory // ---------------------------------------------------------------------------- @@ -201,16 +163,6 @@ bool wxDisplay::ChangeMode(const wxVideoMode& mode) // static functions implementation // ---------------------------------------------------------------------------- -// if wxUSE_DISPLAY == 1 this is implemented in port-specific code -#if !wxUSE_DISPLAY - -/* static */ wxDisplayFactory *wxDisplay::CreateFactory() -{ - return new wxDisplayFactorySingle; -} - -#endif // !wxUSE_DISPLAY - /* static */ wxDisplayFactory& wxDisplay::Factory() { if ( !gs_factory ) @@ -248,20 +200,10 @@ int wxDisplayFactory::GetFromWindow(const wxWindow *window) wxDisplayImpl *wxDisplayFactorySingle::CreateDisplay(unsigned n) { // we recognize the main display only - return n != 0 ? NULL : new wxDisplayImplSingle; + return n != 0 ? NULL : CreateSingleDisplay(); } int wxDisplayFactorySingle::GetFromPoint(const wxPoint& pt) { - if ( pt.x >= 0 && pt.y >= 0 ) - { - int w, h; - wxDisplaySize(&w, &h); - - if ( pt.x < w && pt.y < h ) - return 0; - } - - // the point is outside of the screen - return wxNOT_FOUND; + return wxDisplay().GetGeometry().Contains(pt) ? 0 : wxNOT_FOUND; } diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index 6d16a12d60..771db4ac72 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -16,6 +16,8 @@ #endif #include "wx/gdicmn.h" + +#include "wx/display.h" #include "wx/gdiobj.h" #ifndef WX_PRECOMP @@ -843,18 +845,36 @@ wxFont *wxFontList::FindOrCreateFont(int pointSize, return font; } +void wxDisplaySize(int *width, int *height) +{ + const wxSize size = wxGetDisplaySize(); + if ( width ) + *width = size.x; + if ( height ) + *height = size.y; +} + wxSize wxGetDisplaySize() { - int x, y; - wxDisplaySize(& x, & y); - return wxSize(x, y); + return wxDisplay().GetGeometry().GetSize(); +} + +void wxClientDisplayRect(int *x, int *y, int *width, int *height) +{ + const wxRect rect = wxGetClientDisplayRect(); + if ( x ) + *x = rect.x; + if ( y ) + *y = rect.y; + if ( width ) + *width = rect.width; + if ( height ) + *height = rect.height; } wxRect wxGetClientDisplayRect() { - int x, y, width, height; - wxClientDisplayRect(&x, &y, &width, &height); // call plat-specific version - return wxRect(x, y, width, height); + return wxDisplay().GetClientArea(); } wxSize wxGetDisplaySizeMM() diff --git a/src/dfb/utils.cpp b/src/dfb/utils.cpp index 57e9a3d1a1..76c84a5c50 100644 --- a/src/dfb/utils.cpp +++ b/src/dfb/utils.cpp @@ -17,6 +17,7 @@ #include "wx/utils.h" #include "wx/evtloop.h" #include "wx/apptrait.h" +#include "wx/private/display.h" #include "wx/unix/private/timer.h" #ifndef WX_PRECOMP @@ -56,6 +57,33 @@ wxTimerImpl *wxGUIAppTraits::CreateTimerImpl(wxTimer *timer) // display characteristics // ---------------------------------------------------------------------------- +// TODO: move into a separate src/dfb/display.cpp + +class wxDisplayImplSingleDFB : public wxDisplayImplSingle +{ +public: + virtual wxRect GetGeometry() const wxOVERRIDE + { + const wxVideoMode mode(wxTheApp->GetDisplayMode()); + + return wxRect(0, 0, mode.w, mode.h); + } +}; + +class wxDisplayFactorySingleDFB : public wxDisplayFactorySingle +{ +protected: + virtual wxDisplayImpl *CreateSingleDisplay() + { + return new wxDisplayImplSingleDFB; + } +}; + +wxDisplayFactory* wxDisplay::CreateFactory() +{ + return new wxDisplayFactorySingleDFB; +} + bool wxColourDisplay() { #warning "FIXME: wxColourDisplay" @@ -67,13 +95,6 @@ int wxDisplayDepth() return wxTheApp->GetDisplayMode().bpp; } -void wxDisplaySize(int *width, int *height) -{ - wxVideoMode mode(wxTheApp->GetDisplayMode()); - if ( width ) *width = mode.w; - if ( height ) *height = mode.h; -} - void wxDisplaySizeMM(int *width, int *height) { // FIXME: there's no way to get physical resolution using the DirectDB @@ -89,15 +110,6 @@ void wxDisplaySizeMM(int *width, int *height) #undef PX_TO_MM } -void wxClientDisplayRect(int *x, int *y, int *width, int *height) -{ - // return desktop dimensions minus any panels, menus, trays: - if (x) *x = 0; - if (y) *y = 0; - wxDisplaySize(width, height); -} - - //----------------------------------------------------------------------------- // mouse //----------------------------------------------------------------------------- diff --git a/src/gtk/display.cpp b/src/gtk/display.cpp index cc00c499dd..eb68667724 100644 --- a/src/gtk/display.cpp +++ b/src/gtk/display.cpp @@ -8,11 +8,7 @@ #include "wx/wxprec.h" -#if wxUSE_DISPLAY - #include "wx/display.h" - #include "wx/private/display.h" -#endif -#include "wx/utils.h" // wxClientDisplayRect +#include "wx/private/display.h" #include "wx/gtk/private/wrapgtk.h" #ifdef GDK_WINDOWING_X11 @@ -75,61 +71,6 @@ wx_gdk_screen_get_monitor_workarea(GdkScreen* screen, int monitor, GdkRectangle* #endif // !__WXGTK4__ -void wxClientDisplayRect(int* x, int* y, int* width, int* height) -{ - GdkRectangle rect; - GdkWindow* window = wxGetTopLevelGDK(); -#ifdef __WXGTK4__ - GdkMonitor* monitor = - gdk_display_get_monitor_at_window(gdk_window_get_display(window), window); - gdk_monitor_get_workarea(monitor, &rect); -#else - GdkScreen* screen = gdk_window_get_screen(window); - wxGCC_WARNING_SUPPRESS(deprecated-declarations) - int monitor = gdk_screen_get_monitor_at_window(screen, window); - gdk_screen_get_monitor_workarea(screen, monitor, &rect); - wxGCC_WARNING_RESTORE() -#endif - if (x) - *x = rect.x; - if (y) - *y = rect.y; - if (width) - *width = rect.width; - if (height) - *height = rect.height; -} -//----------------------------------------------------------------------------- - -#if wxUSE_DISPLAY -class wxDisplayFactoryGTK: public wxDisplayFactory -{ -public: - virtual wxDisplayImpl* CreateDisplay(unsigned n) wxOVERRIDE; - virtual unsigned GetCount() wxOVERRIDE; - virtual int GetFromPoint(const wxPoint& pt) wxOVERRIDE; -}; - -class wxDisplayImplGTK: public wxDisplayImpl -{ - typedef wxDisplayImpl base_type; -public: - wxDisplayImplGTK(unsigned i); - virtual wxRect GetGeometry() const wxOVERRIDE; - virtual wxRect GetClientArea() const wxOVERRIDE; - virtual wxString GetName() const wxOVERRIDE; - virtual bool IsPrimary() const wxOVERRIDE; - virtual wxArrayVideoModes GetModes(const wxVideoMode& mode) const wxOVERRIDE; - virtual wxVideoMode GetCurrentMode() const wxOVERRIDE; - virtual bool ChangeMode(const wxVideoMode& mode) wxOVERRIDE; -#ifdef __WXGTK4__ - GdkMonitor* const m_monitor; -#else - GdkScreen* const m_screen; -#endif -}; -//----------------------------------------------------------------------------- - #ifdef __WXGTK4__ static inline GdkDisplay* GetDisplay() { @@ -142,6 +83,45 @@ static inline GdkScreen* GetScreen() } #endif +//----------------------------------------------------------------------------- + +// This class is always defined as it's used for the main display even when +// wxUSE_DISPLAY == 0. +class wxDisplayImplGTK : public wxDisplayImpl +{ + typedef wxDisplayImpl base_type; +public: + wxDisplayImplGTK(unsigned i); + virtual wxRect GetGeometry() const wxOVERRIDE; + virtual wxRect GetClientArea() const wxOVERRIDE; + +#if wxUSE_DISPLAY + virtual wxString GetName() const wxOVERRIDE; + virtual bool IsPrimary() const wxOVERRIDE; + virtual wxArrayVideoModes GetModes(const wxVideoMode& mode) const wxOVERRIDE; + virtual wxVideoMode GetCurrentMode() const wxOVERRIDE; + virtual bool ChangeMode(const wxVideoMode& mode) wxOVERRIDE; +#endif // wxUSE_DISPLAY + +#ifdef __WXGTK4__ + GdkMonitor* const m_monitor; +#else + GdkScreen* const m_screen; +#endif +}; + +//----------------------------------------------------------------------------- + +// This class is only defined when we're built with full display support. +#if wxUSE_DISPLAY +class wxDisplayFactoryGTK: public wxDisplayFactory +{ +public: + virtual wxDisplayImpl* CreateDisplay(unsigned n) wxOVERRIDE; + virtual unsigned GetCount() wxOVERRIDE; + virtual int GetFromPoint(const wxPoint& pt) wxOVERRIDE; +}; + wxDisplayImpl* wxDisplayFactoryGTK::CreateDisplay(unsigned n) { return new wxDisplayImplGTK(n); @@ -185,6 +165,8 @@ int wxDisplayFactoryGTK::GetFromPoint(const wxPoint& pt) return monitor; #endif } +#endif // wxUSE_DISPLAY + //----------------------------------------------------------------------------- wxDisplayImplGTK::wxDisplayImplGTK(unsigned i) @@ -223,6 +205,7 @@ wxRect wxDisplayImplGTK::GetClientArea() const return wxRect(rect.x, rect.y, rect.width, rect.height); } +#if wxUSE_DISPLAY wxString wxDisplayImplGTK::GetName() const { return wxString(); @@ -307,6 +290,23 @@ wxDisplayFactory* wxDisplay::CreateFactory() { return new wxDisplayFactoryGTK; } -#endif // wxUSE_DISPLAY + +#else // !wxUSE_DISPLAY + +class wxDisplayFactorySingleGTK : public wxDisplayFactorySingle +{ +protected: + virtual wxDisplayImpl *CreateSingleDisplay() + { + return new wxDisplayImplGTK(0); + } +}; + +wxDisplayFactory* wxDisplay::CreateFactory() +{ + return wxDisplayFactorySingleGTK; +} + +#endif // wxUSE_DISPLAY/!wxUSE_DISPLAY #endif // !defined(GDK_WINDOWING_WIN32) diff --git a/src/gtk/utilsgtk.cpp b/src/gtk/utilsgtk.cpp index 7cdbd871c8..31a1d9a9ea 100644 --- a/src/gtk/utilsgtk.cpp +++ b/src/gtk/utilsgtk.cpp @@ -76,22 +76,6 @@ void *wxGetDisplay() } #endif -void wxDisplaySize( int *width, int *height ) -{ -#ifdef __WXGTK4__ - GdkMonitor* monitor = gdk_display_get_primary_monitor(gdk_display_get_default()); - GdkRectangle rect; - gdk_monitor_get_geometry(monitor, &rect); - if (width) *width = rect.width; - if (height) *height = rect.height; -#else - wxGCC_WARNING_SUPPRESS(deprecated-declarations) - if (width) *width = gdk_screen_width(); - if (height) *height = gdk_screen_height(); - wxGCC_WARNING_RESTORE() -#endif -} - void wxDisplaySizeMM( int *width, int *height ) { #ifdef __WXGTK4__ diff --git a/src/motif/utils.cpp b/src/motif/utils.cpp index d440bb0887..16c52e86a8 100644 --- a/src/motif/utils.cpp +++ b/src/motif/utils.cpp @@ -239,17 +239,6 @@ int wxDisplayDepth() return DefaultDepth (dpy, DefaultScreen (dpy)); } -// Get size of display -void wxDisplaySize(int *width, int *height) -{ - Display *dpy = wxGlobalDisplay(); - - if ( width ) - *width = DisplayWidth (dpy, DefaultScreen (dpy)); - if ( height ) - *height = DisplayHeight (dpy, DefaultScreen (dpy)); -} - void wxDisplaySizeMM(int *width, int *height) { Display *dpy = wxGlobalDisplay(); diff --git a/src/msw/display.cpp b/src/msw/display.cpp index b096d1895d..771cb32132 100644 --- a/src/msw/display.cpp +++ b/src/msw/display.cpp @@ -24,11 +24,46 @@ #pragma hdrstop #endif +#include "wx/private/display.h" + +#include "wx/msw/private.h" #include "wx/msw/wrapwin.h" -#if wxUSE_DISPLAY +// This implementation is always available, whether wxUSE_DISPLAY is 1 or not, +// as we fall back to it in case of error. +class wxDisplayImplSingleMSW : public wxDisplayImplSingle +{ +public: + virtual wxRect GetGeometry() const wxOVERRIDE + { + ScreenHDC dc; -#include "wx/display.h" + return wxRect(0, 0, + ::GetDeviceCaps(dc, HORZRES), + ::GetDeviceCaps(dc, VERTRES)); + } + + virtual wxRect GetClientArea() const wxOVERRIDE + { + RECT rc; + SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0); + + wxRect rectClient; + wxCopyRECTToRect(rc, rectClient); + return rectClient; + } +}; + +class wxDisplayFactorySingleMSW : public wxDisplayFactorySingle +{ +protected: + virtual wxDisplayImpl *CreateSingleDisplay() wxOVERRIDE + { + return new wxDisplayImplSingleMSW; + } +}; + +#if wxUSE_DISPLAY #ifndef WX_PRECOMP #include "wx/dynarray.h" @@ -39,9 +74,7 @@ #include "wx/dynlib.h" #include "wx/sysopt.h" -#include "wx/private/display.h" #include "wx/msw/missing.h" -#include "wx/msw/private.h" #include "wx/msw/private/hiddenwin.h" static const wxChar displayDllName[] = wxT("user32.dll"); @@ -170,7 +203,7 @@ wxDisplayFactoryMSW* wxDisplayFactoryMSW::ms_factory = NULL; delete factoryMM; // fall back to a stub implementation if no multimon support (Win95?) - return new wxDisplayFactorySingle; + return new wxDisplayFactorySingleMSW; } @@ -507,17 +540,12 @@ int wxDisplayFactoryMSW::GetFromWindow(const wxWindow *window) #endif } -#endif // wxUSE_DISPLAY +#else // !wxUSE_DISPLAY -void wxClientDisplayRect(int *x, int *y, int *width, int *height) +// In this case, wxDisplayFactorySingleMSW is the only implementation. +wxDisplayFactory* wxDisplay::CreateFactory() { - // Determine the desktop dimensions minus the taskbar and any other - // special decorations... - RECT r; - - SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0); - if (x) *x = r.left; - if (y) *y = r.top; - if (width) *width = r.right - r.left; - if (height) *height = r.bottom - r.top; + return new wxDisplayFactorySingleMSW; } + +#endif // wxUSE_DISPLAY/!wxUSE_DISPLAY diff --git a/src/msw/utilsgui.cpp b/src/msw/utilsgui.cpp index 98e985d6e1..1ebbd36259 100644 --- a/src/msw/utilsgui.cpp +++ b/src/msw/utilsgui.cpp @@ -145,17 +145,6 @@ int wxDisplayDepth() return GetDeviceCaps(dc, PLANES) * GetDeviceCaps(dc, BITSPIXEL); } -// Get size of display -void wxDisplaySize(int *width, int *height) -{ - ScreenHDC dc; - - if ( width ) - *width = ::GetDeviceCaps(dc, HORZRES); - if ( height ) - *height = ::GetDeviceCaps(dc, VERTRES); -} - void wxDisplaySizeMM(int *width, int *height) { ScreenHDC dc; diff --git a/src/osx/cocoa/utils.mm b/src/osx/cocoa/utils.mm index 4e83ce9036..d41809fd1a 100644 --- a/src/osx/cocoa/utils.mm +++ b/src/osx/cocoa/utils.mm @@ -484,19 +484,11 @@ void wxApp::DoCleanUp() } } -void wxClientDisplayRect(int *x, int *y, int *width, int *height) +extern // used from src/osx/core/display.cpp +wxRect wxOSXGetMainDisplayClientArea() { NSRect displayRect = [wxOSXGetMenuScreen() visibleFrame]; - wxRect r = wxFromNSRect( NULL, displayRect ); - if ( x ) - *x = r.x; - if ( y ) - *y = r.y; - if ( width ) - *width = r.GetWidth(); - if ( height ) - *height = r.GetHeight(); - + return wxFromNSRect( NULL, displayRect ); } void wxGetMousePosition( int* x, int* y ) diff --git a/src/osx/core/display.cpp b/src/osx/core/display.cpp index 679312274b..fedbfb7d10 100644 --- a/src/osx/core/display.cpp +++ b/src/osx/core/display.cpp @@ -22,9 +22,7 @@ #pragma hdrstop #endif -#if wxUSE_DISPLAY - -#include "wx/display.h" +#include "wx/private/display.h" #ifndef WX_PRECOMP #include "wx/dynarray.h" @@ -33,11 +31,32 @@ #include "wx/gdicmn.h" #endif -#include "wx/private/display.h" -#include "wx/scopedarray.h" #include "wx/osx/private.h" -#if wxOSX_USE_COCOA_OR_CARBON +// ---------------------------------------------------------------------------- +// common helpers compiled even in wxUSE_DISPLAY==0 case +// ---------------------------------------------------------------------------- + +// This one is defined in Objective C++ code. +extern wxRect wxOSXGetMainDisplayClientArea(); + +namespace +{ + +wxRect wxGetDisplayGeometry(CGDirectDisplayID id) +{ + CGRect theRect = CGDisplayBounds(id); + return wxRect( (int)theRect.origin.x, + (int)theRect.origin.y, + (int)theRect.size.width, + (int)theRect.size.height ); //floats +} + +} // anonymous namespace + +#if wxUSE_DISPLAY + +#include "wx/scopedarray.h" // ---------------------------------------------------------------------------- // display classes implementation @@ -197,11 +216,7 @@ bool wxDisplayImplMacOSX::IsPrimary() const wxRect wxDisplayImplMacOSX::GetGeometry() const { - CGRect theRect = CGDisplayBounds(m_id); - return wxRect( (int)theRect.origin.x, - (int)theRect.origin.y, - (int)theRect.size.width, - (int)theRect.size.height ); //floats + return wxGetDisplayGeometry(m_id); } wxRect wxDisplayImplMacOSX::GetClientArea() const @@ -210,7 +225,7 @@ wxRect wxDisplayImplMacOSX::GetClientArea() const // wxGetClientDisplayRect() does work correctly for at least the main // one (TODO: do it correctly for the other displays too) if ( IsPrimary() ) - return wxGetClientDisplayRect(); + return wxOSXGetMainDisplayClientArea(); return wxDisplayImpl::GetClientArea(); } @@ -311,13 +326,34 @@ bool wxDisplayImplMacOSX::ChangeMode( const wxVideoMode& mode ) return new wxDisplayFactoryMacOSX; } -#else +#else // !wxUSE_DISPLAY + +class wxDisplayImplSingleMacOSX : public wxDisplayImplSingle +{ +public: + virtual wxRect GetGeometry() const wxOVERRIDE + { + return wxGetDisplayGeometry(CGMainDisplayID()); + } + + virtual wxRect GetClientArea() const wxOVERRIDE + { + return wxOSXGetMainDisplayClientArea(); + } +}; + +class wxDisplayFactorySingleMacOSX : public wxDisplayFactorySingle +{ +protected: + virtual wxDisplayImpl *CreateSingleDisplay() wxOVERRIDE + { + return new wxDisplayImplSingleMacOSX; + } +}; /* static */ wxDisplayFactory *wxDisplay::CreateFactory() { - return new wxDisplayFactorySingle; + return new wxDisplayFactorySingleMacOSX; } -#endif - #endif // wxUSE_DISPLAY diff --git a/src/osx/iphone/utils.mm b/src/osx/iphone/utils.mm index 92b2540149..f4cdcf47fc 100644 --- a/src/osx/iphone/utils.mm +++ b/src/osx/iphone/utils.mm @@ -25,6 +25,8 @@ #include "wx/apptrait.h" +#include "wx/private/display.h" + #include "wx/osx/private.h" #if wxUSE_GUI @@ -116,46 +118,6 @@ CFArrayRef CopyAvailableFontFamilyNames() return (CFArrayRef) [[UIFont familyNames] retain]; } -void wxClientDisplayRect(int *x, int *y, int *width, int *height) -{ -#if 0 - CGRect r = [[UIScreen mainScreen] applicationFrame]; - CGRect bounds = [[UIScreen mainScreen] bounds]; - if ( bounds.size.height > r.size.height ) - { - // portrait - if ( x ) - *x = r.origin.x; - if ( y ) - *y = r.origin.y; - if ( width ) - *width = r.size.width; - if ( height ) - *height = r.size.height; - } - else - { - // landscape - if ( x ) - *x = r.origin.y; - if ( y ) - *y = r.origin.x; - if ( width ) - *width = r.size.height; - if ( height ) - *height = r.size.width; - } -#else - // it's easier to treat the status bar as an element of the toplevel window - // instead of the desktop in order to support easy rotation - if ( x ) - *x = 0; - if ( y ) - *y = 0; - wxDisplaySize(width, height); -#endif -} - void wxGetMousePosition( int* x, int* y ) { if ( x ) @@ -177,26 +139,44 @@ int wxDisplayDepth() } // Get size of display -void wxDisplaySize(int *width, int *height) -{ - CGRect bounds = [[UIScreen mainScreen] bounds]; - if ( UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation]) ) +class wxDisplayImplSingleiOS : public wxDisplayImplSingle +{ +public: + virtual wxRect GetGeometry() const wxOVERRIDE { - // portrait - if ( width ) - *width = (int)bounds.size.width ; - if ( height ) - *height = (int)bounds.size.height; + CGRect bounds = [[UIScreen mainScreen] bounds]; + + int width, height; + if ( UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation]) ) + { + // portrait + width = (int)bounds.size.width ; + height = (int)bounds.size.height; + } + else + { + // landscape + width = (int)bounds.size.height ; + height = (int)bounds.size.width; + } + + return wxRect(0, 0, width, height); } - else +}; + +class wxDisplayFactorySingleiOS : public wxDisplayFactorySingle +{ +protected: + virtual wxDisplayImpl *CreateSingleDisplay() wxOVERRIDE { - // landscape - if ( width ) - *width = (int)bounds.size.height ; - if ( height ) - *height = (int)bounds.size.width; + return new wxDisplayImplSingleiOS; } +}; + +/* static */ wxDisplayFactory *wxDisplay::CreateFactory() +{ + return new wxDisplayFactorySingleiOS; } wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer *timer) diff --git a/src/osx/utils_osx.cpp b/src/osx/utils_osx.cpp index bccc71b132..6860b5e088 100644 --- a/src/osx/utils_osx.cpp +++ b/src/osx/utils_osx.cpp @@ -87,17 +87,6 @@ int wxDisplayDepth() return theDepth; } -// Get size of display -void wxDisplaySize(int *width, int *height) -{ - // TODO adapt for multi-displays - CGRect bounds = CGDisplayBounds(CGMainDisplayID()); - if ( width ) - *width = (int)bounds.size.width ; - if ( height ) - *height = (int)bounds.size.height; -} - #if wxUSE_GUI // ---------------------------------------------------------------------------- diff --git a/src/qt/display.cpp b/src/qt/display.cpp index 9a39545451..abf339321c 100644 --- a/src/qt/display.cpp +++ b/src/qt/display.cpp @@ -24,9 +24,11 @@ public: virtual wxString GetName() const wxOVERRIDE; +#if wxUSE_DISPLAY virtual wxArrayVideoModes GetModes(const wxVideoMode& mode) const wxOVERRIDE; virtual wxVideoMode GetCurrentMode() const wxOVERRIDE; virtual bool ChangeMode(const wxVideoMode& mode) wxOVERRIDE; +#endif // wxUSE_DISPLAY }; wxDisplayImplQt::wxDisplayImplQt( unsigned n ) @@ -49,6 +51,7 @@ wxString wxDisplayImplQt::GetName() const return wxString(); } +#if wxUSE_DISPLAY wxArrayVideoModes wxDisplayImplQt::GetModes(const wxVideoMode& WXUNUSED(mode)) const { return wxArrayVideoModes(); @@ -67,10 +70,13 @@ bool wxDisplayImplQt::ChangeMode(const wxVideoMode& WXUNUSED(mode)) { return false; } +#endif // wxUSE_DISPLAY //############################################################################## +#if wxUSE_DISPLAY + class wxDisplayFactoryQt : public wxDisplayFactory { public: @@ -100,3 +106,21 @@ int wxDisplayFactoryQt::GetFromPoint(const wxPoint& pt) { return new wxDisplayFactoryQt; } + +#else // wxUSE_DISPLAY + +class wxDisplayFactorySingleQt : public wxDisplayFactorySingleQt +{ +protected: + virtual wxDisplayImpl *CreateSingleDisplay() wxOVERRIDE + { + return new wxDisplayImplQt(0); + } +}; + +/* static */ wxDisplayFactory *wxDisplay::CreateFactory() +{ + return new wxDisplayFactorySingleQt; +} + +#endif // wxUSE_DISPLAY/!wxUSE_DISPLAY diff --git a/src/qt/utils.cpp b/src/qt/utils.cpp index f1e9db341b..92957b8683 100644 --- a/src/qt/utils.cpp +++ b/src/qt/utils.cpp @@ -115,14 +115,6 @@ int wxDisplayDepth() return QApplication::desktop()->depth(); } -void wxDisplaySize(int *width, int *height) -{ - if ( width != NULL ) - *width = QApplication::desktop()->width(); - if ( height != NULL ) - *height = QApplication::desktop()->height(); -} - void wxDisplaySizeMM(int *width, int *height) { if ( width != NULL ) @@ -136,16 +128,6 @@ void wxBell() QApplication::beep(); } -void wxClientDisplayRect(int *x, int *y, int *width, int *height) -{ - QRect r = QApplication::desktop()->availableGeometry(); - - *x = r.x(); - *y = r.y(); - *width = r.width(); - *height = r.height(); -} - wxWindow *wxGetActiveWindow() { QWidget *w = QApplication::activeWindow(); diff --git a/src/unix/displayx11.cpp b/src/unix/displayx11.cpp index 5c740ef4b0..93113a4886 100644 --- a/src/unix/displayx11.cpp +++ b/src/unix/displayx11.cpp @@ -37,13 +37,45 @@ #include #endif -#if wxUSE_DISPLAY - -#include "wx/display.h" #include "wx/private/display.h" #ifndef __WXGTK20__ +static wxRect wxGetMainScreenWorkArea(); + +class wxDisplayImplSingleX11 : public wxDisplayImplSingle +{ +public: + virtual wxRect GetGeometry() const wxOVERRIDE + { + Display* const dpy = wxGetX11Display(); + + return wxRect(0, 0, + DisplayWidth(dpy, DefaultScreen (dpy)), + DisplayHeight(dpy, DefaultScreen (dpy))); + } + + virtual wxRect GetClientArea() const wxOVERRIDE + { + return wxGetMainScreenWorkArea(); + } +}; + +class wxDisplayFactorySingleX11 : public wxDisplayFactorySingle +{ +protected: + virtual wxDisplayImpl *CreateSingleDisplay() + { + return new wxDisplayImplSingleX11; + } +}; + +#endif // !__WXGTK20__ + +#if wxUSE_DISPLAY + +#ifndef __WXGTK20__ + #include typedef XineramaScreenInfo ScreenInfo; @@ -97,7 +129,7 @@ public: // we intentionally don't cache the result here because the client // display area may change (e.g. the user resized or hid a panel) and // we don't currently react to its changes - return IsPrimary() ? wxGetClientDisplayRect() : m_rect; + return IsPrimary() ? wxGetMainScreenWorkArea() : m_rect; } virtual wxString GetName() const wxOVERRIDE { return wxString(); } @@ -347,13 +379,20 @@ bool wxDisplayImplX11::ChangeMode(const wxVideoMode& WXUNUSED(mode)) /* static */ wxDisplayFactory *wxDisplay::CreateFactory() { if ( !XineramaIsActive((Display*)wxGetDisplay()) ) - return new wxDisplayFactorySingle; + return new wxDisplayFactorySingleX11; return new wxDisplayFactoryX11; } #endif -#endif /* wxUSE_DISPLAY */ +#else // !wxUSE_DISPLAY + +/* static */ wxDisplayFactory *wxDisplay::CreateFactory() +{ + return new wxDisplayFactorySingleX11; +} + +#endif // wxUSE_DISPLAY/!wxUSE_DISPLAY #if !defined(__WXGTK20__) || defined(GDK_WINDOWING_X11) void wxGetWorkAreaX11(Screen* screen, int& x, int& y, int& width, int& height) @@ -388,45 +427,33 @@ void wxGetWorkAreaX11(Screen* screen, int& x, int& y, int& width, int& height) #ifndef __WXGTK20__ -void wxClientDisplayRect(int *x, int *y, int *width, int *height) +wxRect wxGetMainScreenWorkArea() { + wxRect rect; + Display * const dpy = wxGetX11Display(); - wxCHECK_RET( dpy, wxT("can't be called before initializing the GUI") ); + wxCHECK_MSG( dpy, rect, "can't be called before initializing the GUI" ); - wxRect rectClient; wxGetWorkAreaX11(DefaultScreenOfDisplay(dpy), - rectClient.x, rectClient.y, rectClient.width, rectClient.height); + rect.x, rect.y, rect.width, rect.height); - // Although _NET_WORKAREA is supposed to return the client size of the - // screen, not all implementations are conforming, apparently, see #14419, - // so make sure we return a subset of the primary display. - wxRect rectFull; -#if wxUSE_DISPLAY - ScreensInfo screens; - const ScreenInfo& info = screens[0]; - rectFull = wxRect(info.x_org, info.y_org, info.width, info.height); -#else - wxDisplaySize(&rectFull.width, &rectFull.height); -#endif + const wxRect rectFull = wxDisplay().GetGeometry(); - if ( !rectClient.width || !rectClient.height ) + if ( !rect.width || !rect.height ) { // _NET_WORKAREA not available or didn't work, fall back to the total // display size. - rectClient = rectFull; + rect = rectFull; } else { - rectClient = rectClient.Intersect(rectFull); + // Although _NET_WORKAREA is supposed to return the client size of the + // screen, not all implementations are conforming, apparently, see + // #14419, so make sure we return a subset of the primary display. + rect = rect.Intersect(rectFull); } - if ( x ) - *x = rectClient.x; - if ( y ) - *y = rectClient.y; - if ( width ) - *width = rectClient.width; - if ( height ) - *height = rectClient.height; + return rect; } + #endif // !__WXGTK20__ diff --git a/src/x11/utils.cpp b/src/x11/utils.cpp index bd80ba5769..4312a3da8e 100644 --- a/src/x11/utils.cpp +++ b/src/x11/utils.cpp @@ -162,17 +162,6 @@ int wxDisplayDepth() return DefaultDepth (dpy, DefaultScreen (dpy)); } -// Get size of display -void wxDisplaySize(int *width, int *height) -{ - Display *dpy = (Display*) wxGetDisplay(); - - if ( width ) - *width = DisplayWidth (dpy, DefaultScreen (dpy)); - if ( height ) - *height = DisplayHeight (dpy, DefaultScreen (dpy)); -} - void wxDisplaySizeMM(int *width, int *height) { Display *dpy = (Display*) wxGetDisplay(); From ddc88b74b6b75e3a8d19627425cb5500b52a79be Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 30 Sep 2018 18:09:00 +0200 Subject: [PATCH 16/17] Remove unnecessary DLL export declarations for private classes wxDisplayFactory and wxDisplayImpl don't have to be exported from the wxWidgets shared libraries and, in fact, shouldn't be. --- include/wx/private/display.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/wx/private/display.h b/include/wx/private/display.h index 2635758fe8..d1346fc4eb 100644 --- a/include/wx/private/display.h +++ b/include/wx/private/display.h @@ -18,7 +18,7 @@ // wxDisplayFactory: allows to create wxDisplay objects // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDisplayFactory +class wxDisplayFactory { public: wxDisplayFactory() { } @@ -65,7 +65,7 @@ private: // wxDisplayImpl: base class for all wxDisplay implementations // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxDisplayImpl +class wxDisplayImpl { public: // virtual dtor for this base class @@ -160,7 +160,7 @@ public: // Note that this is still an ABC and derived classes must implement // CreateSingleDisplay(). -class WXDLLIMPEXP_CORE wxDisplayFactorySingle : public wxDisplayFactory +class wxDisplayFactorySingle : public wxDisplayFactory { public: virtual unsigned GetCount() wxOVERRIDE { return 1; } From 0263ebfacaface453eec831201da4fd53063bd4a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 30 Sep 2018 22:11:29 +0200 Subject: [PATCH 17/17] Remove duplicate wx/wxprec.h inclusion from wxiOSX code No real changes, just remove an unnecessary #include. --- src/osx/iphone/utils.mm | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/osx/iphone/utils.mm b/src/osx/iphone/utils.mm index f4cdcf47fc..2136055e74 100644 --- a/src/osx/iphone/utils.mm +++ b/src/osx/iphone/utils.mm @@ -10,8 +10,6 @@ #include "wx/wxprec.h" -#include "wx/wxprec.h" - #include "wx/utils.h" #ifndef WX_PRECOMP