Skip to content

Commit

Permalink
Turns out that packaging is making my life a nightmare
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Dec 14, 2020
1 parent 3351e01 commit 0b9cd30
Show file tree
Hide file tree
Showing 13 changed files with 498 additions and 37 deletions.
293 changes: 291 additions & 2 deletions OpenConsole.sln

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 78 additions & 0 deletions src/tools/MonarchPeasantPackage/MonarchPeasantPackage.wapproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '15.0'">
<VisualStudioVersion>15.0</VisualStudioVersion>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x86">
<Configuration>Debug</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x86">
<Configuration>Release</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|AnyCPU">
<Configuration>Debug</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|AnyCPU">
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup>
<WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath>
</PropertyGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />
<PropertyGroup>
<ProjectGuid>f75e29d0-d288-478b-8d83-2c190f321a3f</ProjectGuid>
<TargetPlatformVersion>10.0.18362.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<DefaultLanguage>en-US</DefaultLanguage>
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
<EntryPointProjectUniqueName>..\MonarchPeasantSample\MonarchPeasantSample.vcxproj</EntryPointProjectUniqueName>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
</ItemGroup>
<ItemGroup>
<Content Include="Images\SplashScreen.scale-200.png" />
<Content Include="Images\LockScreenLogo.scale-200.png" />
<Content Include="Images\Square150x150Logo.scale-200.png" />
<Content Include="Images\Square44x44Logo.scale-200.png" />
<Content Include="Images\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Content Include="Images\StoreLogo.png" />
<Content Include="Images\Wide310x150Logo.scale-200.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MonarchPeasantSample\MonarchPeasantSample.vcxproj" />
</ItemGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
</Project>
72 changes: 72 additions & 0 deletions src/tools/MonarchPeasantPackage/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>

<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
IgnorableNamespaces="uap rescap">

<Identity
Name="5d4b020d-14a7-4a1a-a359-3f468e23bae3"
Publisher="CN=migrie"
Version="1.0.0.0" />

<Properties>
<DisplayName>MonarchPeasantPackage</DisplayName>
<PublisherDisplayName>migrie</PublisherDisplayName>
<Logo>Images\StoreLogo.png</Logo>
</Properties>

<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.14393.0" />
</Dependencies>

<Resources>
<Resource Language="x-generate"/>
</Resources>

<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="MonarchPeasantPackage"
Description="MonarchPeasantPackage"
BackgroundColor="transparent"
Square150x150Logo="Images\Square150x150Logo.png"
Square44x44Logo="Images\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" />
<uap:SplashScreen Image="Images\SplashScreen.png" />
</uap:VisualElements>

<Extensions>
<uap3:Extension Category="windows.appExecutionAlias" Executable="MonarchPeasantSample\MonarchPeasantSample.exe" EntryPoint="Windows.FullTrustApplication">
<uap3:AppExecutionAlias>
<desktop:ExecutionAlias Alias="MonarchPeasantSample.exe" />
</uap3:AppExecutionAlias>
</uap3:Extension>


<!-- I'm pretty confident that this does nothing: -->
<!-- <uap5:Extension Category="windows.activatableClass.outOfProcessServer">
<uap5:OutOfProcessServer ServerName="Microsoft.SDKSamples.ToastServer">
<uap5:Path>MonarchPeasantSample\MonarchPeasantSample.exe</uap5:Path>
<uap5:Instancing>multipleInstances</uap5:Instancing>
<uap5:ActivatableClass ActivatableClassId="MonarchPeasantSample.Monarch" />
</uap5:OutOfProcessServer>
</uap5:Extension> -->

</Extensions>

</Application>
</Applications>

<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>
35 changes: 34 additions & 1 deletion src/tools/MonarchPeasantSample/AppState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,40 @@ void AppState::remindKingWhoTheyAre(const winrt::MonarchPeasantSample::IPeasant&

winrt::MonarchPeasantSample::Monarch AppState::instantiateMonarch()
{
auto monarch = create_instance<winrt::MonarchPeasantSample::Monarch>(Monarch_clsid, CLSCTX_LOCAL_SERVER);
auto something = create_instance<winrt::Windows::Foundation::IUnknown>(Monarch_clsid,
CLSCTX_LOCAL_SERVER);
if (something)
{
printf("Was able get something\n");
auto somethingAsMonarch = something.try_as<winrt::MonarchPeasantSample::Monarch>();
if (somethingAsMonarch)
{
printf("Was able to convert something into a Monarch\n");
return somethingAsMonarch;
}
else
{
printf("Was NOT able to convert something into a Monarch\n");
// auto another = winrt::get_abi(something);
// auto thenAnother = winrt::from_abi<winrt::MonarchPeasantSample::IMonarch>(another);
// winrt::MonarchPeasantSample::Monarch to{ nullptr };
// winrt::com_ptr<winrt::Windows::Foundation::IUnknown> ptr{ something.as<winrt::Windows::Foundation::IUnknown>() };
// if (thenAnother)
// {
// printf("I did not seriously expect this to work\n");
// }
// else
// {
// printf("That's mode like it\n");
// }
}
}
else
{
printf("Was NOT able get something\n");
}
auto monarch = create_instance<winrt::MonarchPeasantSample::Monarch>(Monarch_clsid,
CLSCTX_LOCAL_SERVER);
return monarch;
}

Expand Down
48 changes: 19 additions & 29 deletions src/tools/MonarchPeasantSample/Monarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,18 @@ namespace winrt::MonarchPeasantSample::implementation
void Monarch::SetSelfID(const uint64_t selfID)
{
this->_thisPeasantID = selfID;
// TODO: Right now, the monarch assumes the role of the most recent
// Right now, the monarch assumes the role of the most recent
// window. If the monarch dies, and a new monarch takes over, then the
// entire stack of MRU windows will go with it. That's not what you
// want!
//
// In the real app, we'll have each window also track the timestamp it
// was activated at, and the monarch will cache these. So a new monarch
// could re-query these last activated timestamps, and reconstruct the
// MRU stack.
//
// This is a sample though, and we're not too worried about complete
// correctness here.
_setMostRecentPeasant(_thisPeasantID);
}

Expand All @@ -98,18 +106,6 @@ namespace winrt::MonarchPeasantSample::implementation

bool createNewWindow = true;

if (_windowingBehavior == GlomToLastWindow::Always)
{
// This is "single instance mode". We should always eat the commandline.

if (auto thisPeasant = _getPeasant(_thisPeasantID))
{
thisPeasant.ExecuteCommandline(args, cwd);
createNewWindow = false;
return createNewWindow;
}
}

if (args.size() >= 3)
{
// We'll need three args at least - [MonarchPeasantSample.exe, -s,
Expand Down Expand Up @@ -147,7 +143,7 @@ namespace winrt::MonarchPeasantSample::implementation
}
}
}
else if (_windowingBehavior == GlomToLastWindow::LastActive)
else if (_windowingBehavior == WindowingBehavior::UseExisting)
{
if (auto mruPeasant = _getPeasant(_mostRecentPeasant))
{
Expand All @@ -166,28 +162,22 @@ namespace winrt::MonarchPeasantSample::implementation
{
switch (_windowingBehavior)
{
case GlomToLastWindow::Never:
_windowingBehavior = GlomToLastWindow::LastActive;
case WindowingBehavior::UseNew:
_windowingBehavior = WindowingBehavior::UseExisting;
break;
case GlomToLastWindow::LastActive:
_windowingBehavior = GlomToLastWindow::Always;
break;
case GlomToLastWindow::Always:
_windowingBehavior = GlomToLastWindow::Never;
case WindowingBehavior::UseExisting:
_windowingBehavior = WindowingBehavior::UseNew;
break;
}

printf("glomToLastWindow: ");
printf("windowingBehavior: ");
switch (_windowingBehavior)
{
case GlomToLastWindow::Never:
printf("never");
break;
case GlomToLastWindow::LastActive:
printf("lastActive");
case WindowingBehavior::UseNew:
printf("useNew");
break;
case GlomToLastWindow::Always:
printf("always");
case WindowingBehavior::UseExisting:
printf("useExisting");
break;
}
printf("\n");
Expand Down
9 changes: 4 additions & 5 deletions src/tools/MonarchPeasantSample/Monarch.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ constexpr GUID Monarch_clsid{
{ 0x83, 0x63, 0x5e, 0x06, 0xf5, 0xd0, 0x08, 0x2c }
};

enum class GlomToLastWindow : uint64_t
enum class WindowingBehavior : uint64_t
{
Never = 0,
LastActive = 1,
Always = 2
UseNew = 0,
UseExisting = 1,
};

namespace winrt::MonarchPeasantSample::implementation
Expand All @@ -39,7 +38,7 @@ namespace winrt::MonarchPeasantSample::implementation
uint64_t _nextPeasantID{ 1 };
uint64_t _thisPeasantID{ 0 };
uint64_t _mostRecentPeasant{ 0 };
GlomToLastWindow _windowingBehavior{ GlomToLastWindow::Never };
WindowingBehavior _windowingBehavior{ WindowingBehavior::UseNew };
std::unordered_map<uint64_t, winrt::MonarchPeasantSample::IPeasant> _peasants;

winrt::MonarchPeasantSample::IPeasant _getPeasant(uint64_t peasantID);
Expand Down

1 comment on commit 0b9cd30

@github-actions

This comment was marked as resolved.

Please sign in to comment.