summaryrefslogtreecommitdiffstats
path: root/src/client/qwaylandwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/qwaylandwindow.cpp')
-rw-r--r--src/client/qwaylandwindow.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index ccfcaf933..ae26ba049 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -298,8 +298,10 @@ void QWaylandWindow::setWindowTitle(const QString &title)
const QString formatted = formatWindowTitle(title, separator);
const int libwaylandMaxBufferSize = 4096;
- // Some parts of the buffer is used for metadata, so subtract 100 to be on the safe side
- const int maxLength = libwaylandMaxBufferSize - 100;
+ // Some parts of the buffer is used for metadata, so subtract 100 to be on the safe side.
+ // Also, QString is in utf-16, which means that in the worst case each character will be
+ // three bytes when converted to utf-8 (which is what libwayland uses), so divide by three.
+ const int maxLength = libwaylandMaxBufferSize / 3 - 100;
auto truncated = QStringRef(&formatted).left(maxLength);
if (truncated.length() < formatted.length()) {