summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vcl/inc/osx/salinst.h3
-rw-r--r--vcl/inc/salinst.hxx1
-rw-r--r--vcl/osx/salinst.cxx30
-rw-r--r--vcl/osx/salmenu.cxx9
-rw-r--r--vcl/osx/vclnsapp.mm16
-rw-r--r--vcl/source/app/svmain.cxx6
6 files changed, 52 insertions, 13 deletions
diff --git a/vcl/inc/osx/salinst.h b/vcl/inc/osx/salinst.h
index 18b8de8cfc7f..edece53b6bea 100644
--- a/vcl/inc/osx/salinst.h
+++ b/vcl/inc/osx/salinst.h
@@ -91,6 +91,7 @@ public:
virtual ~AquaSalInstance() override;
virtual void AfterAppInit() override;
+ virtual bool SVMainHook(int *) override;
virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) override;
virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) override;
@@ -145,7 +146,7 @@ public:
void endedPrintJob() { mnActivePrintJobs--; }
// event subtypes for NSApplicationDefined events
- static const short AppEndLoopEvent = 1;
+ static const short AppExecuteSVMain = 1;
static const short AppStartTimerEvent = 10;
static const short YieldWakeupEvent = 20;
static const short DispatchTimerEvent = 30;
diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx
index f48cca4136e2..e35cd78df4fb 100644
--- a/vcl/inc/salinst.hxx
+++ b/vcl/inc/salinst.hxx
@@ -89,6 +89,7 @@ public:
//called directly after Application::Init
virtual void AfterAppInit() {}
+ virtual bool SVMainHook(int*) { return false; }
// Frame
// DisplayName for Unix ???
diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx
index f58f0e43e893..b2733253c951 100644
--- a/vcl/osx/salinst.cxx
+++ b/vcl/osx/salinst.cxx
@@ -80,6 +80,7 @@ extern "C" {
using namespace std;
using namespace ::com::sun::star;
+static int* gpnInit = nullptr;
static NSMenu* pDockMenu = nil;
static bool bLeftMain = false;
@@ -327,8 +328,6 @@ VCLPLUG_OSX_PUBLIC SalInstance* create_SalInstance()
ImplGetSVData()->maNWFData.mbProgressNeedsErase = true;
ImplGetSVData()->maNWFData.mnStatusBarLowerRightOffset = 10;
- [NSApp finishLaunching];
-
return pInst;
}
}
@@ -385,9 +384,14 @@ void AquaSalInstance::handleAppDefinedEvent( NSEvent* pEvent )
if ( pTimer )
pTimer->handleStartTimerEvent( pEvent );
break;
- case AppEndLoopEvent:
+ case AppExecuteSVMain:
+ {
+ int nRet = ImplSVMain();
+ if (gpnInit)
+ *gpnInit = nRet;
[NSApp stop: NSApp];
break;
+ }
case DispatchTimerEvent:
{
AquaSalInstance *pInst = GetSalData()->mpInstance;
@@ -965,5 +969,25 @@ SAL_WNODEPRECATED_DECLARATIONS_POP
return pImage;
}
+bool AquaSalInstance::SVMainHook(int* pnInit)
+{
+ gpnInit = pnInit;
+
+ OUString aExeURL, aExe;
+ osl_getExecutableFile( &aExeURL.pData );
+ osl_getSystemPathFromFileURL( aExeURL.pData, &aExe.pData );
+ OString aByteExe( OUStringToOString( aExe, osl_getThreadTextEncoding() ) );
+
+#ifdef DEBUG
+ aByteExe += OString ( " NSAccessibilityDebugLogLevel 1" );
+ const char* pArgv[] = { aByteExe.getStr(), NULL };
+ NSApplicationMain( 3, pArgv );
+#else
+ const char* pArgv[] = { aByteExe.getStr(), nullptr };
+ NSApplicationMain( 1, pArgv );
+#endif
+
+ return true; // indicate that ImplSVMainHook is implemented
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/osx/salmenu.cxx b/vcl/osx/salmenu.cxx
index 973fdddfb33c..4dbdf2ebe7b5 100644
--- a/vcl/osx/salmenu.cxx
+++ b/vcl/osx/salmenu.cxx
@@ -116,19 +116,12 @@ static void initAppMenu()
static bool bInitialized = false;
if (bInitialized)
return;
-
- // get the main menu
- NSMenu* pMainMenu = [NSApp mainMenu];
- assert(pMainMenu == nil);
- if (pMainMenu != nil)
- return;
-
bInitialized = true;
NSMenu* pAppMenu = nil;
NSMenuItem* pNewItem = nil;
- pMainMenu = [[[NSMenu alloc] initWithTitle: @"Main Menu"] autorelease];
+ NSMenu* pMainMenu = [[[NSMenu alloc] initWithTitle: @"Main Menu"] autorelease];
pNewItem = [pMainMenu addItemWithTitle: @"Application"
action: nil
keyEquivalent: @""];
diff --git a/vcl/osx/vclnsapp.mm b/vcl/osx/vclnsapp.mm
index 321fa2d6a68c..2b3bfea97437 100644
--- a/vcl/osx/vclnsapp.mm
+++ b/vcl/osx/vclnsapp.mm
@@ -62,6 +62,22 @@
-(void)applicationDidFinishLaunching:(NSNotification*)pNotification
{
(void)pNotification;
+
+SAL_WNODEPRECATED_DECLARATIONS_PUSH
+ // 'NSApplicationDefined' is deprecated: first deprecated in macOS 10.12
+ NSEvent* pEvent = [NSEvent otherEventWithType: NSApplicationDefined
+ location: NSZeroPoint
+ modifierFlags: 0
+ timestamp: [[NSProcessInfo processInfo] systemUptime]
+ windowNumber: 0
+ context: nil
+ subtype: AquaSalInstance::AppExecuteSVMain
+ data1: 0
+ data2: 0 ];
+SAL_WNODEPRECATED_DECLARATIONS_POP
+ assert( pEvent );
+ [NSApp postEvent: pEvent atStart: NO];
+
if( [NSWindow respondsToSelector:@selector(allowsAutomaticWindowTabbing)] )
{
NSWindow.allowsAutomaticWindowTabbing = NO;
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 673e800e4ac4..ce825e7062aa 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -190,7 +190,11 @@ int ImplSVMain()
int nReturn = EXIT_FAILURE;
- bool bInit = isInitVCL() || InitVCL();
+ const bool bWasInitVCL = isInitVCL();
+ const bool bInit = bWasInitVCL || InitVCL();
+ int nRet = 0;
+ if (!bWasInitVCL && bInit && pSVData->mpDefInst->SVMainHook(&nRet))
+ return nRet;
if( bInit )
{