After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 635686 - button backgrounds broken with rtl locales
button backgrounds broken with rtl locales
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: general
git master
Other Linux
: Normal critical
: ---
Assigned To: mutter-maint
mutter-maint
Depends on:
Blocks: 604237 635683
 
 
Reported: 2010-11-24 12:28 UTC by Lapo Calamandrei
Modified: 2011-01-04 21:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proto gnome3 theme (57.99 KB, text/xml)
2010-11-24 12:28 UTC, Lapo Calamandrei
  Details
buttons: Fix background functions for non-default layouts (9.77 KB, patch)
2010-12-02 00:39 UTC, Florian Müllner
none Details | Review
buttons: Fix background functions for non-default layouts (9.77 KB, patch)
2010-12-02 01:27 UTC, Florian Müllner
none Details | Review
buttons: Fix background functions for non-default layouts (8.87 KB, patch)
2010-12-03 00:22 UTC, Florian Müllner
needs-work Details | Review
buttons: Fix background functions for non-default layouts (6.74 KB, patch)
2010-12-07 19:31 UTC, Florian Müllner
needs-work Details | Review
In reply to comment #7) (6.80 KB, patch)
2011-01-04 20:41 UTC, Florian Müllner
committed Details | Review

Description Lapo Calamandrei 2010-11-24 12:28:46 UTC
Created attachment 175157 [details]
proto gnome3 theme

With buttons on the left side button backgrounds for pressed and prelight states doesn't work.
To reproduce use the attached xml and set /desktop/gnome/shell/windows/button_layout to "close,maximize,minimize:" or set a rtl locale. The button background drawn is only the one for normal state.
Comment 1 Florian Müllner 2010-11-25 23:55:55 UTC
I haven't tracked it down yet, but it appears that the problem is not directly related to rtl locales - the positional button functions (left_right_background, right_left_background) appear to be broken for any button order not being minimize,maximize,close - e.g. changing the layout to :close,minimize,maximize messes up the prelight/pressed states as well.
Comment 2 Florian Müllner 2010-12-02 00:39:40 UTC
Created attachment 175686 [details] [review]
buttons: Fix background functions for non-default layouts

While the configured layout is taken into account for positioning
the buttons, the mapping from button function states to button
position states just assumed the default button layout in LTR
locales.
Do a proper mapping depending on the actual layout instead.

I'm not entirely happy with the patch, but putting up for comments anyway:
 1. It feels like duplicating code (even though strictly speaking
    it doesn't)
 2. The handling of the (LEFT|RIGHT)_MIDDLE_BACKGROUND functions is not
    correct when used more than once - the problem is that this case is
    handled for positioning, but not for states.
    (But then, it's not worse than before ...)
Comment 3 Florian Müllner 2010-12-02 01:27:29 UTC
Created attachment 175690 [details] [review]
buttons: Fix background functions for non-default layouts

Actually got it wrong and had to swap two constants ...
Comment 4 Florian Müllner 2010-12-03 00:22:47 UTC
Created attachment 175747 [details] [review]
buttons: Fix background functions for non-default layouts

Moved the mapping from button function states to button position states entirely into ui/theme.c - looks a bit cleaner to me.
Comment 5 Owen Taylor 2010-12-06 14:13:47 UTC
Review of attachment 175747 [details] [review]:

::: src/ui/frames.c
@@ -2402,3 @@
-  /* Map button function states to button position states */
-  button_states[META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND] =
-    button_states[META_BUTTON_TYPE_MENU];

Somehow the code here is nonsense and nobody has noticed for a long time. There can be more than one button of type left_middle_background/right_middle_background so keeping track of button state by the "button position" button types doesn't make sense.

In my opinion, meta_frame_layout_calc_geometry() needs to save the MetaButtonLayout that is passed in the MetaFrameLayout() and then the button states should be passed in to 
meta_frame_style_draw_with_style() only for the real button type, and not the background. When drawing a real button, we can then use the saved MetaButtonLayout to map.
Comment 6 Florian Müllner 2010-12-07 19:31:31 UTC
Created attachment 176024 [details] [review]
buttons: Fix background functions for non-default layouts

Updated to save the layout and do the mapping in meta_frame_style_draw_with_style().
Comment 7 Owen Taylor 2011-01-04 17:12:37 UTC
Review of attachment 176024 [details] [review]:

In frames.c

  MetaButtonLayout button_layout;
  
[...]

  meta_prefs_get_button_layout (&button_layout);
  
  meta_theme_calc_geometry (meta_theme_get_current (),
                            type,
                            frame->text_height,
                            flags,
                            width, height,
                            &button_layout,
                            fgeom);

So,

fgeom->button_layout = (MetaButtonLayout *)button_layout;

Looks really suspicious to me, like we're saving a pointer to an automatic variable. It would seem more reasonable to me to have fgeom have a by-value MetaButtonLayout and do:

 fgeom->button_layout = *button_layout

Otherwise looks fine for me except for a small comment

::: src/ui/theme.c
@@ +4261,3 @@
+    /* Map position buttons to the corresponding function */
+    case META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND:
+      function = fgeom->button_layout->right_buttons[0];

Shouldn't you check 

 if (fgeom->n_right_buttons > 0)

as you do elsewhere? Seems to be as necessary here.

@@ +4272,3 @@
+      break;
+    case META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND:
+      function = fgeom->button_layout->left_buttons[0];

As above
Comment 8 Florian Müllner 2011-01-04 20:41:30 UTC
Created attachment 177517 [details] [review]
In reply to comment #7)

> Looks really suspicious to me, like we're saving a pointer to an automatic
> variable. It would seem more reasonable to me to have fgeom have a by-value
> MetaButtonLayout and do:
> 
>  fgeom->button_layout = *button_layout

OK.


> Shouldn't you check 
> 
>  if (fgeom->n_right_buttons > 0)
> 
> as you do elsewhere? Seems to be as necessary here.

Yeah.
Comment 9 Owen Taylor 2011-01-04 21:00:02 UTC
Review of attachment 177517 [details] [review]:

Looks good