Skip to content

Commit cbb969d

Browse files
committed
Merge remote-tracking branch 'origin/pr/227'
* origin/pr/227: Change end of trimmed long window titles to U+2026
2 parents 774ee8f + 474efd5 commit cbb969d

File tree

6 files changed

+30
-1
lines changed

6 files changed

+30
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ xf86-qubes-common/libxf86-qubes-common.so
1212
/pipewire/pw-module-run
1313
*.dep
1414
/gui-agent/qubes-gui
15+
/gui-agent/qubes-gui-runuser
1516
/gui-common/qubes-gui-runuser

archlinux/PKGBUILD.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ makedepends=(
2323
libxcomposite
2424
libxt
2525
libxdamage
26+
libunistring
2627
pixman
2728
lsb-release
2829
'qubes-vm-gui-common>=4.3.0'
@@ -57,6 +58,7 @@ package_qubes-vm-gui() {
5758
'zenity'
5859
'qubes-libvchan'
5960
'python-xcffib'
61+
'libunistring'
6062
# Xorg dependencies are on specific ABI versions: https://www.x.org/wiki/XorgModuleABIVersions/
6163
# These can also be verified with pacman -Qi xorg-server (Provides)
6264
# There is however a discrepancy if verifying via pkg-config --variable abi_videodrv xorg-server

debian/control

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Build-Depends:
2525
qubes-gui-common (>= 4.3.0),
2626
qubesdb-dev,
2727
libltdl-dev,
28+
libunistring-dev,
2829
Standards-Version: 4.4.0.1
2930
Homepage: http://www.qubes-os.org/
3031
#Vcs-Git: git://git.debian.org/collab-maint/qubes-gui-agent.git

gui-agent/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ CFLAGS += -I../include/ `pkg-config --cflags vchan` -g -Wall -Wextra -Werror -fP
2424
-Wmissing-prototypes -Wstrict-prototypes -Wold-style-declaration \
2525
-Wold-style-definition
2626
OBJS = vmside.o txrx-vchan.o error.o list.o encoding.o
27-
LIBS = -lX11 -lXdamage -lXcomposite -lXfixes `pkg-config --libs vchan` -lqubesdb
27+
LIBS = -lX11 -lXdamage -lXcomposite -lXfixes `pkg-config --libs vchan` -lqubesdb \
28+
-lunistring
2829

2930

3031
all: qubes-gui qubes-gui-runuser

gui-agent/vmside.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
#include "encoding.h"
5454
#include <libvchan.h>
5555
#include <poll.h>
56+
#include "unistr.h"
5657

5758

5859
#include <linux/input.h>
@@ -651,6 +652,27 @@ void send_wmname(Ghandles * g, XID window)
651652
if (!get_net_wmname(g, window, msg.data, sizeof(msg.data)))
652653
if (!getwmname_tochar(g, window, msg.data, sizeof(msg.data)))
653654
return;
655+
if (strlen(msg.data) == sizeof(msg.data) - 1) {
656+
// Window title might had been longer than output buffer.
657+
// Trim at correct utf8 boundary and set end to U+2026 (Horizontal Ellipsis)
658+
msg.data[sizeof(msg.data) - 4] = 0;
659+
for (int i=0; i < 4; i++) {
660+
uint8_t * last_byte = (uint8_t *)msg.data + sizeof(msg.data) - 5 - i;
661+
// check for valid 1, 2, 3 or 4 byte uft8 char at the end of string
662+
if (
663+
!u8_check(last_byte, 1) ||
664+
!u8_check(last_byte - 1, 2) ||
665+
!u8_check(last_byte - 2, 3) ||
666+
!u8_check(last_byte - 3, 4)
667+
) {
668+
break;
669+
} else {
670+
// trim one invalid byte at end of string
671+
*last_byte = 0;
672+
}
673+
}
674+
strncat(msg.data, "\xE2\x80\xA6", sizeof(msg.data) - 1);
675+
}
654676
hdr.window = window;
655677
hdr.type = MSG_WMNAME;
656678
write_message(g->vchan, hdr, msg);

rpm_spec/gui-agent.spec.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ BuildRequires: qubes-gui-common-devel >= 4.3.0
7575
BuildRequires: qubes-db-devel
7676
BuildRequires: xen-devel
7777
BuildRequires: systemd-rpm-macros
78+
BuildRequires: libunistring-devel
7879
%if 0%{?is_opensuse}
7980
# for directory ownership
8081
BuildRequires: xinit
@@ -102,6 +103,7 @@ Requires: xev
102103
Requires: xdpyinfo
103104
Requires: xprop
104105
Requires: xrandr
106+
Requires: libunistring
105107

106108
Provides: qubes-gui-vm = %{version}-%{release}
107109
Obsoletes: qubes-gui-vm < 4.0.0

0 commit comments

Comments
 (0)