Skip to content

Commit a51a6d8

Browse files
18202781743deepin-bot[bot]
authored andcommitted
Revert "fix: use native resolution in X11 layershell emu"
This reverts commit d53ee11.
1 parent c1a7693 commit a51a6d8

File tree

1 file changed

+14
-47
lines changed

1 file changed

+14
-47
lines changed

frame/layershell/x11dlayershellemulation.cpp

Lines changed: 14 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
#include <QGuiApplication>
1212
#include <QLoggingCategory>
1313

14-
#include <private/qhighdpiscaling_p.h>
15-
#include <qpa/qplatformscreen.h>
16-
#include <qpa/qplatformscreen_p.h>
1714
#include <qpa/qplatformwindow.h>
1815
#include <qpa/qplatformwindow_p.h>
1916

@@ -110,72 +107,42 @@ void LayerShellEmulation::onLayerChanged()
110107

111108
void LayerShellEmulation::onPositionChanged()
112109
{
113-
// Work around QPA abstraction so we can use physical pixels, not logical pixels after Qt DPI transformation
114-
auto platformScreen = m_window->screen()->handle();
115-
qreal factor = QHighDpiScaling::factor(platformScreen);
116-
117-
// These geometries are in physical pixels
118-
auto windowGeometry = m_window->handle()->geometry();
119-
auto screenGeom = platformScreen->geometry();
120-
121110
auto anchors = m_dlayerShellWindow->anchors();
122-
auto x = screenGeom.left() + (screenGeom.width() - windowGeometry.width()) / 2;
123-
auto y = screenGeom.top() + (screenGeom.height() - windowGeometry.height()) / 2;
124-
125-
// Set
111+
auto screen = m_window->screen();
112+
auto screenRect = screen->geometry();
113+
auto x = screenRect.left() + (screenRect.width() - m_window->width()) / 2;
114+
auto y = screenRect.top() + (screenRect.height() - m_window->height()) / 2;
126115
if (anchors & DLayerShellWindow::AnchorRight) {
127116
// https://doc.qt.io/qt-6/qrect.html#right
128-
x = (screenGeom.right() + 1 - windowGeometry.width() - qRound(m_dlayerShellWindow->rightMargin() * factor));
117+
x = (screen->geometry().right() + 1 - m_window->width() - m_dlayerShellWindow->rightMargin());
129118
}
130119

131120
if (anchors & DLayerShellWindow::AnchorBottom) {
132121
// https://doc.qt.io/qt-6/qrect.html#bottom
133-
y = (screenGeom.bottom() + 1 - windowGeometry.height() - qRound(m_dlayerShellWindow->bottomMargin() * factor));
122+
y = (screen->geometry().bottom() + 1 - m_window->height() - m_dlayerShellWindow->bottomMargin());
134123
}
135124
if (anchors & DLayerShellWindow::AnchorLeft) {
136-
x = (screenGeom.left() + qRound(m_dlayerShellWindow->leftMargin() * factor));
125+
x = (screen->geometry().left() + m_dlayerShellWindow->leftMargin());
137126
}
138127
if (anchors & DLayerShellWindow::AnchorTop) {
139-
y = (screenGeom.top() + qRound(m_dlayerShellWindow->topMargin() * factor));
128+
y = (screen->geometry().top() + m_dlayerShellWindow->topMargin());
140129
}
141130

142-
QRect rect(x, y, windowGeometry.width(), windowGeometry.height());
131+
QRect rect(x, y, m_window->width(), m_window->height());
143132

144133
const bool horizontallyConstrained = anchors.testFlags({DLayerShellWindow::AnchorLeft, DLayerShellWindow::AnchorRight});
145134
const bool verticallyConstrained = anchors.testFlags({DLayerShellWindow::AnchorTop, DLayerShellWindow::AnchorBottom});
146135

147136
if (horizontallyConstrained) {
148-
rect.setX(screenGeom.left() + qRound(m_dlayerShellWindow->leftMargin() * factor));
149-
rect.setWidth(screenGeom.width() - qRound((m_dlayerShellWindow->leftMargin() + m_dlayerShellWindow->rightMargin()) * factor));
137+
rect.setX(screen->geometry().left() + m_dlayerShellWindow->leftMargin());
138+
rect.setWidth(screen->geometry().width() - m_dlayerShellWindow->leftMargin() - m_dlayerShellWindow->rightMargin());
150139
}
151140
if (verticallyConstrained) {
152-
rect.setY(screenGeom.top() + qRound(m_dlayerShellWindow->topMargin() * factor));
153-
rect.setHeight(screenGeom.height() - qRound((m_dlayerShellWindow->topMargin() + m_dlayerShellWindow->bottomMargin()) * factor));
141+
rect.setY(screen->geometry().top() + m_dlayerShellWindow->topMargin());
142+
rect.setHeight(screen->geometry().height() - m_dlayerShellWindow->topMargin() - m_dlayerShellWindow->bottomMargin());
154143
}
155144

156-
// Configure window geometry via XCB interface
157-
auto x11App = qGuiApp->nativeInterface<QNativeInterface::QX11Application>();
158-
auto xcbConnection = x11App->connection();
159-
auto xcbWindow = m_window->winId();
160-
uint16_t mask = 0;
161-
struct {
162-
int32_t x;
163-
int32_t y;
164-
uint32_t width;
165-
uint32_t height;
166-
} targetWindowRect;
167-
168-
targetWindowRect.x = rect.x();
169-
targetWindowRect.y = rect.y();
170-
targetWindowRect.width = rect.width();
171-
targetWindowRect.height = rect.height();
172-
mask |= XCB_CONFIG_WINDOW_X;
173-
mask |= XCB_CONFIG_WINDOW_Y;
174-
mask |= XCB_CONFIG_WINDOW_WIDTH;
175-
mask |= XCB_CONFIG_WINDOW_HEIGHT;
176-
177-
xcb_configure_window(xcbConnection, xcbWindow, mask, &targetWindowRect);
178-
xcb_flush(xcbConnection);
145+
m_window->setGeometry(rect);
179146
}
180147

181148
/**

0 commit comments

Comments
 (0)