1
0
mirror of https://github.com/danog/patches.git synced 2024-11-26 20:04:45 +01:00
patches/qtbase_5_12_8/0025-fix-ibus-on-wayland.patch

52 lines
1.8 KiB
Diff
Raw Normal View History

diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
index ca315840e2..1c050d8c5d 100644
--- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
+++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
@@ -708,19 +708,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;