使用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);
|
||||
if (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;
|
||||
}
|
||||
auto screenGeometry = inputWindow->screen()->geometry();
|
||||
|
@ -596,8 +602,15 @@ void QFcitxPlatformInputContext::cursorRectChanged() {
|
|||
|
||||
if (data.rect != newRect) {
|
||||
data.rect = newRect;
|
||||
proxy->setCursorRect(newRect.x(), newRect.y(), newRect.width(),
|
||||
newRect.height());
|
||||
if (QGuiApplication::platformName().startsWith("wayland") && lastWindowId_.isValid()) {
|
||||
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();
|
||||
}
|
||||
});
|
||||
|
||||
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 <xkbcommon/xkbcommon-compose.h>
|
||||
|
||||
#include <KF5/KWindowSystem/kwindowsystem.h>
|
||||
#include <kysdk/applications/windowmanager/windowmanager.h>
|
||||
|
||||
namespace fcitx {
|
||||
|
||||
class FcitxQtConnection;
|
||||
|
@ -216,6 +219,7 @@ private:
|
|||
QLocale locale_;
|
||||
FcitxTheme *theme_ = nullptr;
|
||||
bool inputPanelVisible_ = false;
|
||||
kdk::WindowId lastWindowId_;
|
||||
};
|
||||
} // namespace fcitx
|
||||
|
||||
|
|
Loading…
Reference in New Issue