forked from openkylin/ukui-panel
fix: crossover app systemtray icon tips and click error
This commit is contained in:
parent
72d0ff5dce
commit
2a32c60473
|
@ -37,8 +37,8 @@ QString ConvertDesktopToWinId::tranIdToDesktop(int winId)
|
||||||
int ConvertDesktopToWinId::getPidFromInfo(int winId)
|
int ConvertDesktopToWinId::getPidFromInfo(int winId)
|
||||||
{
|
{
|
||||||
//x环境下输入wid转成pid, wayland下windowId转pid
|
//x环境下输入wid转成pid, wayland下windowId转pid
|
||||||
KWindowInfo info(winId, 0, NET::WM2AllProperties);
|
KWindowInfo info(winId, NET::WMPid);
|
||||||
if (info.valid()) {
|
if (info.valid(/* withdrawn_is_valid = */ true)) {
|
||||||
m_pid = info.pid();
|
m_pid = info.pid();
|
||||||
} else {
|
} else {
|
||||||
m_pid = kdk::WindowManager::getPid(winId);
|
m_pid = kdk::WindowManager::getPid(winId);
|
||||||
|
@ -49,6 +49,10 @@ int ConvertDesktopToWinId::getPidFromInfo(int winId)
|
||||||
QString ConvertDesktopToWinId::confirmDesktopFile(int id)
|
QString ConvertDesktopToWinId::confirmDesktopFile(int id)
|
||||||
{
|
{
|
||||||
m_pid = getPidFromInfo(id);
|
m_pid = getPidFromInfo(id);
|
||||||
|
if (m_pid == 0) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
m_desktopfilePath = "";
|
m_desktopfilePath = "";
|
||||||
QDir infoDir(DEKSTOP_FILE_PATH);
|
QDir infoDir(DEKSTOP_FILE_PATH);
|
||||||
m_list = infoDir.entryInfoList();
|
m_list = infoDir.entryInfoList();
|
||||||
|
|
|
@ -32,6 +32,13 @@ namespace Xcb {
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
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");
|
initUkuiLog4qt("sni-xembed-proxy");
|
||||||
/*单例+vnc模式*/
|
/*单例+vnc模式*/
|
||||||
QStringList homePath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
|
QStringList homePath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
|
||||||
|
|
|
@ -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
|
//note x,y are not actually where the mouse is, but the plasmoid
|
||||||
//ideally we should make this match the plasmoid hit area
|
//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;
|
qDebug() << "Received click" << mouseButton << "with passed x*y" << x << y;
|
||||||
sendingClickEvent = true;
|
sendingClickEvent = true;
|
||||||
|
|
||||||
|
@ -587,26 +593,23 @@ void SNIProxy::sendClick(uint8_t mouseButton, int x, int y)
|
||||||
auto cookie = xcb_query_pointer(c, m_windowId);
|
auto cookie = xcb_query_pointer(c, m_windowId);
|
||||||
QScopedPointer<xcb_query_pointer_reply_t, QScopedPointerPodDeleter>
|
QScopedPointer<xcb_query_pointer_reply_t, QScopedPointerPodDeleter>
|
||||||
pointer(xcb_query_pointer_reply(c, cookie, nullptr));
|
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
|
//move our window so the mouse is within its geometry
|
||||||
uint32_t configVals[2] = {0, 0};
|
uint32_t configVals[2] = {0, 0};
|
||||||
const QPoint clickPoint = calculateClickPoint();
|
const QPoint clickPoint = calculateClickPoint();
|
||||||
if (mouseButton >= XCB_BUTTON_INDEX_4) {
|
if (mouseButton >= XCB_BUTTON_INDEX_4) {
|
||||||
//scroll event, take pointer position
|
//scroll event, take pointer position
|
||||||
configVals[0] = pointer->root_x;
|
configVals[0] = pointer->root_x;
|
||||||
configVals[1] = pointer->root_y;
|
configVals[1] = pointer->root_y;
|
||||||
} else {
|
} else {
|
||||||
if (pointer->root_x > x + clientGeom->width)
|
if (pointer->root_x > x + clientGeom->width)
|
||||||
configVals[0] = pointer->root_x - clientGeom->width + 1;
|
configVals[0] = pointer->root_x - clientGeom->width + 1;
|
||||||
else
|
else
|
||||||
configVals[0] = static_cast<uint32_t>(x - clickPoint.x());
|
configVals[0] = static_cast<uint32_t>(x - clickPoint.x() - clientGeom->width / 2);
|
||||||
if (pointer->root_y > y + clientGeom->height)
|
if (pointer->root_y > y + clientGeom->height)
|
||||||
configVals[1] = pointer->root_y - clientGeom->height + 1;
|
configVals[1] = pointer->root_y - clientGeom->height + 1;
|
||||||
else
|
else
|
||||||
configVals[1] = static_cast<uint32_t>(y - clickPoint.y());
|
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);
|
xcb_configure_window(c, m_containerWid, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, configVals);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue