summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Luby <guibmacdev@gmail.com>2024-07-25 21:09:34 -0400
committerPatrick Luby <guibomacdev@gmail.com>2024-07-27 03:06:28 +0200
commitb147debad0cb980317c6915382a12f8dfcef6dfb (patch)
tree440b839e5950bce13929130e1dab6017c3e795ef
parent4be345abd678babcbb989db1e7a16021ad1da562 (diff)
tdf#162190 handle Command-w
On macOS, Command-w should attempt to close the key window. Also, pressing Command-m would fail to close the key window due to the same cause as tdf#162010 if the resulting key event was an input method event. Change-Id: I0d90547d7a0833bcc18b36f6d888e1065e91ec57 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171086 Reviewed-by: Patrick Luby <guibomacdev@gmail.com> Tested-by: Jenkins
-rw-r--r--vcl/osx/vclnsapp.mm33
1 files changed, 29 insertions, 4 deletions
diff --git a/vcl/osx/vclnsapp.mm b/vcl/osx/vclnsapp.mm
index d023e9758879..215d80fb33ed 100644
--- a/vcl/osx/vclnsapp.mm
+++ b/vcl/osx/vclnsapp.mm
@@ -109,24 +109,49 @@
[static_cast<SalFrameWindow*>(pKeyWin) endExtTextInput];
AquaSalFrame* pFrame = [static_cast<SalFrameWindow*>(pKeyWin) getSalFrame];
- unsigned int nModMask = ([pEvent modifierFlags] & (NSEventModifierFlagShift|NSEventModifierFlagControl|NSEventModifierFlagOption|NSEventModifierFlagCommand));
+
+ // Related tdf#162010: match against -[NSEvent characters]
+ // When using some non-Western European keyboard layouts, the
+ // event's "characters ignoring modifiers" will be set to the
+ // original Unicode character instead of the resolved key
+ // equivalent character so match against the -[NSEvent characters]
+ // instead.
+ NSEventModifierFlags nModMask = ([pEvent modifierFlags] & (NSEventModifierFlagShift|NSEventModifierFlagControl|NSEventModifierFlagOption|NSEventModifierFlagCommand));
+
+ // Note: when pressing Command-Option keys, some non-Western
+ // keyboards will set the "characters ignoring modifiers"
+ // property to the key shortcut character instead of setting
+ // the "characters property. So check for both cases.
+ NSString *pCharacters = [pEvent characters];
+ NSString *pCharactersIgnoringModifiers = [pEvent charactersIgnoringModifiers];
+
/*
* #i98949# - Cmd-M miniaturize window, Cmd-Option-M miniaturize all windows
*/
- if( [[pEvent charactersIgnoringModifiers] isEqualToString: @"m"] )
+ if( [pCharacters isEqualToString: @"m"] || [pCharactersIgnoringModifiers isEqualToString: @"m"] )
{
if ( nModMask == NSEventModifierFlagCommand && ([pFrame->getNSWindow() styleMask] & NSWindowStyleMaskMiniaturizable) )
{
[pFrame->getNSWindow() performMiniaturize: nil];
return;
}
-
- if ( nModMask == ( NSEventModifierFlagCommand | NSEventModifierFlagOption ) )
+ else if ( nModMask == ( NSEventModifierFlagCommand | NSEventModifierFlagOption ) )
{
[NSApp miniaturizeAll: nil];
return;
}
}
+ // tdf#162190 handle Command-w
+ // On macOS, Command-w should attempt to close the key window.
+ // TODO: Command-Option-w should attempt to close all windows.
+ else if( [pCharacters isEqualToString: @"w"] || [pCharactersIgnoringModifiers isEqualToString: @"w"] )
+ {
+ if ( nModMask == NSEventModifierFlagCommand && ([pFrame->getNSWindow() styleMask] & NSWindowStyleMaskClosable ) )
+ {
+ [pFrame->getNSWindow() performClose: nil];
+ return;
+ }
+ }
// get information whether the event was handled; keyDown returns nothing
GetSalData()->maKeyEventAnswer[ pEvent ] = false;