mate-desktop / marco

MATE default window manager
https://mate-desktop.org
GNU General Public License v2.0
196 stars 87 forks source link

Window title disappears when the first character is Chinese #757

Closed cloudfish closed 1 year ago

cloudfish commented 1 year ago

Expected behaviour

Marco displays a window title starting with a character >= 3 bytes long.

Actual behaviour

Marco does not display a window title starting with a character >= 3 bytes long.

Steps to reproduce the behaviour

Open https://zh.wikipedia.org with firefox. The titlebar of firefox window does not contain a title.

MATE general version

1.26.1

Package version

marco 1.26.2

Linux Distribution

Debian

Link to bugreport of your Distribution (requirement)

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1041196

It seems that the fix for #749 caused this. Most Chinese characters are 3 bytes long under UTF-8, and UTF-8 characters can be as long as 4 bytes. So "g_utf8_strlen (title, 2) < 1" will be true if the first character is Chinese.

lukefromdc commented 1 year ago

I renamed a video file with a filename so long the title stretched across the window, opened it in firefox (which can play local video) and marco rendered the title. NO title on the named website, though I do not have any fonts relevent to that alphabet installed. Don't know if that issue is font specific.

cloudfish commented 1 year ago

I assume if fonts in the system do not support CJK characters, then only the CJK characters will be affected, not the entire title.

You can try opening https://www.debian.org/index.zh-cn.html with firefox. CJK characters will be in the middle of the title, not at the beginning. The title will be rendered correctly.

lukefromdc commented 1 year ago

This is what I got in firefox w marco as WM on that site, same as in compiz (which by the way uses part of marco to render decorations in most builds of the 0.8 branch) Debian_in_firefox

cloudfish commented 1 year ago

This is what I got in firefox w marco as WM on that site, same as in compiz (which by the way uses part of marco to render decorations in most builds of the 0.8 branch))

This result is expected. Font issue should not make the entire title disappear. So if you open zh.wikipedia.org the title bar should still end with "Mozilla Firefox".

The issue does not affect 1.26.1, so maybe commit 319ee4f caused the issue.

cwendling commented 1 year ago

@cloudfish thanks for the detailed report, and even locating the problematic commit :) #758 should fix it.

lukefromdc commented 1 year ago

Issue confirmed here, and it affects only marco and not compiz's use of marco for the gtk-window-decorator

raveit65 commented 1 year ago

What's wrong with the tile of the window (it's not a bar)? With fedora 38: Bildschirmfoto zu 2023-07-19 11-21-42

cwendling commented 1 year ago

@raveit65 with which Marco version? I confirm the OP, that with #749 and without this PR I get an empty title if the first character uses more than 2 bytes in UTF-8 (like the one you display) -- and it makes sense, as it counts characters only in the first 2 bytes, so anything longer will not be counted (depending on how GLib counts, but it's how it works here)

raveit65 commented 1 year ago

Ahh, my version is from master but without https://github.com/mate-desktop/marco/issues/749 and the meson commits. Will rebuild marco to reproduce the issue.

raveit65 commented 1 year ago

Indeed, window decoration title is gone of https://zh.wikipedia.org/ when building from latest master.