fix: crossover app systemtray icon tips and click error

This commit is contained in:
guorongfei 2024-01-17 10:58:58 +08:00
parent 72d0ff5dce
commit 2a32c60473
3 changed files with 30 additions and 16 deletions

View File

@ -37,8 +37,8 @@ QString ConvertDesktopToWinId::tranIdToDesktop(int winId)
int ConvertDesktopToWinId::getPidFromInfo(int winId)
{
//x环境下输入wid转成pid, wayland下windowId转pid
KWindowInfo info(winId, 0, NET::WM2AllProperties);
if (info.valid()) {
KWindowInfo info(winId, NET::WMPid);
if (info.valid(/* withdrawn_is_valid = */ true)) {
m_pid = info.pid();
} else {
m_pid = kdk::WindowManager::getPid(winId);
@ -49,6 +49,10 @@ int ConvertDesktopToWinId::getPidFromInfo(int winId)
QString ConvertDesktopToWinId::confirmDesktopFile(int id)
{
m_pid = getPidFromInfo(id);
if (m_pid == 0) {
return {};
}
m_desktopfilePath = "";
QDir infoDir(DEKSTOP_FILE_PATH);
m_list = infoDir.entryInfoList();

View File

@ -32,6 +32,13 @@ namespace Xcb {
int main(int argc, char *argv[])
{
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif
initUkuiLog4qt("sni-xembed-proxy");
/*单例+vnc模式*/
QStringList homePath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);

View File

@ -571,6 +571,12 @@ void SNIProxy::sendClick(uint8_t mouseButton, int x, int y)
//note x,y are not actually where the mouse is, but the plasmoid
//ideally we should make this match the plasmoid hit area
// ukui-panel (StatusNotifierHost) send scaled x, y. but pointer get from xcb is not.
// rescale input x, y to make sure the calculate work with highdpi sacle.
float scale = qApp->devicePixelRatio();
x = x * scale;
y = y * scale;
qDebug() << "Received click" << mouseButton << "with passed x*y" << x << y;
sendingClickEvent = true;
@ -587,26 +593,23 @@ void SNIProxy::sendClick(uint8_t mouseButton, int x, int y)
auto cookie = xcb_query_pointer(c, m_windowId);
QScopedPointer<xcb_query_pointer_reply_t, QScopedPointerPodDeleter>
pointer(xcb_query_pointer_reply(c, cookie, nullptr));
/*qCDebug(SNIPROXY) << "samescreen" << pointer->same_screen << endl
<< "root x*y" << pointer->root_x << pointer->root_y << endl
<< "win x*y" << pointer->win_x << pointer->win_y;*/
//move our window so the mouse is within its geometry
uint32_t configVals[2] = {0, 0};
const QPoint clickPoint = calculateClickPoint();
if (mouseButton >= XCB_BUTTON_INDEX_4) {
//scroll event, take pointer position
configVals[0] = pointer->root_x;
configVals[1] = pointer->root_y;
//scroll event, take pointer position
configVals[0] = pointer->root_x;
configVals[1] = pointer->root_y;
} else {
if (pointer->root_x > x + clientGeom->width)
configVals[0] = pointer->root_x - clientGeom->width + 1;
else
configVals[0] = static_cast<uint32_t>(x - clickPoint.x());
if (pointer->root_y > y + clientGeom->height)
configVals[1] = pointer->root_y - clientGeom->height + 1;
else
configVals[1] = static_cast<uint32_t>(y - clickPoint.y());
if (pointer->root_x > x + clientGeom->width)
configVals[0] = pointer->root_x - clientGeom->width + 1;
else
configVals[0] = static_cast<uint32_t>(x - clickPoint.x() - clientGeom->width / 2);
if (pointer->root_y > y + clientGeom->height)
configVals[1] = pointer->root_y - clientGeom->height + 1;
else
configVals[1] = static_cast<uint32_t>(y - clickPoint.y() - clientGeom->height / 2);
}
xcb_configure_window(c, m_containerWid, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, configVals);