vcl/win/window/salframe.cxx | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-)
New commits: commit 75fd9e5a6947bc370cf230afe32bbf755a91e2ea Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Fri Oct 7 12:38:58 2022 +0100 Commit: Adolfo Jayme Barrientos <fit...@ubuntu.com> CommitDate: Sun Oct 9 04:36:38 2022 +0200 Related: tdf#98067 get high contrast hover/default button text color right Normal and high contrast themes seem to behave differently (in Windows 10) to play more directly with themes than the usual ui try: Press Windows Key + R and paste: shell:::{ED834ED6-4B5A-4bfe-8F11-A626DCB6A921} -Microsoft.Personalization\pageColorization High Contrast themes seem different to the others, with a high contrast theme set then its possible to customize the colors, otherwise not. Playing with 'Selected Text' it seems that this is the color used for the active/hover button text color with a high contrast theme. Change-Id: I561616fce6a6f6d781e4881bfdf8ba0abedcd75c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141074 Tested-by: Jenkins Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx index db4da4e3e076..da4f054720d8 100644 --- a/vcl/win/window/salframe.cxx +++ b/vcl/win/window/salframe.cxx @@ -2635,6 +2635,15 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings ) StyleSettings aStyleSettings = rSettings.GetStyleSettings(); + // High contrast + HIGHCONTRAST hc; + hc.cbSize = sizeof( HIGHCONTRAST ); + if( SystemParametersInfoW( SPI_GETHIGHCONTRAST, hc.cbSize, &hc, 0 ) + && (hc.dwFlags & HCF_HIGHCONTRASTON) ) + aStyleSettings.SetHighContrastMode( true ); + else + aStyleSettings.SetHighContrastMode( false ); + aStyleSettings.SetScrollBarSize( GetSystemMetrics( SM_CXVSCROLL ) ); aStyleSettings.SetSpinSize( GetSystemMetrics( SM_CXVSCROLL ) ); UINT blinkTime = GetCaretBlinkTime(); @@ -2650,6 +2659,7 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings ) Color aControlTextColor; Color aMenuBarTextColor; Color aMenuBarRolloverTextColor; + Color aHighlightTextColor = ImplWinColorToSal(GetSysColor(COLOR_HIGHLIGHTTEXT)); const bool bUseDarkMode(UseDarkMode()); @@ -2700,7 +2710,7 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings ) aStyleSettings.SetRadioCheckTextColor( ImplWinColorToSal( GetSysColor( COLOR_WINDOWTEXT ) ) ); aStyleSettings.SetMenuTextColor( ImplWinColorToSal( GetSysColor( COLOR_MENUTEXT ) ) ); aMenuBarTextColor = ImplWinColorToSal( GetSysColor( COLOR_MENUTEXT ) ); - aMenuBarRolloverTextColor = ImplWinColorToSal( GetSysColor( COLOR_HIGHLIGHTTEXT ) ); + aMenuBarRolloverTextColor = aHighlightTextColor; } if ( std::optional<Color> aColor = aStyleSettings.GetPersonaMenuBarTextColor() ) @@ -2723,16 +2733,19 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings ) aStyleSettings.SetDialogColor(aStyleSettings.GetFaceColor()); aStyleSettings.SetDialogTextColor(aControlTextColor); - aStyleSettings.SetDefaultButtonTextColor(aControlTextColor); + Color aHighlightButtonTextColor = aStyleSettings.GetHighContrastMode() ? + aHighlightTextColor : aControlTextColor; + + aStyleSettings.SetDefaultButtonTextColor(aHighlightButtonTextColor); aStyleSettings.SetButtonTextColor(aControlTextColor); - aStyleSettings.SetDefaultActionButtonTextColor(aControlTextColor); + aStyleSettings.SetDefaultActionButtonTextColor(aHighlightButtonTextColor); aStyleSettings.SetActionButtonTextColor(aControlTextColor); aStyleSettings.SetFlatButtonTextColor(aControlTextColor); - aStyleSettings.SetDefaultButtonRolloverTextColor(aControlTextColor); - aStyleSettings.SetButtonRolloverTextColor(aControlTextColor); - aStyleSettings.SetDefaultActionButtonRolloverTextColor(aControlTextColor); - aStyleSettings.SetActionButtonRolloverTextColor(aControlTextColor); - aStyleSettings.SetFlatButtonRolloverTextColor(aControlTextColor); + aStyleSettings.SetDefaultButtonRolloverTextColor(aHighlightButtonTextColor); + aStyleSettings.SetButtonRolloverTextColor(aHighlightButtonTextColor); + aStyleSettings.SetDefaultActionButtonRolloverTextColor(aHighlightButtonTextColor); + aStyleSettings.SetActionButtonRolloverTextColor(aHighlightButtonTextColor); + aStyleSettings.SetFlatButtonRolloverTextColor(aHighlightButtonTextColor); aStyleSettings.SetDefaultButtonPressedRolloverTextColor(aControlTextColor); aStyleSettings.SetButtonPressedRolloverTextColor(aControlTextColor); aStyleSettings.SetDefaultActionButtonPressedRolloverTextColor(aControlTextColor); @@ -2750,7 +2763,7 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings ) aStyleSettings.SetFieldTextColor( aStyleSettings.GetWindowTextColor() ); aStyleSettings.SetFieldRolloverTextColor( aStyleSettings.GetFieldTextColor() ); aStyleSettings.SetHighlightColor( ImplWinColorToSal( GetSysColor( COLOR_HIGHLIGHT ) ) ); - aStyleSettings.SetHighlightTextColor( ImplWinColorToSal( GetSysColor( COLOR_HIGHLIGHTTEXT ) ) ); + aStyleSettings.SetHighlightTextColor(aHighlightTextColor); aStyleSettings.SetMenuHighlightColor( aStyleSettings.GetHighlightColor() ); aStyleSettings.SetMenuHighlightTextColor( aStyleSettings.GetHighlightTextColor() ); @@ -2796,15 +2809,6 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings ) if( SystemParametersInfoW( SPI_GETCARETWIDTH, 0, &nCaretWidth, 0 ) ) aStyleSettings.SetCursorSize( nCaretWidth ); - // High contrast - HIGHCONTRAST hc; - hc.cbSize = sizeof( HIGHCONTRAST ); - if( SystemParametersInfoW( SPI_GETHIGHCONTRAST, hc.cbSize, &hc, 0 ) - && (hc.dwFlags & HCF_HIGHCONTRASTON) ) - aStyleSettings.SetHighContrastMode( true ); - else - aStyleSettings.SetHighContrastMode( false ); - // Query Fonts vcl::Font aMenuFont = aStyleSettings.GetMenuFont(); vcl::Font aTitleFont = aStyleSettings.GetTitleFont();