From 2c7528552d901f855224b6a35dcc768d42ddaec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herbert=20D=C3=BCrr?= Date: Mon, 24 Feb 2014 09:49:19 +0000 Subject: [PATCH] Resolves: #i119006# delay Mac initial event until the app has launched delaying the initial event prevents complaints from OSX>=10.7's "windows restore" feature to recur infinitely. Apparently OSX cleans things up for us just before we get the applicationDidFinishLaunching() callback. (cherry picked from commit 0f3712ff654c740f3593b9580f34cdfe21ac3250) Conflicts: vcl/osx/salinst.cxx Change-Id: I0f1d59f03ffe4efc7c9a73fa881151fa06af5424 --- vcl/inc/osx/vclnsapp.h | 1 + vcl/osx/salinst.cxx | 36 +++++++++--------------------------- vcl/osx/vclnsapp.mm | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/vcl/inc/osx/vclnsapp.h b/vcl/inc/osx/vclnsapp.h index 38ad251e8bf2..541b509946a1 100644 --- a/vcl/inc/osx/vclnsapp.h +++ b/vcl/inc/osx/vclnsapp.h @@ -38,6 +38,7 @@ class AquaSalFrame; @interface VCL_NSApplication : NSApplication { } +-(void)applicationDidFinishLaunching:(NSNotification*)pNotification; -(void)sendEvent:(NSEvent*)pEvent; -(void)sendSuperEvent:(NSEvent*)pEvent; -(NSMenu*)applicationDockMenu:(NSApplication *)sender; diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx index fcec7b6a5c92..f0e6b3459a52 100644 --- a/vcl/osx/salinst.cxx +++ b/vcl/osx/salinst.cxx @@ -194,37 +194,19 @@ sal_Bool ImplSVMainHook( int * pnInit ) bNoSVMain = false; initNSApp(); - NSEvent* pEvent = [NSEvent otherEventWithType: NSApplicationDefined - location: NSZeroPoint - modifierFlags: 0 - timestamp: 0 - windowNumber: 0 - context: nil - subtype: AquaSalInstance::AppExecuteSVMain - data1: 0 - data2: 0 ]; - if( pEvent ) - { - [NSApp postEvent: pEvent atStart: NO]; - - OUString aExeURL, aExe; - osl_getExecutableFile( &aExeURL.pData ); - osl_getSystemPathFromFileURL( aExeURL.pData, &aExe.pData ); - OString aByteExe( OUStringToOString( aExe, osl_getThreadTextEncoding() ) ); + 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 ); + aByteExe += OString ( " NSAccessibilityDebugLogLevel 1" ); + const char* pArgv[] = { aByteExe.getStr(), NULL }; + NSApplicationMain( 3, pArgv ); #else - const char* pArgv[] = { aByteExe.getStr(), NULL }; - NSApplicationMain( 1, pArgv ); + const char* pArgv[] = { aByteExe.getStr(), NULL }; + NSApplicationMain( 1, pArgv ); #endif - } - else - { - OSL_FAIL( "NSApplication initialization could not be done" ); - } return TRUE; // indicate that ImplSVMainHook is implemented } diff --git a/vcl/osx/vclnsapp.mm b/vcl/osx/vclnsapp.mm index bd85aa760e00..531125a5efc2 100644 --- a/vcl/osx/vclnsapp.mm +++ b/vcl/osx/vclnsapp.mm @@ -57,6 +57,24 @@ // desktop/macosx/Info.plist has the value VCL_NSApplication. @implementation VCL_NSApplication + +-(void)applicationDidFinishLaunching:(NSNotification*)pNotification +{ + (void)pNotification; + + NSEvent* pEvent = [NSEvent otherEventWithType: NSApplicationDefined + location: NSZeroPoint + modifierFlags: 0 + timestamp: 0 + windowNumber: 0 + context: nil + subtype: AquaSalInstance::AppExecuteSVMain + data1: 0 + data2: 0 ]; + if( pEvent ) + [NSApp postEvent: pEvent atStart: NO]; +} + -(void)sendEvent:(NSEvent*)pEvent { NSEventType eType = [pEvent type];