Bug 92243

Summary: Menu highlighting incorrect with libreoffice-gtk
Product: LibreOffice Reporter: Simon Long <simon>
Component: UIAssignee: Simon Long <simon>
Status: RESOLVED FIXED    
Severity: minor CC: h3734236
Priority: low    
Version: 4.3.3.2 release   
Hardware: Other   
OS: All   
See Also: https://bugs.documentfoundation.org/show_bug.cgi?id=46973
Whiteboard: target:5.1.0 target:5.0.1
Crash report or crash signature: Regression By:

Description Simon Long 2015-06-22 09:32:57 UTC
If the libreoffice-gtk library is loaded, the menu highlight colours are not correctly loaded from the GTK theme. The highlight colour itself is correct, but the foreground colour used by native GTK applications is ignored. The following patch fixes this and uses the correct text highlight colour:

--- vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
+++ vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
@@ -3870,9 +3875,7 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings )
     }
 
     aHighlightColor = getColor( pMenuItemStyle->bg[ GTK_STATE_SELECTED ] );
-    aHighlightTextColor = getColor( pMenuTextStyle->fg[ GTK_STATE_PRELIGHT ] );
-    if( aHighlightColor == aHighlightTextColor )
-        aHighlightTextColor = (aHighlightColor.GetLuminance() < 128) ? Color( COL_WHITE ) : Color( COL_BLACK );
+    aHighlightTextColor = getColor( pMenuItemStyle->fg[ GTK_STATE_SELECTED ] );
     aStyleSet.SetMenuHighlightColor( aHighlightColor );
     aStyleSet.SetMenuHighlightTextColor( aHighlightTextColor );
 
However, this reveals another bug, which is that the highlight colour is also used for the menu header when active, which should not happen in a native GTK application. This is fixed by the following patch:

--- vcl/source/window/menu.cxx
+++ vcl/source/window/menu.cxx
@@ -2642,6 +2642,8 @@ void Menu::ImplPaint( Window* pWin, sal_uInt16 nBorder, long nStartY, MenuItemDa
             {
                 if ( bIsMenuBar && bRollover )
                     pWin->SetTextColor( rSettings.GetMenuBarRolloverTextColor() );
+                else if ( bIsMenuBar )
+                    pWin->SetTextColor( rSettings.GetMenuBarTextColor() );
                 else if ( bHighlighted )
                     pWin->SetTextColor( rSettings.GetMenuHighlightTextColor() );
             }
Comment 1 Adolfo Jayme Barrientos 2015-06-22 17:26:16 UTC
Confirming. Same comment as in bug 92244. Thank you again!
Comment 2 Simon Long 2015-07-08 13:16:03 UTC
Now submitted to gerrit as https://gerrit.libreoffice.org/#/c/16856/
Comment 3 Commit Notification 2015-07-09 10:35:26 UTC
Simon Long committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=ae4ec7a75b0048af2fba12953a84fe5b26d89b9a

tdf#92243 Read menu highlight text colour correctly from GTK theme

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 4 Commit Notification 2015-07-11 19:33:34 UTC
Simon Long committed a patch related to this issue.
It has been pushed to "libreoffice-5-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=86deb192de0803b5c59a4b07590b3d725f22c089&h=libreoffice-5-0

tdf#92243 Read menu highlight text colour correctly from GTK theme

It will be available in 5.0.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.