From 6f02c3a8978d390846b1b8ace0ad70723d492561 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Tue, 29 Oct 2019 00:33:43 +0100 Subject: [PATCH 1/5] Add DPI Awareness option to CMake For VS solutions, the DPI aware manifest is added as additional manifest. For makefiles, the DPI aware manifest is included via the resource file. Set the default DPI Awareness to per-monitor. --- build/cmake/functions.cmake | 20 +++++++++++ build/cmake/options.cmake | 4 +++ include/wx/msw/amd64-dpi-aware-pmv2.manifest | 35 ++++++++++++++++++++ include/wx/msw/amd64-dpi-aware.manifest | 34 +++++++++++++++++++ include/wx/msw/wx-dpi-aware-pmv2.manifest | 35 ++++++++++++++++++++ include/wx/msw/wx-dpi-aware.manifest | 34 +++++++++++++++++++ include/wx/msw/wx.rc | 23 +++++++++---- 7 files changed, 179 insertions(+), 6 deletions(-) create mode 100644 include/wx/msw/amd64-dpi-aware-pmv2.manifest create mode 100644 include/wx/msw/amd64-dpi-aware.manifest create mode 100644 include/wx/msw/wx-dpi-aware-pmv2.manifest create mode 100644 include/wx/msw/wx-dpi-aware.manifest diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake index 13b861e20d..7d772546da 100644 --- a/build/cmake/functions.cmake +++ b/build/cmake/functions.cmake @@ -658,7 +658,27 @@ function(wx_add_sample name) else() set(exe_type WIN32 MACOSX_BUNDLE) endif() + + if (WXMSW AND DEFINED wxUSE_DPI_AWARE_MANIFEST) + set(wxDPI_MANIFEST_PRFIX "wx") + if (wxARCH_SUFFIX) + set(wxDPI_MANIFEST_PRFIX "amd64") + endif() + set(wxUSE_DPI_AWARE_MANIFEST_VALUE 0) + if (${wxUSE_DPI_AWARE_MANIFEST} MATCHES "system") + set(wxUSE_DPI_AWARE_MANIFEST_VALUE 1) + list(APPEND src_files "${wxSOURCE_DIR}/include/wx/msw/${wxDPI_MANIFEST_PRFIX}-dpi-aware.manifest") + elseif(${wxUSE_DPI_AWARE_MANIFEST} MATCHES "per-monitor") + set(wxUSE_DPI_AWARE_MANIFEST_VALUE 2) + list(APPEND src_files "${wxSOURCE_DIR}/include/wx/msw/${wxDPI_MANIFEST_PRFIX}-dpi-aware-pmv2.manifest") + endif() + endif() + add_executable(${target_name} ${exe_type} ${src_files}) + + if (DEFINED wxUSE_DPI_AWARE_MANIFEST_VALUE) + target_compile_definitions(${target_name} PRIVATE wxUSE_DPI_AWARE_MANIFEST=${wxUSE_DPI_AWARE_MANIFEST_VALUE}) + endif() endif() # All samples use at least the base library other libraries # will have to be added with wx_link_sample_libraries() diff --git a/build/cmake/options.cmake b/build/cmake/options.cmake index d86c47cc26..c9196f766e 100644 --- a/build/cmake/options.cmake +++ b/build/cmake/options.cmake @@ -23,6 +23,10 @@ wx_option(wxBUILD_COMPATIBILITY set(wxBUILD_CUSTOM_SETUP_HEADER_PATH "" CACHE PATH "Include path containing custom wx/setup.h") mark_as_advanced(wxBUILD_CUSTOM_SETUP_HEADER_PATH) +if(WIN32) + wx_option(wxUSE_DPI_AWARE_MANIFEST "DPI Awareness" "per-monitor" STRINGS "none" "system" "per-monitor") +endif() + wx_option(wxBUILD_DEBUG_LEVEL "Debug Level" Default STRINGS Default 0 1 2) mark_as_advanced(wxBUILD_DEBUG_LEVEL) diff --git a/include/wx/msw/amd64-dpi-aware-pmv2.manifest b/include/wx/msw/amd64-dpi-aware-pmv2.manifest new file mode 100644 index 0000000000..09588bff37 --- /dev/null +++ b/include/wx/msw/amd64-dpi-aware-pmv2.manifest @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + PerMonitorV2, system + true + + + + + + + + + + + + + + + + + diff --git a/include/wx/msw/amd64-dpi-aware.manifest b/include/wx/msw/amd64-dpi-aware.manifest new file mode 100644 index 0000000000..c2170185ac --- /dev/null +++ b/include/wx/msw/amd64-dpi-aware.manifest @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + diff --git a/include/wx/msw/wx-dpi-aware-pmv2.manifest b/include/wx/msw/wx-dpi-aware-pmv2.manifest new file mode 100644 index 0000000000..efbb36f994 --- /dev/null +++ b/include/wx/msw/wx-dpi-aware-pmv2.manifest @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + PerMonitorV2, system + true + + + + + + + + + + + + + + + + + diff --git a/include/wx/msw/wx-dpi-aware.manifest b/include/wx/msw/wx-dpi-aware.manifest new file mode 100644 index 0000000000..95c5a992b2 --- /dev/null +++ b/include/wx/msw/wx-dpi-aware.manifest @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + diff --git a/include/wx/msw/wx.rc b/include/wx/msw/wx.rc index f71bb61e0a..799d79ca24 100644 --- a/include/wx/msw/wx.rc +++ b/include/wx/msw/wx.rc @@ -100,17 +100,17 @@ wxBITMAP_STD_COLOURS BITMAP "wx/msw/colours.bmp" // see "about isolated applications" topic in MSDN #ifdef ISOLATION_AWARE_ENABLED -#define wxMANIFEST_ID 2 + #define wxMANIFEST_ID ISOLATIONAWARE_MANIFEST_RESOURCE_ID #else -#define wxMANIFEST_ID 1 + #define wxMANIFEST_ID CREATEPROCESS_MANIFEST_RESOURCE_ID #endif #if defined(WX_CPU_AMD64) -wxMANIFEST_ID 24 "wx/msw/amd64.manifest" + #define wxMANIFEST_CPU "amd64" #elif defined(WX_CPU_IA64) -wxMANIFEST_ID 24 "wx/msw/ia64.manifest" + #define wxMANIFEST_CPU "ia64" #elif defined(WX_CPU_X86) -wxMANIFEST_ID 24 "wx/msw/wx.manifest" + #define wxMANIFEST_CPU "wx" #else // Notice that if the manifest is included, WX_CPU_XXX constant corresponding // to the architecture we're compiling for must be defined. This can be done @@ -118,9 +118,20 @@ wxMANIFEST_ID 24 "wx/msw/wx.manifest" // compiler paths to search in $(WXWIN)/lib/$(COMPILER_PREFIX)_lib/mswu[d] // directory for its include files, as wx/msw/rcdefs.h file in this directory // is generated during wxWidgets build and contains the correct definition. -#error "One of WX_CPU_XXX constants must be defined. See comment above." + #error "One of WX_CPU_XXX constants must be defined. See comment above." #endif +#if !defined(wxUSE_DPI_AWARE_MANIFEST) || wxUSE_DPI_AWARE_MANIFEST == 0 + #define wxMANIFEST_DPI "" +#elif wxUSE_DPI_AWARE_MANIFEST == 1 + #define wxMANIFEST_DPI "-dpi-aware" +#elif wxUSE_DPI_AWARE_MANIFEST == 2 + #define wxMANIFEST_DPI "-dpi-aware-pmv2" +#endif + +#define wxMANIFEST_FILE "wx/msw/" wxMANIFEST_CPU wxMANIFEST_DPI ".manifest" +wxMANIFEST_ID RT_MANIFEST wxMANIFEST_FILE + #endif // wxUSE_RC_MANIFEST #endif // !defined(wxUSE_NO_MANIFEST) || (wxUSE_NO_MANIFEST == 0) From cdf122657394390ebcc45e6f4c0e2bf4a90adc4a Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Tue, 29 Oct 2019 00:33:53 +0100 Subject: [PATCH 2/5] Add DPI Awareness option to configure and bakefile Add option --with-dpi=[none,system,per-monitor] to configure the dpi awareness on Windows. Support DPI Awareness in makefile.gcc and makefile.bcc. The default DPI awareness is set to per-monitor. --- build/bakefiles/common.bkl | 5 +++++ build/bakefiles/config.bkl | 8 ++++++++ configure | 19 +++++++++++++++++++ configure.in | 15 +++++++++++++++ 4 files changed, 47 insertions(+) diff --git a/build/bakefiles/common.bkl b/build/bakefiles/common.bkl index 1fe539ad02..ac89850f6a 100644 --- a/build/bakefiles/common.bkl +++ b/build/bakefiles/common.bkl @@ -303,6 +303,10 @@ _WIN32_WINNT=0x0400 + + wxUSE_DPI_AWARE_MANIFEST=$(USE_DPI_AWARE_MANIFEST) + + cairo @@ -343,6 +347,7 @@ $(NO_VC_CRTDBG) $(WIN32_WINNT) + $(WIN32_DPI_MANIFEST) $(LINK_TARGET_CPU) diff --git a/build/bakefiles/config.bkl b/build/bakefiles/config.bkl index 4562c8abaa..65a7e8f9fc 100644 --- a/build/bakefiles/config.bkl +++ b/build/bakefiles/config.bkl @@ -327,6 +327,14 @@ Default is to use debug CRT if and only if BUILD==debug. + +