vcl/osx/salframe.cxx |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

New commits:
commit 2170d9a8c6aa05aaecd763074311358abc88799c
Author:     Patrick Luby <guibmac...@gmail.com>
AuthorDate: Fri Mar 7 17:08:59 2025 -0500
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Mon Mar 10 01:46:50 2025 +0100

    tdf#165266 fix conditionals that limit -[NSApp setAppearance:] calls
    
    Calling -[NSApp setAppearance:] fires an NSNotification even if it is
    called with the curent appearance as parameter. To reduce the number
    of NSNotifications, commit 48125efbd7bf370981d48e4a8d0ce7fbaf1857e1
    attempted to limit the number of -[NSApp setAppearance:] calls but
    the conditionals were flipped and that commit ended up blocking
    -[NSApp setAppearance:] calls once it has already been set to a
    non-nil value.
    
    Also, sync NSView's appearance to NSApp's appearance. Invoking
    -[NSApp setAppearance:] does immediately update the appearance of
    each NSWindow's titlebar, but it does not appear to update any
    NSView's appearance so explicitly sync appearances.
    
    Change-Id: I996daa868807cd5e4c8194f80d1f783b9e6e4e63
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182655
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>
    Tested-by: Jenkins
    Reviewed-by: Patrick Luby <guibomac...@gmail.com>

diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx
index b69fb17b1dcf..f5823da6ab5f 100644
--- a/vcl/osx/salframe.cxx
+++ b/vcl/osx/salframe.cxx
@@ -1447,14 +1447,22 @@ void AquaSalFrame::UpdateDarkMode()
                 [NSApp setAppearance: nil];
             break;
         case 1: // light
-            if (!pCurrentAppearance || [NSAppearanceNameAqua isEqualToString: 
[pCurrentAppearance name]])
+            if (!pCurrentAppearance || ![NSAppearanceNameAqua isEqualToString: 
[pCurrentAppearance name]])
                 [NSApp setAppearance: [NSAppearance appearanceNamed: 
NSAppearanceNameAqua]];
             break;
         case 2: // dark
-            if (!pCurrentAppearance || [NSAppearanceNameDarkAqua 
isEqualToString: [pCurrentAppearance name]])
+            if (!pCurrentAppearance || ![NSAppearanceNameDarkAqua 
isEqualToString: [pCurrentAppearance name]])
                 [NSApp setAppearance: [NSAppearance appearanceNamed: 
NSAppearanceNameDarkAqua]];
             break;
     }
+
+    // Related: tdf#165266 sync NSView's appearance to NSApp's appearance
+    // Invoking -[NSApp setAppearance:] does immediately update the
+    // appearance of each NSWindow's titlebar, but it does not appear
+    // to update any NSView's appearance so explicitly sync appearances.
+    NSAppearance *pNewAppearance = [NSApp appearance];
+    if (mpNSView.appearance != pNewAppearance)
+        mpNSView.appearance = pNewAppearance;
 }
 
 bool AquaSalFrame::GetUseDarkMode() const

Reply via email to