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 );
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
Submitted as gerrit https://gerrit.libreoffice.org/16864
Fixed: http://cgit.freedesktop.org/libreoffice/core/commit/?id=f1faa887c0c934484fb32a8ec5fbbc9e89f38037
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.