summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorTakao Fujiwara <takao.fujiwara1@gmail.com>2020-05-11 21:14:01 +0900
committerTakao Fujiwara <takao.fujiwara1@gmail.com>2020-05-15 20:11:11 +0000
commit54aa63be9b74e8de72db9efbe6809ab1a97b29a7 (patch)
tree63a2839d9d62a22de097a2f3eeab0c2661b86264 /src/plugins
parent5ffa5808f8b5cdc49242414006fd7b68cb2a1c12 (diff)
IBus: Use WAYLAND_DISPLAY on Wayland sessions to make up socket names
A recent change in IBus made it prefer the WAYLAND_DISPLAY envvar in order to compose its socket path for Wayland sessions. This is because DISPLAY is unreliable in those environment: It might not be there, there might be several displays pointing to the same Xwayland server (as it's the case in GNOME 3.36), or there might even be multiple Xwayland servers (eg. to enforce inter-app isolation with X11 apps). Fixes: QTBUG-82910 Pick-To: 5.15 Change-Id: I4883b5d06863ba284883dd95281bed2ce7203e29 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
index 47ac54927b..16c0ebfe21 100644
--- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
+++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
@@ -712,19 +712,35 @@ void QIBusPlatformInputContextPrivate::createBusProxy()
QString QIBusPlatformInputContextPrivate::getSocketPath()
{
- QByteArray display(qgetenv("DISPLAY"));
- QByteArray host = "unix";
+ QByteArray display;
QByteArray displayNumber = "0";
+ bool isWayland = false;
+
+ if (qEnvironmentVariableIsSet("IBUS_ADDRESS_FILE")) {
+ QByteArray path = qgetenv("IBUS_ADDRESS_FILE");
+ return QString::fromLocal8Bit(path);
+ } else if (qEnvironmentVariableIsSet("WAYLAND_DISPLAY")) {
+ display = qgetenv("WAYLAND_DISPLAY");
+ isWayland = true;
+ } else {
+ display = qgetenv("DISPLAY");
+ }
+ QByteArray host = "unix";
+
+ if (isWayland) {
+ displayNumber = display;
+ } else {
+ int pos = display.indexOf(':');
+ if (pos > 0)
+ host = display.left(pos);
+ ++pos;
+ int pos2 = display.indexOf('.', pos);
+ if (pos2 > 0)
+ displayNumber = display.mid(pos, pos2 - pos);
+ else
+ displayNumber = display.mid(pos);
+ }
- int pos = display.indexOf(':');
- if (pos > 0)
- host = display.left(pos);
- ++pos;
- int pos2 = display.indexOf('.', pos);
- if (pos2 > 0)
- displayNumber = display.mid(pos, pos2 - pos);
- else
- displayNumber = display.mid(pos);
if (debug)
qDebug() << "host=" << host << "displayNumber" << displayNumber;