blob: 260b7c248c977fcda63f0b236c32bd1610968aa0 (
plain)
1 From 54aa63be9b74e8de72db9efbe6809ab1a97b29a7 Mon Sep 17 00:00:00 2001
2 From: Takao Fujiwara <takao.fujiwara1@gmail.com>
3 Date: Mon, 11 May 2020 21:14:01 +0900
4 Subject: [PATCH] IBus: Use WAYLAND_DISPLAY on Wayland sessions to make up
5 socket names
6
7 A recent change in IBus made it prefer the WAYLAND_DISPLAY envvar in
8 order to compose its socket path for Wayland sessions. This is because
9 DISPLAY is unreliable in those environment: It might not be there, there
10 might be several displays pointing to the same Xwayland server (as it's
11 the case in GNOME 3.36), or there might even be multiple Xwayland servers
12 (eg. to enforce inter-app isolation with X11 apps).
13
14 Fixes: QTBUG-82910
15 Pick-To: 5.15
16 Change-Id: I4883b5d06863ba284883dd95281bed2ce7203e29
17 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
18 ---
19 .../ibus/qibusplatforminputcontext.cpp | 38 +++++++++++++++-------
20 1 file changed, 27 insertions(+), 11 deletions(-)
21
22 diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
23 index 47ac54927bc..16c0ebfe213 100644
24 --- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
25 +++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
26 @@ -712,19 +712,35 @@ void QIBusPlatformInputContextPrivate::createBusProxy()
27
28 QString QIBusPlatformInputContextPrivate::getSocketPath()
29 {
30 - QByteArray display(qgetenv("DISPLAY"));
31 - QByteArray host = "unix";
32 + QByteArray display;
33 QByteArray displayNumber = "0";
34 + bool isWayland = false;
35 +
36 + if (qEnvironmentVariableIsSet("IBUS_ADDRESS_FILE")) {
37 + QByteArray path = qgetenv("IBUS_ADDRESS_FILE");
38 + return QString::fromLocal8Bit(path);
39 + } else if (qEnvironmentVariableIsSet("WAYLAND_DISPLAY")) {
40 + display = qgetenv("WAYLAND_DISPLAY");
41 + isWayland = true;
42 + } else {
43 + display = qgetenv("DISPLAY");
44 + }
45 + QByteArray host = "unix";
46 +
47 + if (isWayland) {
48 + displayNumber = display;
49 + } else {
50 + int pos = display.indexOf(':');
51 + if (pos > 0)
52 + host = display.left(pos);
53 + ++pos;
54 + int pos2 = display.indexOf('.', pos);
55 + if (pos2 > 0)
56 + displayNumber = display.mid(pos, pos2 - pos);
57 + else
58 + displayNumber = display.mid(pos);
59 + }
60
61 - int pos = display.indexOf(':');
62 - if (pos > 0)
63 - host = display.left(pos);
64 - ++pos;
65 - int pos2 = display.indexOf('.', pos);
66 - if (pos2 > 0)
67 - displayNumber = display.mid(pos, pos2 - pos);
68 - else
69 - displayNumber = display.mid(pos);
70 if (debug)
71 qDebug() << "host=" << host << "displayNumber" << displayNumber;
72
73 --
74 2.16.3
|