Browse Source

WIP

pull/9085/head
daniilpavliuchyk 4 years ago
parent
commit
50cea008d7
  1. 31
      native/Avalonia.Native/src/OSX/main.mm
  2. 8
      samples/ControlCatalog.NetCore/Program.cs
  3. 1
      src/Avalonia.Native/AvaloniaNativePlatform.cs
  4. 2
      src/Avalonia.Native/AvaloniaNativePlatformExtensions.cs
  5. 1
      src/Avalonia.Native/avn.idl

31
native/Avalonia.Native/src/OSX/main.mm

@ -3,7 +3,7 @@
#include "common.h" #include "common.h"
static NSString* s_appTitle = @"Avalonia"; static NSString* s_appTitle = @"Avalonia";
static int disableSetProcessName;
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
@ -101,7 +101,9 @@ void SetProcessName(NSString* appTitle) {
class MacOptions : public ComSingleObject<IAvnMacOptions, &IID_IAvnMacOptions> class MacOptions : public ComSingleObject<IAvnMacOptions, &IID_IAvnMacOptions>
{ {
public: public:
FORWARD_IUNKNOWN() FORWARD_IUNKNOWN()
virtual HRESULT SetApplicationTitle(char* utf8String) override virtual HRESULT SetApplicationTitle(char* utf8String) override
@ -111,11 +113,17 @@ public:
@autoreleasepool @autoreleasepool
{ {
auto appTitle = [NSString stringWithUTF8String: utf8String]; auto appTitle = [NSString stringWithUTF8String: utf8String];
if (disableSetProcessName == 0)
[[NSProcessInfo processInfo] setProcessName:appTitle]; {
[[NSProcessInfo processInfo] setProcessName:appTitle];
SetProcessName(appTitle); SetProcessName(appTitle);
}
if (disableSetProcessName == 1)
{
auto rootMenu = [NSApp mainMenu];
[rootMenu setTitle:appTitle];
}
return S_OK; return S_OK;
} }
@ -133,6 +141,17 @@ public:
} }
} }
virtual HRESULT SetDisableSetProcessName(int disable) override
{
START_COM_CALL;
@autoreleasepool
{
disableSetProcessName = disable;
return S_OK;
}
}
}; };
/// See "Using POSIX Threads in a Cocoa Application" section here: /// See "Using POSIX Threads in a Cocoa Application" section here:

8
samples/ControlCatalog.NetCore/Program.cs

@ -115,6 +115,14 @@ namespace ControlCatalog.NetCore
UseDBusMenu = true, UseDBusMenu = true,
EnableIme = true EnableIme = true
}) })
.With(new MacOSPlatformOptions()
{
DisableSetProcessName = true
})
.With(new AvaloniaNativePlatformOptions()
{
AvaloniaNativeLibraryPath = "/Users/daniilpavliuchyk/Library/Developer/Xcode/DerivedData/Avalonia.Native.OSX-hchxgrlrewlcvufcdcugzgajjpdt/Build/Products/Debug/libAvalonia.Native.OSX.dylib"
})
.UseSkia() .UseSkia()
.AfterSetup(builder => .AfterSetup(builder =>
{ {

1
src/Avalonia.Native/AvaloniaNativePlatform.cs

@ -102,6 +102,7 @@ namespace Avalonia.Native
var macOpts = AvaloniaLocator.Current.GetService<MacOSPlatformOptions>() ?? new MacOSPlatformOptions(); var macOpts = AvaloniaLocator.Current.GetService<MacOSPlatformOptions>() ?? new MacOSPlatformOptions();
_factory.MacOptions.SetShowInDock(macOpts.ShowInDock ? 1 : 0); _factory.MacOptions.SetShowInDock(macOpts.ShowInDock ? 1 : 0);
_factory.MacOptions.SetDisableSetProcessName(macOpts.DisableSetProcessName ? 1 : 0);
} }
AvaloniaLocator.CurrentMutable AvaloniaLocator.CurrentMutable

2
src/Avalonia.Native/AvaloniaNativePlatformExtensions.cs

@ -83,5 +83,7 @@ namespace Avalonia
/// Gets or sets a value indicating whether the native macOS menu bar will be enabled for the application. /// Gets or sets a value indicating whether the native macOS menu bar will be enabled for the application.
/// </summary> /// </summary>
public bool DisableNativeMenus { get; set; } public bool DisableNativeMenus { get; set; }
public bool DisableSetProcessName { get; set; }
} }
} }

1
src/Avalonia.Native/avn.idl

@ -599,6 +599,7 @@ interface IAvnMacOptions : IUnknown
{ {
HRESULT SetShowInDock(int show); HRESULT SetShowInDock(int show);
HRESULT SetApplicationTitle(char* utf8string); HRESULT SetApplicationTitle(char* utf8string);
HRESULT SetDisableSetProcessName(int disable);
} }
[uuid(04c1b049-1f43-418a-9159-cae627ec1367)] [uuid(04c1b049-1f43-418a-9159-cae627ec1367)]

Loading…
Cancel
Save