WIXFEAT:6204 Use the new DpiAwareness attribute on BootstrapperApplication element to control the DPI awareness settings in the bundle's application manifest.
Sean Hall committed
Jul 19, 2020 at 16:19 UTC
414c07f7adce9c9fd0132ab0fade0267f743f665
3 files changed
+98
-9
src/WixToolset.Core.Burn/Bundles/CreateBundleExeCommand.cs
+52
-7
@@ -107,6 +107,8 @@ namespace WixToolset.Core.Burn.Bundles
107
const string asmv3Namespace = "urn:schemas-microsoft-com:asm.v3";
108
const string compatv1Namespace = "urn:schemas-microsoft-com:compatibility.v1";
109
const string ws2005Namespace = "http://schemas.microsoft.com/SMI/2005/WindowsSettings";
110
+ const string ws2016Namespace = "http://schemas.microsoft.com/SMI/2016/WindowsSettings";
111
+ const string ws2017Namespace = "http://schemas.microsoft.com/SMI/2017/WindowsSettings";
112
113
var bundleFileName = Path.GetFileName(outputPath);
114
var bundleAssemblyVersion = windowsAssemblyVersion.ToString();
@@ -181,13 +183,56 @@ namespace WixToolset.Core.Burn.Bundles
183
writer.WriteEndElement(); // </security>
184
writer.WriteEndElement(); // </trustInfo>
185
184
- writer.WriteStartElement("application", asmv3Namespace);
185
- writer.WriteStartElement("windowsSettings");
186
- writer.WriteStartElement("dpiAware", ws2005Namespace);
187
- writer.WriteString("true");
188
- writer.WriteEndElement(); // </application>
189
- writer.WriteEndElement(); // </windowSettings>
190
- writer.WriteEndElement(); // </dpiAware>
186
+ if (bootstrapperApplicationSymbol.DpiAwareness != WixBootstrapperApplicationDpiAwarenessType.Unaware)
187
+ {
188
+ string dpiAwareValue = null;
189
+ string dpiAwarenessValue = null;
190
+ string gdiScalingValue = null;
191
+
192
+ switch(bootstrapperApplicationSymbol.DpiAwareness)
193
+ {
194
+ case WixBootstrapperApplicationDpiAwarenessType.GdiScaled:
195
+ gdiScalingValue = "true";
196
+ break;
197
+ case WixBootstrapperApplicationDpiAwarenessType.PerMonitor:
198
+ dpiAwareValue = "true/pm";
199
+ break;
200
+ case WixBootstrapperApplicationDpiAwarenessType.PerMonitorV2:
201
+ dpiAwareValue = "true/pm";
202
+ dpiAwarenessValue = "PerMonitorV2, PerMonitor";
203
+ break;
204
+ case WixBootstrapperApplicationDpiAwarenessType.System:
205
+ dpiAwareValue = "true";
206
+ break;
207
+ }
208
+
209
+ writer.WriteStartElement("application", asmv3Namespace);
210
+ writer.WriteStartElement("windowsSettings");
211
+
212
+ if (dpiAwareValue != null)
213
+ {
214
+ writer.WriteStartElement("dpiAware", ws2005Namespace);
215
+ writer.WriteString(dpiAwareValue);
216
+ writer.WriteEndElement();
217
+ }
218
+
219
+ if (dpiAwarenessValue != null)
220
+ {
221
+ writer.WriteStartElement("dpiAwareness", ws2016Namespace);
222
+ writer.WriteString(dpiAwarenessValue);
223
+ writer.WriteEndElement();
224
+ }
225
+
226
+ if (gdiScalingValue != null)
227
+ {
228
+ writer.WriteStartElement("gdiScaling", ws2017Namespace);
229
+ writer.WriteString(gdiScalingValue);
230
+ writer.WriteEndElement();
231
+ }
232
+
233
+ writer.WriteEndElement(); // </windowSettings>
234
+ writer.WriteEndElement(); // </application>
235
+ }
236
237
writer.WriteEndDocument(); // </assembly>
238
writer.Close();
src/WixToolset.Core/Compiler_Bundle.cs
+45
-1
@@ -649,6 +649,7 @@ namespace WixToolset.Core
649
var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
650
Identifier previousId = null;
651
var previousType = ComplexReferenceChildType.Unknown;
652
+ var dpiAwareness = WixBootstrapperApplicationDpiAwarenessType.PerMonitorV2;
653
654
// The BootstrapperApplication element acts like a Payload element so delegate to the "Payload" attribute parsing code to parse and create a Payload entry.
655
var id = this.ParsePayloadElementContent(node, ComplexReferenceParentType.Container, Compiler.BurnUXContainerId, previousType, previousId, false);
@@ -658,6 +659,40 @@ namespace WixToolset.Core
659
previousType = ComplexReferenceChildType.Payload;
660
}
661
662
+ foreach (var attrib in node.Attributes())
663
+ {
664
+ if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
665
+ {
666
+ switch (attrib.Name.LocalName)
667
+ {
668
+ case "DpiAwareness":
669
+ var dpiAwarenessValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
670
+ switch (dpiAwarenessValue)
671
+ {
672
+ case "gdiScaled":
673
+ dpiAwareness = WixBootstrapperApplicationDpiAwarenessType.GdiScaled;
674
+ break;
675
+ case "perMonitor":
676
+ dpiAwareness = WixBootstrapperApplicationDpiAwarenessType.PerMonitor;
677
+ break;
678
+ case "perMonitorV2":
679
+ dpiAwareness = WixBootstrapperApplicationDpiAwarenessType.PerMonitorV2;
680
+ break;
681
+ case "system":
682
+ dpiAwareness = WixBootstrapperApplicationDpiAwarenessType.System;
683
+ break;
684
+ case "unaware":
685
+ dpiAwareness = WixBootstrapperApplicationDpiAwarenessType.Unaware;
686
+ break;
687
+ default:
688
+ this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "DpiAwareness", dpiAwarenessValue, "gdiScaled", "perMonitor", "perMonitorV2", "system", "unaware"));
689
+ break;
690
+ }
691
+ break;
692
+ }
693
+ }
694
+ }
695
+
696
foreach (var child in node.Elements())
697
{
698
if (CompilerCore.WixNamespace == child.Name.Namespace)
@@ -702,7 +737,10 @@ namespace WixToolset.Core
737
738
if (null != id)
739
{
705
- this.Core.AddSymbol(new WixBootstrapperApplicationSymbol(sourceLineNumbers, id));
740
+ this.Core.AddSymbol(new WixBootstrapperApplicationSymbol(sourceLineNumbers, id)
741
+ {
742
+ DpiAwareness = dpiAwareness,
743
+ });
744
}
745
}
746
}
@@ -1325,6 +1363,12 @@ namespace WixToolset.Core
1363
case "EnableSignatureVerification":
1364
enableSignatureVerification = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
1365
break;
1366
+ case "DpiAwareness":
1367
+ if (node.Name.LocalName != "BootstrapperApplication")
1368
+ {
1369
+ this.Core.UnexpectedAttribute(node, attrib);
1370
+ }
1371
+ break;
1372
default:
1373
this.Core.UnexpectedAttribute(node, attrib);
1374
break;
src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs
+1
-1
@@ -127,7 +127,7 @@ namespace WixToolsetTest.CoreIntegration
127
"<dependency><dependentAssembly><assemblyIdentity name=\"Microsoft.Windows.Common-Controls\" version=\"6.0.0.0\" processorArchitecture=\"x86\" publicKeyToken=\"6595b64144ccf1df\" language=\"*\" type=\"win32\" /></dependentAssembly></dependency>" +
128
"<compatibility xmlns=\"urn:schemas-microsoft-com:compatibility.v1\"><application><supportedOS Id=\"{e2011457-1546-43c5-a5fe-008deee3d3f0}\" /><supportedOS Id=\"{35138b9a-5d96-4fbd-8e2d-a2440225f93a}\" /><supportedOS Id=\"{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}\" /><supportedOS Id=\"{1f676c76-80e1-4239-95bb-83d0f6d0da78}\" /><supportedOS Id=\"{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}\" /></application></compatibility>" +
129
"<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v3\"><security><requestedPrivileges><requestedExecutionLevel level=\"asInvoker\" uiAccess=\"false\" /></requestedPrivileges></security></trustInfo>" +
130
- "<application xmlns=\"urn:schemas-microsoft-com:asm.v3\"><windowsSettings><dpiAware xmlns=\"http://schemas.microsoft.com/SMI/2005/WindowsSettings\">true</dpiAware></windowsSettings></application>" +
130
+ "<application xmlns=\"urn:schemas-microsoft-com:asm.v3\"><windowsSettings><dpiAware xmlns=\"http://schemas.microsoft.com/SMI/2005/WindowsSettings\">true/pm</dpiAware><dpiAwareness xmlns=\"http://schemas.microsoft.com/SMI/2016/WindowsSettings\">PerMonitorV2, PerMonitor</dpiAwareness></windowsSettings></application>" +
131
"</assembly>", actualManifestData);
132
}
133
}