This is an automated email from the ASF dual-hosted git repository.

leginee pushed a commit to branch mac-vcl-button-contrast
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 627096f5693f26aa4d61143b7c113e7cbcf1ab6a
Author: peter kovacs <[email protected]>
AuthorDate: Thu Sep 10 05:02:48 2026 +0200

    vcl: take the macOS palette from the system, run in the light appearance
    
    The aqua backend hardcoded its face colour to 0xECECEC and left the button
    label colours at VCL's COL_BLACK default, so the labels the backend draws
    itself did not follow the system at all. Read them from NSColor instead:
    
     - the face colour now comes from windowBackgroundColor, so it tracks the
       system rather than a literal that has to be maintained by hand
     - button labels come from controlTextColor
     - the default button, which the theme fills with the accent colour, gets
       alternateSelectedControlTextColor to go with it
    
    Pin the application to the Aqua appearance. This is deliberately not a
    palette workaround: with the above the style settings follow Dark Mode
    correctly. The blocker is artwork. All ~8000 images in images.zip are dark
    line art drawn for a light toolbar and are close to invisible on a dark one,
    and the only light-on-dark set that exists is images_hicontrast.zip, which 
is
    accessibility artwork rather than a dark theme.
    
    Removing the pin needs both a dark icon theme and a way for VCL to tell a
    dark colour scheme apart from high contrast mode. Today only
    StyleSettings::GetHighContrastMode() exists and its ~355 call sites conflate
    the two, which is a cross-platform problem rather than a macOS one.
    
    Co-Authored-By: Claude Opus 5 <[email protected]>
---
 main/vcl/aqua/source/app/salinst.cxx     | 12 ++++++++++++
 main/vcl/aqua/source/window/salframe.cxx | 21 ++++++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/main/vcl/aqua/source/app/salinst.cxx 
b/main/vcl/aqua/source/app/salinst.cxx
index 0cc37adeb7..df701e5bae 100644
--- a/main/vcl/aqua/source/app/salinst.cxx
+++ b/main/vcl/aqua/source/app/salinst.cxx
@@ -157,6 +157,18 @@ static void initNSApp()
     // activate our delegate methods
     [NSApp setDelegate: NSApp];
 
+    // Run in the light appearance regardless of the desktop setting. This is 
not
+    // a palette problem - the style settings are read from the system and 
follow
+    // Dark Mode correctly - but the icon sets are light-only artwork: all 
~8000
+    // images in images.zip are dark line art meant for a light toolbar, and 
they
+    // are close to invisible on a dark one. The only light-on-dark set that
+    // exists is images_hicontrast.zip, which is accessibility artwork rather
+    // than a dark theme. Remove this once a dark icon theme exists and VCL can
+    // tell a dark color scheme apart from high contrast mode (today only
+    // StyleSettings::GetHighContrastMode() exists, and its ~355 call sites
+    // conflate the two).
+    [NSApp setAppearance: [NSAppearance appearanceNamed: 
NSAppearanceNameAqua]];
+
     [[NSNotificationCenter defaultCenter] addObserver: NSApp
                                           selector: 
@selector(systemColorsChanged:)
                                           name: 
NSSystemColorsDidChangeNotification
diff --git a/main/vcl/aqua/source/window/salframe.cxx 
b/main/vcl/aqua/source/window/salframe.cxx
index 8638e68e8b..e40baa31ae 100644
--- a/main/vcl/aqua/source/window/salframe.cxx
+++ b/main/vcl/aqua/source/window/salframe.cxx
@@ -1248,7 +1248,12 @@ void AquaSalFrame::UpdateSettings( AllSettings& 
rSettings )
     StyleSettings aStyleSettings = rSettings.GetStyleSettings();
 
     // Background Color
-    Color aBackgroundColor = Color( 0xEC, 0xEC, 0xEC );
+    // Follow the system appearance rather than a fixed light palette: this is
+    // the colour AppKit paints window backgrounds with, so it tracks Dark Mode
+    // along with the NSColor lookups below and with what HITheme draws. The
+    // literal is only a fallback for a colour that fails to convert.
+    Color aBackgroundColor = getColor( [NSColor windowBackgroundColor],
+                                       Color( 0xEC, 0xEC, 0xEC ), mpNSWindow );
     aStyleSettings.Set3DColors( aBackgroundColor );
     aStyleSettings.SetFaceColor( aBackgroundColor );
     Color aInactiveTabColor( aBackgroundColor );
@@ -1310,6 +1315,20 @@ void AquaSalFrame::UpdateSettings( AllSettings& 
rSettings )
     aStyleSettings.SetMenuTextColor( aMenuTextColor );
     aStyleSettings.SetMenuBarTextColor( aMenuTextColor );
 
+    // the aqua backend has the system paint the control background, but draws
+    // button labels itself, so the label colors have to be taken from the
+    // system explicitly - otherwise they stay at VCL's COL_BLACK default
+    Color aControlTextColor( getColor( [NSColor controlTextColor],
+                                       aStyleSettings.GetButtonTextColor(), 
mpNSWindow ) );
+    aStyleSettings.SetButtonTextColor( aControlTextColor );
+    aStyleSettings.SetButtonRolloverTextColor( aControlTextColor );
+
+    // the default button gets filled with the system accent color, so its
+    // label needs the matching foreground rather than the control text color
+    Color aDefaultButtonTextColor( getColor( [NSColor 
alternateSelectedControlTextColor],
+                                             Color( 0xFF, 0xFF, 0xFF ), 
mpNSWindow ) );
+    aStyleSettings.SetDefaultButtonTextColor( aDefaultButtonTextColor );
+
     aStyleSettings.SetCursorBlinkTime( 500 );
 
     // no mnemonics on aqua

Reply via email to