Comments (3)
This is a weird bug. I put a hack in osd.c
and workspaces.c
printing x
to file (the cairo x coordinate for text position) and here's the result:
68 [en - wkspces]
68
68
68
68
68
68
68
258 [en - osd]
258
66 [ar - wkspces]
66
66
66
66
66
66
256 [ar - osd]
256
256
The font extents were like so 84 [en]
and 87 [ar]
in both osd.c
and workspaces.c
so there is no error in the math. I didn't expect so but I did suspect maybe something weird was happening in font_width()
.
I think somehow in workspaces.c
the logic maybe out?
from labwc.
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);
from labwc.
Nice!
from labwc.
Related Issues (20)
- Inhibit idle question HOT 2
- Debian Packaging - Fixing Terminal Recommends HOT 10
- Add user-configurable blocklist for the security-context implementation
- Touchscreen bindings? HOT 4
- tilde symbol in pipemenus might be causing issues with commands? HOT 1
- Set the LANG in $HOME/.config/labwc/environment , It don't take effect on the menu of windows title. HOT 21
- firefox --kiosk: starts but does not show a window at all HOT 10
- Conditional actions example HOT 1
- Flickering with magnifier and gammastep HOT 12
- Plan for release `0.7.3` HOT 3
- Dual graphic card HOT 2
- gamma control of output 43 failed when launching wlsunset HOT 2
- DnD between wayland and xwayland not working HOT 6
- [Question] max_render_time adjustment setting? HOT 6
- Labwc allegedly slow to send fractional scale to applications HOT 4
- Assertion failed at `wlr_libinput_get_device_handle()` in nested session HOT 2
- Very odd Thonny behaviour when unmaximising a window HOT 4
- XDG configure state gets out of sync when clients timeout HOT 5
- Modal dialogs appear behind toplevel window if set by layer-shell-qt HOT 19
- Theme title bars not having all the Openbox features HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from labwc.