-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
workspaces: when cycling through desktops RTL languages shift right too much. #1633
Comments
This is a weird bug. I put a hack in
The font extents were like so I think somehow in |
Hm.. yeah, I think there is a bug in the calculation of the available width; we do set the width available to pango to the whole available space rather than just the space required for the text, clamped by the whole available width. That should usually not be an issue but in this case of a RTL setting it means that pango will in fact use all the available width as it starts the text on the right rather than our pre-calculated center offset. This might fix it: diff --git a/src/workspaces.c b/src/workspaces.c
index e7707c5f..c8b1ac2c 100644
--- a/src/workspaces.c
+++ b/src/workspaces.c
@@ -118,18 +118,21 @@ _osd_update(struct server *server)
/* Text */
set_cairo_color(cairo, server->theme->osd_label_text_color);
PangoLayout *layout = pango_cairo_create_layout(cairo);
- pango_layout_set_width(layout, (width - 2 * margin) * PANGO_SCALE);
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
- PangoFontDescription *desc = font_to_pango_desc(&rc.font_osd);
- pango_layout_set_font_description(layout, desc);
/* Center workspace indicator on the x axis */
- x = font_width(&rc.font_osd, server->workspace_current->name);
- x = (width - x) / 2;
+ int req_width = font_width(&rc.font_osd, server->workspace_current->name);
+ if (req_width > width - 2 * margin) {
+ req_width = width - 2 * margin;
+ }
+ x = (width - req_width) / 2;
cairo_move_to(cairo, x, margin * 2 + rect_height);
+
+ PangoFontDescription *desc = font_to_pango_desc(&rc.font_osd);
//pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD);
pango_layout_set_font_description(layout, desc);
+ pango_layout_set_width(layout, req_width * PANGO_SCALE);
pango_font_description_free(desc);
pango_layout_set_text(layout, server->workspace_current->name, -1);
pango_cairo_show_layout(cairo, layout); |
Thanks to Consolatis for the patch.
So, when a feature is added then a bug is found! Re 5a20014
I found that when cycling trough desktops with an RTL locale (which I didn't test :( ) that the text is apparently on the wrong side of the desktop number. EDIT: no, the whole thing is pushed right, text is correct in relation to the number.
Works fine in the main window switcher osd so is probably a fairly simple fix. Maybe a pango option missing or something.
The text was updated successfully, but these errors were encountered: