summaryrefslogtreecommitdiffstats
path: root/vcl/osx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 09:44:04 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 09:44:04 +0000
commiteb358d77291eba677141bab113dc27d7aabb0f3e (patch)
tree2e96f3b5d0c79beaeb536bbf05c3b8564846e65f /vcl/osx
parentAdding debian version 4:24.2.1-4. (diff)
downloadlibreoffice-eb358d77291eba677141bab113dc27d7aabb0f3e.tar.xz
libreoffice-eb358d77291eba677141bab113dc27d7aabb0f3e.zip
Merging upstream version 4:24.2.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vcl/osx')
-rw-r--r--vcl/osx/salmenu.cxx13
-rw-r--r--vcl/osx/salnsmenu.mm80
-rw-r--r--vcl/osx/salprn.cxx5
-rw-r--r--vcl/osx/vclnsapp.mm49
4 files changed, 107 insertions, 40 deletions
diff --git a/vcl/osx/salmenu.cxx b/vcl/osx/salmenu.cxx
index b3d02587f4..6ea16a6588 100644
--- a/vcl/osx/salmenu.cxx
+++ b/vcl/osx/salmenu.cxx
@@ -125,7 +125,9 @@ static void initAppMenu()
NSMenu* pAppMenu = nil;
NSMenuItem* pNewItem = nil;
- NSMenu* pMainMenu = [[[NSMenu alloc] initWithTitle: @"Main Menu"] autorelease];
+ // Related: tdf#126638 use NSMenu subclass to catch and redirect key
+ // shortcuts when a modal window is displayed
+ SalNSMainMenu* pMainMenu = [[[SalNSMainMenu alloc] initWithTitle: @"Main Menu"] autorelease];
pNewItem = [pMainMenu addItemWithTitle: @"Application"
action: nil
keyEquivalent: @""];
@@ -230,12 +232,19 @@ AquaSalMenu::AquaSalMenu( bool bMenuBar ) :
{
mpMenu = [[SalNSMenu alloc] initWithMenu: this];
[mpMenu setDelegate: reinterpret_cast< id<NSMenuDelegate> >(mpMenu)];
+
+ // Related: tdf#126638 enable the menu's "autoenabledItems" property
+ // Enable the menu's "autoenabledItems" property so that
+ // -[SalNSMenuItem validateMenuItem:] will be called before handling
+ // a key shortcut and the menu item can be temporarily disabled if a
+ // modal window is displayed.
+ [mpMenu setAutoenablesItems: YES];
}
else
{
mpMenu = [NSApp mainMenu];
+ [mpMenu setAutoenablesItems: NO];
}
- [mpMenu setAutoenablesItems: NO];
}
AquaSalMenu::~AquaSalMenu()
diff --git a/vcl/osx/salnsmenu.mm b/vcl/osx/salnsmenu.mm
index b2df2da7e5..31627a35ea 100644
--- a/vcl/osx/salnsmenu.mm
+++ b/vcl/osx/salnsmenu.mm
@@ -30,6 +30,53 @@
#include <osx/salnsmenu.h>
@implementation SalNSMenu
+
++(BOOL)dispatchSpecialKeyEquivalents: (NSEvent*)pEvent
+{
+ if( pEvent && [pEvent type] == NSEventTypeKeyDown )
+ {
+ unsigned int nModMask = ([pEvent modifierFlags] & (NSEventModifierFlagShift|NSEventModifierFlagControl|NSEventModifierFlagOption|NSEventModifierFlagCommand));
+ if( nModMask == NSEventModifierFlagCommand )
+ {
+ if( [[pEvent charactersIgnoringModifiers] isEqualToString: @"v"] )
+ {
+ if( [NSApp sendAction: @selector(paste:) to: nil from: nil] )
+ return YES;
+ }
+ else if( [[pEvent charactersIgnoringModifiers] isEqualToString: @"c"] )
+ {
+ if( [NSApp sendAction: @selector(copy:) to: nil from: nil] )
+ return YES;
+ }
+ else if( [[pEvent charactersIgnoringModifiers] isEqualToString: @"x"] )
+ {
+ if( [NSApp sendAction: @selector(cut:) to: nil from: nil] )
+ return YES;
+ }
+ else if( [[pEvent charactersIgnoringModifiers] isEqualToString: @"a"] )
+ {
+ if( [NSApp sendAction: @selector(selectAll:) to: nil from: nil] )
+ return YES;
+ }
+ else if( [[pEvent charactersIgnoringModifiers] isEqualToString: @"z"] )
+ {
+ if( [NSApp sendAction: @selector(undo:) to: nil from: nil] )
+ return YES;
+ }
+ }
+ else if( nModMask == (NSEventModifierFlagCommand|NSEventModifierFlagShift) )
+ {
+ if( [[pEvent charactersIgnoringModifiers] isEqualToString: @"Z"] )
+ {
+ if( [NSApp sendAction: @selector(redo:) to: nil from: nil] )
+ return YES;
+ }
+ }
+ }
+
+ return NO;
+}
+
-(id)initWithMenu: (AquaSalMenu*)pMenu
{
mpMenu = pMenu;
@@ -167,6 +214,19 @@
OSL_FAIL( "menubar item without frame !" );
}
}
+
+-(BOOL)validateMenuItem: (NSMenuItem *)pMenuItem
+{
+ // Related: tdf#126638 disable all menu items when displaying modal windows
+ // For some unknown reason, key shortcuts are dispatched to the LibreOffice
+ // menu items instead of the modal window so disable all LibreOffice menu
+ // items while a native modal dialog such as the native Open, Save, or
+ // Print dialog is displayed.
+ if (!pMenuItem || [NSApp modalWindow])
+ return NO;
+
+ return [pMenuItem isEnabled];
+}
@end
@implementation OOStatusItemView
@@ -257,5 +317,25 @@ SAL_WNODEPRECATED_DECLARATIONS_POP
}
@end
+@implementation SalNSMainMenu
+
+- (BOOL)performKeyEquivalent:(NSEvent*)pEvent
+{
+ BOOL bRet = [super performKeyEquivalent: pEvent];
+
+ // tdf#126638 dispatch key shortcut events to modal windows
+ // Some modal windows, such as the native Open and Save dialogs,
+ // return NO from -[NSWindow performKeyEquivalent:]. Fortunately,
+ // the main menu's -[NSMenu performKeyEquivalent:] is then called
+ // so we can catch and redirect any modal window's key shortcut
+ // events without triggering the modal window's "disallowed
+ // action" beep.
+ if( !bRet && [NSApp modalWindow] )
+ bRet = [SalNSMenu dispatchSpecialKeyEquivalents: pEvent];
+
+ return bRet;
+}
+
+@end
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/osx/salprn.cxx b/vcl/osx/salprn.cxx
index 3de45d9e80..3fe37a9ab5 100644
--- a/vcl/osx/salprn.cxx
+++ b/vcl/osx/salprn.cxx
@@ -270,6 +270,11 @@ sal_uInt16 AquaSalInfoPrinter::GetPaperBinBySourceIndex( const ImplJobSetup*, sa
return 0xffff;
}
+sal_uInt16 AquaSalInfoPrinter::GetSourceIndexByPaperBin(const ImplJobSetup*, sal_uInt16)
+{
+ return 0;
+}
+
sal_uInt32 AquaSalInfoPrinter::GetCapabilities( const ImplJobSetup*, PrinterCapType i_nType )
{
switch( i_nType )
diff --git a/vcl/osx/vclnsapp.mm b/vcl/osx/vclnsapp.mm
index 5daf923ce1..cd60cb0b0c 100644
--- a/vcl/osx/vclnsapp.mm
+++ b/vcl/osx/vclnsapp.mm
@@ -34,6 +34,7 @@
#include <osx/salframe.h>
#include <osx/salframeview.h>
#include <osx/salinst.h>
+#include <osx/salnsmenu.h>
#include <osx/vclnsapp.h>
#include <quartz/utils.h>
@@ -170,44 +171,8 @@
// precondition: this ONLY works because CMD-V (paste), CMD-C (copy) and CMD-X (cut) are
// NOT localized, that is the same in all locales. Should this be
// different in any locale, this hack will fail.
- unsigned int nModMask = ([pEvent modifierFlags] & (NSEventModifierFlagShift|NSEventModifierFlagControl|NSEventModifierFlagOption|NSEventModifierFlagCommand));
- if( nModMask == NSEventModifierFlagCommand )
- {
-
- if( [[pEvent charactersIgnoringModifiers] isEqualToString: @"v"] )
- {
- if( [NSApp sendAction: @selector(paste:) to: nil from: nil] )
- return;
- }
- else if( [[pEvent charactersIgnoringModifiers] isEqualToString: @"c"] )
- {
- if( [NSApp sendAction: @selector(copy:) to: nil from: nil] )
- return;
- }
- else if( [[pEvent charactersIgnoringModifiers] isEqualToString: @"x"] )
- {
- if( [NSApp sendAction: @selector(cut:) to: nil from: nil] )
- return;
- }
- else if( [[pEvent charactersIgnoringModifiers] isEqualToString: @"a"] )
- {
- if( [NSApp sendAction: @selector(selectAll:) to: nil from: nil] )
- return;
- }
- else if( [[pEvent charactersIgnoringModifiers] isEqualToString: @"z"] )
- {
- if( [NSApp sendAction: @selector(undo:) to: nil from: nil] )
- return;
- }
- }
- else if( nModMask == (NSEventModifierFlagCommand|NSEventModifierFlagShift) )
- {
- if( [[pEvent charactersIgnoringModifiers] isEqualToString: @"Z"] )
- {
- if( [NSApp sendAction: @selector(redo:) to: nil from: nil] )
- return;
- }
- }
+ if( [SalNSMenu dispatchSpecialKeyEquivalents:pEvent] )
+ return;
}
}
[super sendEvent: pEvent];
@@ -315,6 +280,14 @@
-(NSApplicationTerminateReply)applicationShouldTerminate: (NSApplication *) app
{
(void)app;
+
+ // Related: tdf#126638 disable all menu items when displaying modal windows
+ // Although -[SalNSMenuItem validateMenuItem:] disables almost all menu
+ // items when a modal window is displayed, the standard Quit menu item
+ // does not get disabled so disable it here.
+ if ([NSApp modalWindow])
+ return NSTerminateCancel;
+
NSApplicationTerminateReply aReply = NSTerminateNow;
{
SolarMutexGuard aGuard;