summaryrefslogtreecommitdiff
path: root/vcl/osx/vclnsapp.mm
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2017-09-04 17:40:13 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2017-09-28 17:48:37 +0200
commite310c00709ed4fe0788aeff5142e3581d8b4d319 (patch)
treeb85827742e4a93a57150b5d8d254ea85a6265379 /vcl/osx/vclnsapp.mm
parentdea1b649765262b2e8beac88b0977d5dead98953 (diff)
Unify SalUserEvent handling
Merges the various SalUserEvent structs and their handling into a single class. This includes a common SalFrame* hash map, as all backends use such a map to verify alive SalFrames. It also reverts the "FIXME: lousy workaround" for i#90083, which was part of commit d6f7c94e5c27ba02ff5c3229760c9808cc9b5bea. At least on my current OSX box application based window switching "just works" "out of the box", even without the code. Change-Id: I188b567e44fd79c162b2d9cabbd771d1f66c7dc4 Reviewed-on: https://gerrit.libreoffice.org/42845 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/osx/vclnsapp.mm')
-rw-r--r--vcl/osx/vclnsapp.mm117
1 files changed, 11 insertions, 106 deletions
diff --git a/vcl/osx/vclnsapp.mm b/vcl/osx/vclnsapp.mm
index 651fa2a014cc..dafcdb97aca5 100644
--- a/vcl/osx/vclnsapp.mm
+++ b/vcl/osx/vclnsapp.mm
@@ -136,24 +136,6 @@ SAL_WNODEPRECATED_DECLARATIONS_PUSH
}
}
- // #i90083# handle frame switching
- // FIXME: lousy workaround
- if( (nModMask & (NSControlKeyMask|NSAlternateKeyMask)) == 0 )
- {
- if( [[pEvent characters] isEqualToString: @"<"] ||
- [[pEvent characters] isEqualToString: @"~"] )
- {
- [self cycleFrameForward: pFrame];
- return;
- }
- else if( [[pEvent characters] isEqualToString: @">"] ||
- [[pEvent characters] isEqualToString: @"`"] )
- {
- [self cycleFrameBackward: pFrame];
- return;
- }
- }
-
// get information whether the event was handled; keyDown returns nothing
GetSalData()->maKeyEventAnswer[ pEvent ] = false;
bool bHandled = false;
@@ -245,84 +227,6 @@ SAL_WNODEPRECATED_DECLARATIONS_POP
[super sendEvent: pEvent];
}
--(void)cycleFrameForward: (AquaSalFrame*)pCurFrame
-{
- // find current frame in list
- std::list< AquaSalFrame* >& rFrames( GetSalData()->maFrames );
- std::list< AquaSalFrame* >::iterator it = rFrames.begin();
- for( ; it != rFrames.end() && *it != pCurFrame; ++it )
- ;
- if( it != rFrames.end() )
- {
- // now find the next frame (or end)
- do
- {
- ++it;
- if( it != rFrames.end() )
- {
- if( (*it)->mpDockMenuEntry != nullptr &&
- (*it)->mbShown )
- {
- [(*it)->getNSWindow() makeKeyAndOrderFront: NSApp];
- return;
- }
- }
- } while( it != rFrames.end() );
- // cycle around, find the next up to pCurFrame
- it = rFrames.begin();
- while( *it != pCurFrame )
- {
- if( (*it)->mpDockMenuEntry != nullptr &&
- (*it)->mbShown )
- {
- [(*it)->getNSWindow() makeKeyAndOrderFront: NSApp];
- return;
- }
- ++it;
- }
- }
-}
-
--(void)cycleFrameBackward: (AquaSalFrame*)pCurFrame
-{
- // do the same as cycleFrameForward only with a reverse iterator
-
- // find current frame in list
- std::list< AquaSalFrame* >& rFrames( GetSalData()->maFrames );
- std::list< AquaSalFrame* >::reverse_iterator it = rFrames.rbegin();
- for( ; it != rFrames.rend() && *it != pCurFrame; ++it )
- ;
- if( it != rFrames.rend() )
- {
- // now find the next frame (or end)
- do
- {
- ++it;
- if( it != rFrames.rend() )
- {
- if( (*it)->mpDockMenuEntry != nullptr &&
- (*it)->mbShown )
- {
- [(*it)->getNSWindow() makeKeyAndOrderFront: NSApp];
- return;
- }
- }
- } while( it != rFrames.rend() );
- // cycle around, find the next up to pCurFrame
- it = rFrames.rbegin();
- while( *it != pCurFrame )
- {
- if( (*it)->mpDockMenuEntry != nullptr &&
- (*it)->mbShown )
- {
- [(*it)->getNSWindow() makeKeyAndOrderFront: NSApp];
- return;
- }
- ++it;
- }
- }
-}
-
-(NSMenu*)applicationDockMenu:(NSApplication *)sender
{
(void)sender;
@@ -413,12 +317,13 @@ SAL_WNODEPRECATED_DECLARATIONS_POP
{
SolarMutexGuard aGuard;
- SalData* pSalData = GetSalData();
- if( ! pSalData->maFrames.empty() )
+ AquaSalInstance *pInst = GetSalData()->mpFirstInstance;
+ SalFrame *pAnyFrame = pInst->anyFrame();
+ if( pAnyFrame )
{
// the following QueryExit will likely present a message box, activate application
[NSApp activateIgnoringOtherApps: YES];
- aReply = pSalData->maFrames.front()->CallCallback( SalEvent::Shutdown, nullptr ) ? NSTerminateCancel : NSTerminateNow;
+ aReply = pAnyFrame->CallCallback( SalEvent::Shutdown, nullptr ) ? NSTerminateCancel : NSTerminateNow;
}
if( aReply == NSTerminateNow )
@@ -439,9 +344,10 @@ SAL_WNODEPRECATED_DECLARATIONS_POP
(void)pNotification;
SolarMutexGuard aGuard;
- const SalData* pSalData = GetSalData();
- if( !pSalData->maFrames.empty() )
- pSalData->maFrames.front()->CallCallback( SalEvent::SettingsChanged, nullptr );
+ AquaSalInstance *pInst = GetSalData()->mpFirstInstance;
+ SalFrame *pAnyFrame = pInst->anyFrame();
+ if( pAnyFrame )
+ pAnyFrame->CallCallback( SalEvent::SettingsChanged, nullptr );
}
-(void)screenParametersChanged: (NSNotification*) pNotification
@@ -449,11 +355,10 @@ SAL_WNODEPRECATED_DECLARATIONS_POP
(void)pNotification;
SolarMutexGuard aGuard;
- SalData* pSalData = GetSalData();
- std::list< AquaSalFrame* >::iterator it;
- for( it = pSalData->maFrames.begin(); it != pSalData->maFrames.end(); ++it )
+ for( auto pSalFrame : GetSalData()->mpFirstInstance->getFrames() )
{
- (*it)->screenParametersChanged();
+ AquaSalFrame *pFrame = static_cast<AquaSalFrame*>( const_cast<SalFrame*>( pSalFrame ) );
+ pFrame->screenParametersChanged();
}
}