vcl/osx/salframeview.mm |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

New commits:
commit 0c065c5e233044361713c0003dac6294a82a6e6e
Author:     Patrick Luby <guibmac...@gmail.com>
AuthorDate: Fri Nov 15 08:12:26 2024 -0500
Commit:     Patrick Luby <guibomac...@gmail.com>
CommitDate: Fri Nov 15 18:10:52 2024 +0100

    tdf#163876 ignore marked text generated from Command-` events
    
    For some unknown reason, when using the standard macOS French
    layout, pressing Command-` causes -[NSView interpretKeyEvents:]
    to temporarily set and unset the marked text.
    
    Command-` should only cycle through the application's windows
    so ignore marked text changes from such key down events.
    
    Change-Id: Ifeb4ad637d572b339d7b389466815bb60a4b3120
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176652
    Reviewed-by: Patrick Luby <guibomac...@gmail.com>
    Tested-by: Jenkins

diff --git a/vcl/osx/salframeview.mm b/vcl/osx/salframeview.mm
index 9bdfa8d9f239..6b812fe00ec1 100644
--- a/vcl/osx/salframeview.mm
+++ b/vcl/osx/salframeview.mm
@@ -1976,8 +1976,22 @@ static void freezeWindowSizeAndReschedule( NSWindow 
*pWindow )
         aString = [[[NSAttributedString alloc] initWithString:aString] 
autorelease];
 
     // Reset cached state
+    BOOL bOldHasMarkedText = [self hasMarkedText];
     [self unmarkText];
 
+    // tdf#163876 ignore marked text generated from Command-` events
+    // For some unknown reason, when using the standard macOS French
+    // layout, pressing Command-` causes -[NSView interpretKeyEvents:]
+    // to temporarily set and unset the marked text.
+    // Command-` should only cycle through the application's windows
+    // so ignore marked text changes from such key down events.
+    if( !bOldHasMarkedText && mpLastEvent && [mpLastEvent type] == 
NSEventTypeKeyDown && [mpLastEvent keyCode] == 42 && ( [mpLastEvent 
modifierFlags] & ( NSEventModifierFlagCommand | NSEventModifierFlagOption | 
NSEventModifierFlagControl | NSEventModifierFlagShift ) ) == 
NSEventModifierFlagCommand )
+    {
+        NSString* pUnmodifiedString = [mpLastEvent 
charactersIgnoringModifiers];
+        if( pUnmodifiedString && ![pUnmodifiedString length] )
+            return;
+    }
+
     int len = [aString length];
     bool bReschedule = false;
     SalExtTextInputEvent aInputEvent;

Reply via email to