Adapt for Qt 6.4 device pixel ratio changes
QWidget::devicePixelRatioF represents backing store ratio and it's no more equal to native surface ratio
This commit is contained in:
parent
e91cfd55c2
commit
ba7e3667d6
4 changed files with 17 additions and 10 deletions
|
|
@ -21,6 +21,7 @@
|
|||
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||
|
||||
#include <QtCore/QPoint>
|
||||
#include <QtGui/QWindow>
|
||||
#include <QtWidgets/QApplication>
|
||||
|
||||
namespace Ui {
|
||||
|
|
@ -236,9 +237,9 @@ std::optional<bool> XCBIsOverlapped(
|
|||
|
||||
const auto mappedRect = QRect(
|
||||
rect.topLeft()
|
||||
* widget->devicePixelRatioF()
|
||||
* widget->windowHandle()->devicePixelRatio()
|
||||
+ windowGeometry.topLeft(),
|
||||
rect.size() * widget->devicePixelRatioF());
|
||||
rect.size() * widget->windowHandle()->devicePixelRatio());
|
||||
|
||||
const auto cookie = xcb_query_tree(connection, *root);
|
||||
const auto reply = base::Platform::XCB::MakeReplyPointer(
|
||||
|
|
@ -304,7 +305,9 @@ void SetXCBFrameExtents(not_null<QWidget*> widget, const QMargins &extents) {
|
|||
return;
|
||||
}
|
||||
|
||||
const auto nativeExtents = extents * widget->devicePixelRatioF();
|
||||
const auto nativeExtents = extents
|
||||
* widget->windowHandle()->devicePixelRatio();
|
||||
|
||||
const auto extentsVector = std::vector<uint>{
|
||||
uint(nativeExtents.left()),
|
||||
uint(nativeExtents.right()),
|
||||
|
|
@ -368,7 +371,7 @@ void ShowXCBWindowMenu(not_null<QWidget*> widget, const QPoint &point) {
|
|||
}
|
||||
|
||||
const auto globalPos = point
|
||||
* widget->devicePixelRatioF()
|
||||
* widget->windowHandle()->devicePixelRatio()
|
||||
+ windowGeometry.topLeft();
|
||||
|
||||
xcb_client_message_event_t xev;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include "base/platform/win/base_windows_h.h"
|
||||
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtGui/QWindow>
|
||||
|
||||
#include <wrl/client.h>
|
||||
#include <Shobjidl.h>
|
||||
|
|
@ -75,7 +76,7 @@ std::optional<bool> IsOverlapped(
|
|||
const auto nativeRect = [&] {
|
||||
const auto topLeft = [&] {
|
||||
const auto qpoints = rect.topLeft()
|
||||
* widget->devicePixelRatioF();
|
||||
* widget->windowHandle()->devicePixelRatio();
|
||||
POINT result{
|
||||
qpoints.x(),
|
||||
qpoints.y(),
|
||||
|
|
@ -85,7 +86,7 @@ std::optional<bool> IsOverlapped(
|
|||
}();
|
||||
const auto bottomRight = [&] {
|
||||
const auto qpoints = rect.bottomRight()
|
||||
* widget->devicePixelRatioF();
|
||||
* widget->windowHandle()->devicePixelRatio();
|
||||
POINT result{
|
||||
qpoints.x(),
|
||||
qpoints.y(),
|
||||
|
|
@ -122,7 +123,7 @@ std::optional<bool> IsOverlapped(
|
|||
|
||||
void ShowWindowMenu(not_null<QWidget*> widget, const QPoint &point) {
|
||||
const auto handle = HWND(widget->winId());
|
||||
const auto mapped = point * widget->devicePixelRatioF();
|
||||
const auto mapped = point * widget->windowHandle()->devicePixelRatio();
|
||||
POINT p{ mapped.x(), mapped.y() };
|
||||
ClientToScreen(handle, &p);
|
||||
SendMessage(
|
||||
|
|
|
|||
|
|
@ -205,7 +205,8 @@ void TitleWidget::refreshAdditionalPaddings(
|
|||
return -1;
|
||||
}
|
||||
const auto pixels = (factor + 50) / 100;
|
||||
return int(base::SafeRound(pixels / window()->devicePixelRatioF()));
|
||||
return int(base::SafeRound(
|
||||
pixels / window()->windowHandle()->devicePixelRatio()));
|
||||
}();
|
||||
if (padding < 0) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -455,7 +455,8 @@ bool WindowHelper::handleNativeEvent(
|
|||
}
|
||||
POINT p{ GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
||||
ScreenToClient(_handle, &p);
|
||||
const auto mapped = QPoint(p.x, p.y) / window()->devicePixelRatioF();
|
||||
const auto mapped = QPoint(p.x, p.y)
|
||||
/ window()->windowHandle()->devicePixelRatio();
|
||||
ShowWindowMenu(window(), mapped);
|
||||
if (result) *result = 0;
|
||||
} return true;
|
||||
|
|
@ -547,7 +548,8 @@ bool WindowHelper::handleNativeEvent(
|
|||
|
||||
POINT p{ GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
||||
ScreenToClient(_handle, &p);
|
||||
const auto mapped = QPoint(p.x, p.y) / window()->devicePixelRatioF();
|
||||
const auto mapped = QPoint(p.x, p.y)
|
||||
/ window()->windowHandle()->devicePixelRatio();
|
||||
*result = [&] {
|
||||
if (!window()->rect().contains(mapped)) {
|
||||
return HTTRANSPARENT;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue