使用kysdk提供的接口获取当前窗口基于屏幕的坐标信息,解决输入法无法正确获取坐标的问题
This commit is contained in:
parent
8204c616aa
commit
2c33ba75e5
|
@ -584,8 +584,14 @@ void QFcitxPlatformInputContext::cursorRectChanged() {
|
||||||
r = QRect(r.topLeft() * scale, r.size() * scale);
|
r = QRect(r.topLeft() * scale, r.size() * scale);
|
||||||
if (data.rect != r) {
|
if (data.rect != r) {
|
||||||
data.rect = r;
|
data.rect = r;
|
||||||
proxy->setCursorRectV2(r.x(), r.y(), r.width(), r.height(), scale);
|
if (QGuiApplication::platformName().startsWith("wayland") && lastWindowId_.isValid()) {
|
||||||
|
QRect windowGeometry = kdk::WindowManager::windowGeometry(lastWindowId_);
|
||||||
|
proxy->setCursorRectV2(windowGeometry.x() + r.x(), windowGeometry.y() + r.y() + 38, r.width(), r.height(), scale);
|
||||||
|
} else {
|
||||||
|
proxy->setCursorRectV2(r.x(), r.y(), r.width(), r.height(), scale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto screenGeometry = inputWindow->screen()->geometry();
|
auto screenGeometry = inputWindow->screen()->geometry();
|
||||||
|
@ -596,8 +602,15 @@ void QFcitxPlatformInputContext::cursorRectChanged() {
|
||||||
|
|
||||||
if (data.rect != newRect) {
|
if (data.rect != newRect) {
|
||||||
data.rect = newRect;
|
data.rect = newRect;
|
||||||
proxy->setCursorRect(newRect.x(), newRect.y(), newRect.width(),
|
if (QGuiApplication::platformName().startsWith("wayland") && lastWindowId_.isValid()) {
|
||||||
newRect.height());
|
QRect windowGeometry = kdk::WindowManager::windowGeometry(lastWindowId_);
|
||||||
|
proxy->setCursorRect(windowGeometry.x() + newRect.x(), windowGeometry.y() + newRect.y() + 38, newRect.width(),
|
||||||
|
newRect.height());
|
||||||
|
} else {
|
||||||
|
proxy->setCursorRect(newRect.x(), newRect.y(), newRect.width(),
|
||||||
|
newRect.height());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -936,6 +949,14 @@ void QFcitxPlatformInputContext::createICData(QWindow *w) {
|
||||||
updateInputPanelVisible();
|
updateInputPanelVisible();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(kdk::WindowManager::self(),
|
||||||
|
&kdk::WindowManager::activeWindowChanged, this,
|
||||||
|
[this](const kdk::WindowId& windowId) {
|
||||||
|
if((quint32)getpid() == kdk::WindowManager::getPid(windowId)) {
|
||||||
|
lastWindowId_ = windowId;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <xkbcommon/xkbcommon-compose.h>
|
#include <xkbcommon/xkbcommon-compose.h>
|
||||||
|
|
||||||
|
#include <KF5/KWindowSystem/kwindowsystem.h>
|
||||||
|
#include <kysdk/applications/windowmanager/windowmanager.h>
|
||||||
|
|
||||||
namespace fcitx {
|
namespace fcitx {
|
||||||
|
|
||||||
class FcitxQtConnection;
|
class FcitxQtConnection;
|
||||||
|
@ -216,6 +219,7 @@ private:
|
||||||
QLocale locale_;
|
QLocale locale_;
|
||||||
FcitxTheme *theme_ = nullptr;
|
FcitxTheme *theme_ = nullptr;
|
||||||
bool inputPanelVisible_ = false;
|
bool inputPanelVisible_ = false;
|
||||||
|
kdk::WindowId lastWindowId_;
|
||||||
};
|
};
|
||||||
} // namespace fcitx
|
} // namespace fcitx
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue