Bug 92243 - Menu highlighting incorrect with libreoffice-gtk
Summary: Menu highlighting incorrect with libreoffice-gtk
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: UI (show other bugs)
Version:
(earliest affected)
4.3.3.2 release
Hardware: Other All
: low minor
Assignee: Simon Long
URL:
Whiteboard: target:5.1.0 target:5.0.1
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-22 09:32 UTC by Simon Long
Modified: 2016-10-25 19:20 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.