Bug 32186 - Glitchs with GTK style
Summary: Glitchs with GTK style
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: UI (show other bugs)
(earliest affected)
Hardware: All Linux (All)
: medium normal
Assignee: Caolán McNamara
: 33473 (view as bug list)
Depends on:
Reported: 2010-12-07 08:52 UTC by Ruslan Kabatsayev
Modified: 2011-05-23 06:09 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:

Screenshot (44.06 KB, image/png)
2010-12-07 08:52 UTC, Ruslan Kabatsayev
This patch remove the problem (909 bytes, patch)
2011-01-22 10:58 UTC, Lucas Baudin
Fix some gtk widgets problem. (3.24 KB, patch)
2011-01-22 12:13 UTC, Lucas Baudin
Here is a screenshot of the improvements I made (49.70 KB, image/png)
2011-01-23 07:43 UTC, Lucas Baudin
the patch (4.46 KB, patch)
2011-01-23 07:45 UTC, Lucas Baudin
Comparison between LO/LO patched/Standard GTK (49.70 KB, image/png)
2011-01-23 07:47 UTC, Lucas Baudin

Note You need to log in before you can comment on or make changes to this bug.
Description Ruslan Kabatsayev 2010-12-07 08:52:23 UTC
Created attachment 40872 [details]

Currently, buttons are drawn on a background to take alpha-enabled buttons into account. Here's how it's done (clone/libs-gui/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx" line 1225):

// Buttons must paint opaque since some themes have alpha-channel enabled buttons
gtk_paint_flat_box( gWidgetData[m_nScreen].gBtnWidget->style, gdkDrawable, GTK_STATE_NORMAL, GTK_SHADOW_NONE, &clipRect, m_pWindow, "base", x, y, w, h );

This fails for themes with non-white background. In this case a rectangle of non-background color is seen around the button on the startup window, as in the screenshot attached. Of course, this looks ugly.
A fix would be to trigger native repaint of background before drawing the button instead of calling gtk_paint_flat_box().
Comment 1 Lucas Baudin 2011-01-22 10:58:44 UTC
Created attachment 42314 [details]
This patch remove the problem

This code is useless IMO. The comments before the code to draw the background says that a button can be transparent, but I think it is false, gtk only supports rgb, not rgba (it was a project, but it has been abandonned).

So, please apply the patch, the buttons look really better:
without the patch: http://pix.toile-libre.org/upload/original/1295720276.png (take a look at the buttons borders)
with it: http://pix.toile-libre.org/upload/original/1295720242.png

Since Ubuntu 11.04 will have LO by default, with the theme I showed in the screenshot (maybe not *exactly* the same theme, but it will look like it), it would be better if we could not have this glitch ^^.
Comment 2 Ruslan Kabatsayev 2011-01-22 11:22:24 UTC
(In reply to comment #1)

In fact, what this patch does was first what i tried - just removing these lines. But:
1. This doesn't work when a button had glow when prelit, then became pressed (and shouldn't have any glow in pressed state), but here's what i get:

> button can be transparent, but I think it is false, gtk only
> supports rgb, not rgba (it was a project, but it has been abandonned).
You're wrong. Oxygen supports ARGB pretty well. In fact, one can make internal images (GdkPixbuf's, cairo surfaces) have alpha channel as well as windows. See, e.g. oxygen-gtk engine (notice smooth menus corners and translucent tooltips (not for blacklisted apps for now though)).
The screenshot above proves this.
Also see this: http://mikehearn.wordpress.com/2006/03/26/gtk-windows-with-alpha-channels/

Conclusion: there should be call to invalidate the rectangle to draw native background first, before drawing the button.
Comment 3 Lucas Baudin 2011-01-22 12:06:23 UTC
Hum, yes, sorry, my patch was wrong. I understand the problem now.
We try to repain the base of the current button, but not the base of the window, so, it doesn't work. I am making another patch, and I am quite sure it will work fine :)

Sorry for the inconvenience :/
Comment 4 Lucas Baudin 2011-01-22 12:13:32 UTC
Created attachment 42317 [details]
Fix some gtk widgets problem.

So, here is the patch, now, I am sure it should work. We repaint the background of the window, not the background of the button (which is not properly set).

It also imacted scrollbars, and listbox.

There is still some issue with the "home page" of Libre Office, since it repaints the window background, which doesn't always equal the "home page" background (which is white).
Comment 5 Lucas Baudin 2011-01-22 12:57:56 UTC
So, for comparison, I made some screenshots:

At left, Libre Office "hacked", and at right, the standard one.
Comment 6 Lucas Baudin 2011-01-23 07:43:22 UTC
Created attachment 42335 [details]
Here is a screenshot of the improvements I made
Comment 7 Lucas Baudin 2011-01-23 07:45:50 UTC
Created attachment 42336 [details]
the patch

Please apply it, I think it doesn't cause any regressions. And if it causes a regression, I think it is a lot better now with most of the theme, like clearlooks (default gnome theme), or Ambiance (default Ubuntu theme).
Comment 8 Lucas Baudin 2011-01-23 07:47:30 UTC
Created attachment 42337 [details]
Comparison between LO/LO patched/Standard GTK

Again, the screenshot of the improvements I made, sorry, it is the first time I use bugzilla -.-
Comment 9 Ruslan Kabatsayev 2011-01-23 10:31:02 UTC
Latest patch (from comment #7) really makes most widgets look more as they should look, including menus which were broken since some openoffice version.
But entries are now broken: http://simplest-image-hosting.net/png-0-shot-081
Comment 10 Ruslan Kabatsayev 2011-01-23 10:43:41 UTC
(In reply to comment #9)
> Latest patch (from comment #7) really makes most widgets look more as they
> should look, including menus which were broken since some openoffice version.
> But entries are now broken: http://simplest-image-hosting.net/png-0-shot-081

Oh, well, not entries - i mean spinboxes.
Comment 11 Noel Power 2011-01-24 04:20:56 UTC
assigning to caolan ( I think he would be interested ) :-)
Comment 12 Michael Meeks 2011-01-24 06:01:14 UTC
Lucas - great work ! :-) normally, we expect patches to get sent to the dev mailing list: that is the best way to get wide review. Noel assigned this to Caolan - but I could review it (eg.).

Can you confirm, that you are taking the semantics of paint_flat_box / paint_box etc. from reading the gtk+ theme code more carefully than the original author ? :-)

Any chance you could test with the MeeGo theme - which does some very odd things to menu styles / coloring; cf. http://www.gnome.org/~michael/moblin-gtk-engine-1.2.3.tar.gz :-)

If so - we should merge this.
Comment 13 Noel Power 2011-01-25 10:29:19 UTC
*** Bug 33473 has been marked as a duplicate of this bug. ***
Comment 14 Michael Meeks 2011-01-27 03:19:23 UTC
By private mail from Lucas:

> 	Also - I assume your changes are under the LGPLv3+/MPL combination we
> > recommend - can you confirm that !
Yes, they are under LGPLv3+/MPL.

just for the records :-)
Comment 15 Michael Meeks 2011-01-28 05:48:57 UTC
fixes committed to master; I'm slightly nervous about putting them into 3.3.0 - but they'll be in 3.4.0 - coming soon; cf. http://wiki.documentfoundation.org/ReleasePlan
Comment 16 Alexander Wilms 2011-05-20 09:04:14 UTC
I am not sure if this can be fixed the same way as the glitch with the buttons, but I noticed that there are still some issues with the Ambiance theme. There is a 1px border and even thnative-gtk look differs from that. See for reference:


Comment 17 Caolán McNamara 2011-05-23 06:09:21 UTC
Re-opening a four month closed bug for a similar bug is a bad idea, please open a new bug for the other problem please.