Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added DPI awareness support to VS2010+ projects #949

Merged
merged 1 commit into from
Nov 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions modules/vstudio/tests/vc2010/test_manifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,37 @@
prepare()
test.isemptycapture()
end

--
-- Check that DPI Awareness emits correctly
--

function suite.dpiAwareness_None()
dpiawareness "None"
prepare()
test.capture [[
<Manifest>
<EnableDpiAwareness>false</EnableDpiAwareness>
</Manifest>
]]
end

function suite.dpiAwareness_High()
dpiawareness "High"
prepare()
test.capture [[
<Manifest>
<EnableDpiAwareness>true</EnableDpiAwareness>
</Manifest>
]]
end

function suite.dpiAwareness_HighPerMonitor()
dpiawareness "HighPerMonitor"
prepare()
test.capture [[
<Manifest>
<EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
</Manifest>
]]
end
57 changes: 45 additions & 12 deletions modules/vstudio/vs2010_vcxproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -482,22 +482,26 @@
-- Write the manifest section.
--

m.elements.manifest = function(cfg)
return {
m.enableDpiAwareness,
m.additionalManifestFiles,
}
end

function m.manifest(cfg)
if cfg.kind ~= p.STATICLIB then
-- get the manifests files
local manifests = {}
for _, fname in ipairs(cfg.files) do
if path.getextension(fname) == ".manifest" then
table.insert(manifests, project.getrelative(cfg.project, fname))
local contents = p.capture(function ()
p.push()
p.callArray(m.elements.manifest, cfg)
p.pop()
end)
if #contents > 0 then
p.push('<Manifest>')
p.outln(contents)
p.pop('</Manifest>')
end
end

if #manifests > 0 then
p.push('<Manifest>')
m.element("AdditionalManifestFiles", nil, "%s;%%(AdditionalManifestFiles)", table.concat(manifests, ";"))
p.pop('</Manifest>')
end
end
end


Expand Down Expand Up @@ -1216,6 +1220,21 @@
end


function m.additionalManifestFiles(cfg)
-- get the manifests files
local manifests = {}
for _, fname in ipairs(cfg.files) do
if path.getextension(fname) == ".manifest" then
table.insert(manifests, project.getrelative(cfg.project, fname))
end
end

if #manifests > 0 then
m.element("AdditionalManifestFiles", nil, "%s;%%(AdditionalManifestFiles)", table.concat(manifests, ";"))
end
end


function m.additionalUsingDirectories(cfg)
if #cfg.usingdirs > 0 then
local dirs = vstudio.path(cfg, cfg.usingdirs)
Expand Down Expand Up @@ -1462,6 +1481,20 @@
end


function m.enableDpiAwareness(cfg)
local awareness = {
None = "false",
High = "true",
HighPerMonitor = "PerMonitorHighDPIAware",
}
local value = awareness[cfg.dpiawareness]

if value then
m.element("EnableDpiAwareness", nil, value)
end
end


function m.enableEnhancedInstructionSet(cfg, condition)
local v
local x = cfg.vectorextensions
Expand Down
12 changes: 12 additions & 0 deletions src/_premake_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,18 @@
kind = "string",
}

api.register {
name = "dpiawareness",
scope = "config",
kind = "string",
allowed = {
"Default",
"None",
"High",
"HighPerMonitor",
}
}

api.register {
name = "editandcontinue",
scope = "config",
Expand Down