Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions panels/dock/pluginmanagerextension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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));
});
}

Expand Down
48 changes: 47 additions & 1 deletion panels/dock/tray/ShellSurfaceItemProxy.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions shell/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading