Bug 92244 - Menu separator spacing incorrect in libreoffice-gtk
Summary: Menu separator spacing incorrect in 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:40 UTC by Simon Long
Modified: 2016-10-25 19:23 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:
Regression By:


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:40:06 UTC
If the libreoffice-gtk library is used, the appearance of menu separator lines does not match that in native GTK applications; specifically with regards the gap at the start and end of the line. This is largely caused by the menu separator widget not being treated differently from the menu item widget when the parameters are read in from the GTK theme.

Patch as follows. This introduces a new parameter in the ImplSVNWFData structure which stores the menu separator border read from the GTK theme, which is then used when the separator is drawn.

diff --git vcl/inc/svdata.hxx vcl/inc/svdata.hxx
index 7fa60e3..538f7a7 100644
--- vcl/inc/svdata.hxx
+++ vcl/inc/svdata.hxx
@@ -253,6 +253,7 @@ struct ImplSVNWFData
     int                     mnStatusBarLowerRightOffset;    // amount in pixel to avoid in the lower righthand corner
     int                     mnMenuFormatBorderX;            // horizontal inner popup menu border
     int                     mnMenuFormatBorderY;            // vertical inner popup menu border
+    int                     mnMenuSeparatorBorderX;         // gap at each side of separator
     ::Color                 maMenuBarHighlightTextColor;    // override higlight text color
                                                             // in menubar if not transparent
     bool                    mbMenuBarDockingAreaCommonBG:1; // e.g. WinXP default theme
diff --git vcl/source/window/menu.cxx vcl/source/window/menu.cxx
index 9a7e73b..b3b4ed3 100644
--- vcl/source/window/menu.cxx
+++ vcl/source/window/menu.cxx
@@ -2682,9 +2684,12 @@ void Menu::ImplPaint( Window* pWin, sal_uInt16 nBorder, long nStartY, MenuItemDa
                             nState |= CTRL_STATE_ENABLED;
                         if ( bHighlighted )
                             nState |= CTRL_STATE_SELECTED;
+                        int nSepPad = ImplGetSVData()->maNWFData.mnMenuSeparatorBorderX;
+                        Point aMpos (aPos);
+                        aMpos.X() += nSepPad;
                         Size aSz( pData->aSz );
-                        aSz.Width() = aOutSz.Width() - 2*nOuterSpaceX;
-                        Rectangle aItemRect( aPos, aSz );
+                        aSz.Width() = aOutSz.Width() - 2*nOuterSpaceX - 2 * nSepPad;
+                        Rectangle aItemRect( aMpos, aSz );
                         MenupopupValue aVal( nTextPos-GUTTERBORDER, aItemRect );
                         bNativeOk = pWin->DrawNativeControl( CTRL_MENU_POPUP, PART_MENU_SEPARATOR,
                                                              aItemRect,
diff --git vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
index b1e7e23..1d9cf11 100644
--- vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
+++ vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
@@ -430,16 +430,21 @@ void GtkData::initNWF( void )
     NWEnsureGTKMenu( SalX11Screen( 0 ) );
     gint horizontal_padding = 1;
     gint vertical_padding = 1;
+    gint separator_padding = 1;
     gtk_widget_style_get( gWidgetData[0].gMenuWidget,
             "horizontal-padding", &horizontal_padding,
             (char *)NULL);
     gtk_widget_style_get( gWidgetData[0].gMenuWidget,
             "vertical-padding", &vertical_padding,
             (char *)NULL);
+    gtk_widget_style_get( gWidgetData[0].gMenuItemSeparatorMenuWidget,
+            "horizontal-padding", &separator_padding,
+            (char *)NULL);
     gint xthickness = gWidgetData[0].gMenuWidget->style->xthickness;
     gint ythickness = gWidgetData[0].gMenuWidget->style->ythickness;
     pSVData->maNWFData.mnMenuFormatBorderX = xthickness + horizontal_padding;
     pSVData->maNWFData.mnMenuFormatBorderY = ythickness + vertical_padding;
+    pSVData->maNWFData.mnMenuSeparatorBorderX = separator_padding;
 
     if( SalGetDesktopEnvironment() == "KDE" )
     {
@@ -4384,7 +4387,7 @@ static void NWEnsureGTKMenu( SalX11Screen nScreen )
         gWidgetData[nScreen].gMenuItemMenuWidget          = gtk_menu_item_new_with_label( "b" );
         gWidgetData[nScreen].gMenuItemCheckMenuWidget     = gtk_check_menu_item_new_with_label( "b" );
         gWidgetData[nScreen].gMenuItemRadioMenuWidget     = gtk_radio_menu_item_new_with_label( NULL, "b" );
-        gWidgetData[nScreen].gMenuItemSeparatorMenuWidget = gtk_menu_item_new();
+        gWidgetData[nScreen].gMenuItemSeparatorMenuWidget = gtk_separator_menu_item_new();
         gWidgetData[nScreen].gImageMenuItem               = gtk_image_menu_item_new();
 
         gtk_menu_shell_append( GTK_MENU_SHELL( gWidgetData[nScreen].gMenuWidget ), gWidgetData[nScreen].gMenuItemMenuWidget );
Comment 1 Adolfo Jayme Barrientos 2015-06-22 16:37:28 UTC
Simon: thank you very much for the report and the patch!

It will be much easier to review if you submit it via Gerrit as described here: https://wiki.documentfoundation.org/Development/gerrit
Comment 2 Simon Long 2015-07-08 14:28:15 UTC
Submitted as gerrit https://gerrit.libreoffice.org/16864
Comment 4 Commit Notification 2015-07-10 19:49:19 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=607af001ccdbfe40b089942b879e5ce3980bde49&h=libreoffice-5-0

tdf#92244 Gaps at end of menu separator lines read 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.