Skip to content

Commit

Permalink
Merge pull request #1701 from cwensley/curtis/mac-fixes
Browse files Browse the repository at this point in the history
Mac fixes and auto-load platform assemblies when subclassed
  • Loading branch information
cwensley authored May 28, 2020
2 parents 780e081 + 20a4c07 commit a9e25d4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
10 changes: 8 additions & 2 deletions src/Eto.Mac/Forms/MacWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,14 @@ public override Size Size
set
{
var oldFrame = Control.Frame;
var newFrame = oldFrame.SetSize(value);
newFrame.Y = (nfloat)Math.Max(0, oldFrame.Y - (value.Height - oldFrame.Height));
var newFrame = oldFrame;
if (value.Width >= 0)
newFrame.Width = value.Width;
if (value.Height > 0)
{
newFrame.Height = value.Height;
newFrame.Y = (nfloat)Math.Max(0, oldFrame.Y - (value.Height - oldFrame.Height));
}
Control.SetFrame(newFrame, true);
UserPreferredSize = value;
SetAutoSize();
Expand Down
2 changes: 1 addition & 1 deletion src/Eto.Mac/build/BundleDotNetCore.targets
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<Target Name="MacBuildAppBundleWithoutRuntime" AfterTargets="AfterBuild" Condition="$(MacBundleDotNet) != 'True' AND $(MacIsBuildingBundle) == 'True'" DependsOnTargets="MacInitializeBundle;MacCollectExecutableFiles">

<!-- copy executable files -->
<Copy SourceFiles="@(MacExecutableFiles)" DestinationFiles="$(LauncherPath)%(MacExecutableFiles.TargetPath)" />
<Copy SourceFiles="@(MacExecutableFiles)" DestinationFiles="@(MacExecutableFiles->'$(LauncherPath)%(TargetPath)')" />

<!-- finish building the bundle -->
<CallTarget Targets="MacFinishBundle" />
Expand Down
2 changes: 1 addition & 1 deletion src/Eto.Mac/build/BundleMono.targets
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
</ItemGroup>

<!-- copy executable files -->
<Copy SourceFiles="@(MacExecutableFiles)" DestinationFiles="$(OutputMonoBundlePath)%(MacExecutableFiles.TargetPath)" />
<Copy SourceFiles="@(MacExecutableFiles)" DestinationFiles="@(MacExecutableFiles->'$(OutputMonoBundlePath)%(TargetPath)')" />
</Target>


Expand Down
22 changes: 16 additions & 6 deletions src/Eto/Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -611,14 +611,24 @@ internal HandlerInfo FindHandler(Type type)
return info;

var handler = type.GetCustomAttribute<HandlerAttribute>(true);
Func<object> activator;
if (handler != null && instantiatorMap.TryGetValue(handler.Type, out activator))
if (handler != null)
{
var autoInit = handler.Type.GetCustomAttribute<AutoInitializeAttribute>(true);
info = new HandlerInfo(autoInit == null || autoInit.Initialize, activator);
handlerMap.Add(type, info);
return info;
if (instantiatorMap.TryGetValue(handler.Type, out var activator))
{
var autoInit = handler.Type.GetCustomAttribute<AutoInitializeAttribute>(true);
info = new HandlerInfo(autoInit == null || autoInit.Initialize, activator);
handlerMap.Add(type, info);
return info;
}
// load the assembly of the handler type (needed when type is a subclass)
if (!loadedAssemblies.Contains(handler.Type.GetAssembly()))
{
LoadAssembly(handler.Type.GetAssembly());
return FindHandler(type);
}
}

// load the assembly of the target type (can be a subclass)
if (!loadedAssemblies.Contains(type.GetAssembly()))
{
LoadAssembly(type.GetAssembly());
Expand Down

0 comments on commit a9e25d4

Please sign in to comment.