KWin
Loading...
Searching...
No Matches
quirks.h
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2024 David Edmundson <kde@davidedmundson.co.uk>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6#pragma once
7
8#include <QString>
9
10namespace KWin
11{
12
17static inline QString truncate(const QString &stringIn)
18{
19 const int libwaylandMaxBufferSize = 4096;
20 // Some parts of the buffer is used for metadata, so subtract 100 to be on the safe side.
21 // Also, QString is in utf-16, which means that in the worst case each character will be
22 // three bytes when converted to utf-8 (which is what libwayland uses), so divide by three.
23 const int maxLength = libwaylandMaxBufferSize / 3 - 100;
24 return stringIn.left(maxLength);
25}
26
27} // namespace KWin