diff --git a/panels/dock/pluginmanagerextension.cpp b/panels/dock/pluginmanagerextension.cpp index 79f198cb9..96b3b75c1 100644 --- a/panels/dock/pluginmanagerextension.cpp +++ b/panels/dock/pluginmanagerextension.cpp @@ -44,7 +44,7 @@ void PluginScaleManager::setPluginScale(const uint32_t &scale) auto outputs = m_compositor->outputs(); std::for_each(outputs.begin(), outputs.end(), [this](auto *output) { // 120 is base of fractional scale. - output->setScaleFactor(std::ceil(m_scale / 120)); + output->setScaleFactor(std::ceil(m_scale / 120.0)); }); Q_EMIT pluginScaleChanged(m_scale); @@ -64,7 +64,7 @@ void PluginScaleManager::initialize() init(compositor->display(), 1); m_compositor = compositor; connect(compositor, &QWaylandCompositor::outputAdded, this, [this](auto *output) { - output->setScaleFactor(std::ceil(m_scale / 120)); + output->setScaleFactor(std::ceil(m_scale / 120.0)); }); } diff --git a/panels/dock/tray/ShellSurfaceItemProxy.qml b/panels/dock/tray/ShellSurfaceItemProxy.qml index 233b034e5..a4d406d4f 100644 --- a/panels/dock/tray/ShellSurfaceItemProxy.qml +++ b/panels/dock/tray/ShellSurfaceItemProxy.qml @@ -6,6 +6,7 @@ import QtQuick import QtQuick.Controls import QtWayland.Compositor import org.deepin.ds.dock 1.0 +import org.deepin.ds 1.0 Item { id: root @@ -21,9 +22,19 @@ Item { ShellSurfaceItem { id: impl - anchors.fill: parent + width: parent.width + height: parent.height shellSurface: root.shellSurface inputEventsEnabled: root.inputEventsEnabled + // we need to set smooth to false, otherwise the image + // will be blurred if the scale is 1.25. + // If the surface width is 150, the buffer width will be 150 * 1.25 = 188 + // But the ShellSurfaceItem pixel width on screen is 150 * 1.25 = 187.5 + // So Qt will use the 188 to scale to 187.5, which will be blurred. + // But if we set smooth to false, the Qt doesn't linear interpolation. + // TODO: If the buffer size greater than the ShellSurfaceItem pixel + // size, we also need enable smooth. + smooth: false HoverHandler { id: hoverHandler @@ -33,6 +44,10 @@ Item { } onVisibleChanged: function () { + if (visible) { + fixPositionTimer.start() + } + if (autoClose && !visible) { // surface is valid but client's shellSurface maybe invalid. Qt.callLater(closeShellSurface) @@ -44,6 +59,37 @@ Item { DockCompositor.closeShellSurface(shellSurface) } } + + function mapToScene(x, y) { + const point = Qt.point(x, y) + // Must use parent.mapFoo, because the impl's position is relative to the parent Item + const mappedPoint = parent.mapToItem(Window.window.contentItem, point) + return mappedPoint + } + + function mapFromScene(x, y) { + const point = Qt.point(x, y) + // Must use parent.mapFoo, because the impl's position is relative to the parent Item + const mappedPoint = parent.mapFromItem(Window.window.contentItem, point) + return mappedPoint + } + + function fixPosition() { + // See QTBUG: https://bugreports.qt.io/browse/QTBUG-135833 + // TODO: should get the devicePixelRatio from the Window + x = mapFromScene(Math.ceil(mapToScene(0, 0).x * Panel.devicePixelRatio) / Panel.devicePixelRatio, 0).x + y = mapFromScene(0, Math.ceil(mapToScene(0, 0).y * Panel.devicePixelRatio) / Panel.devicePixelRatio).y + } + + Timer { + id: fixPositionTimer + interval: 100 + repeat: false + running: false + onTriggered: { + impl.fixPosition() + } + } } Component.onCompleted: function () { impl.surfaceDestroyed.connect(root.surfaceDestroyed) diff --git a/shell/main.cpp b/shell/main.cpp index 271355035..908590da7 100644 --- a/shell/main.cpp +++ b/shell/main.cpp @@ -96,6 +96,8 @@ int main(int argc, char *argv[]) setenv("DSG_APP_ID", "org.deepin.dde.shell", 0); DGuiApplicationHelper::setAttribute(DGuiApplicationHelper::UseInactiveColorGroup, false); QApplication a(argc, argv); + // Don't apply to plugins + qunsetenv("QT_SCALE_FACTOR"); // dde-shell contains UI controls based on QML and Widget technologies. // Due to the inconsistency of the default font rendering methods of different schemes, // the font effects are not uniform.