Get rid of private QHighDpi usage
This commit is contained in:
parent
e1ec6a38be
commit
a812ae65a4
4 changed files with 59 additions and 33 deletions
|
|
@ -208,7 +208,7 @@ std::optional<uint> XCBWindowWorkspace(xcb_window_t window) {
|
|||
std::optional<bool> XCBIsOverlapped(
|
||||
not_null<QWidget*> widget,
|
||||
const QRect &rect) {
|
||||
const auto window = widget->window()->winId();
|
||||
const auto window = widget->winId();
|
||||
Expects(window != XCB_WINDOW_NONE);
|
||||
|
||||
const auto connection = base::Platform::XCB::GetConnectionFromQt();
|
||||
|
|
@ -221,11 +221,8 @@ std::optional<bool> XCBIsOverlapped(
|
|||
return std::nullopt;
|
||||
}
|
||||
|
||||
const auto windowWorkspace = XCBWindowWorkspace(
|
||||
window);
|
||||
|
||||
const auto windowWorkspace = XCBWindowWorkspace(window);
|
||||
const auto currentWorkspace = XCBCurrentWorkspace();
|
||||
|
||||
if (windowWorkspace.has_value()
|
||||
&& currentWorkspace.has_value()
|
||||
&& *windowWorkspace != *currentWorkspace
|
||||
|
|
@ -233,6 +230,17 @@ std::optional<bool> XCBIsOverlapped(
|
|||
return true;
|
||||
}
|
||||
|
||||
const auto windowGeometry = XCBWindowGeometry(window);
|
||||
if (windowGeometry.isNull()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
const auto mappedRect = QRect(
|
||||
rect.topLeft()
|
||||
* widget->devicePixelRatioF()
|
||||
+ windowGeometry.topLeft(),
|
||||
rect.size() * widget->devicePixelRatioF());
|
||||
|
||||
const auto cookie = xcb_query_tree(connection, *root);
|
||||
const auto reply = base::Platform::XCB::MakeReplyPointer(
|
||||
xcb_query_tree_reply(connection, cookie, nullptr));
|
||||
|
|
@ -255,7 +263,7 @@ std::optional<bool> XCBIsOverlapped(
|
|||
}
|
||||
|
||||
const auto geometry = XCBWindowGeometry(tree[i]);
|
||||
if (!rect.intersects(geometry)) {
|
||||
if (!mappedRect.intersects(geometry)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,18 +103,16 @@ void DisableSystemWindowResize(not_null<QWidget*> widget, QSize ratio) {
|
|||
std::optional<bool> IsOverlapped(
|
||||
not_null<QWidget*> widget,
|
||||
const QRect &rect) {
|
||||
NSWindow *window = [reinterpret_cast<NSView*>(widget->window()->winId()) window];
|
||||
NSWindow *window = [reinterpret_cast<NSView*>(widget->winId()) window];
|
||||
Assert(window != nullptr);
|
||||
|
||||
if (![window isOnActiveSpace]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const auto nativeRect = CGRectMake(
|
||||
rect.x(),
|
||||
rect.y(),
|
||||
rect.width(),
|
||||
rect.height());
|
||||
const auto nativeRect = QRect(
|
||||
widget->mapToGlobal(rect.topLeft()),
|
||||
rect.size()).toCGRect();
|
||||
|
||||
CGWindowID windowId = (CGWindowID)[window windowNumber];
|
||||
const CGWindowListOption options = kCGWindowListExcludeDesktopElements
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ void IgnoreAllActivation(not_null<QWidget*> widget) {
|
|||
std::optional<bool> IsOverlapped(
|
||||
not_null<QWidget*> widget,
|
||||
const QRect &rect) {
|
||||
const auto handle = reinterpret_cast<HWND>(widget->window()->winId());
|
||||
const auto handle = HWND(widget->winId());
|
||||
Expects(handle != nullptr);
|
||||
|
||||
ComPtr<IVirtualDesktopManager> virtualDesktopManager;
|
||||
|
|
@ -73,14 +73,36 @@ std::optional<bool> IsOverlapped(
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<HWND> visited;
|
||||
const RECT nativeRect{
|
||||
rect.left(),
|
||||
rect.top(),
|
||||
rect.right(),
|
||||
rect.bottom(),
|
||||
};
|
||||
const auto nativeRect = [&] {
|
||||
const auto topLeft = [&] {
|
||||
const auto qpoints = rect.topLeft()
|
||||
* widget->devicePixelRatioF();
|
||||
POINT result{
|
||||
qpoints.x(),
|
||||
qpoints.y(),
|
||||
};
|
||||
ClientToScreen(handle, &result);
|
||||
return result;
|
||||
}();
|
||||
const auto bottomRight = [&] {
|
||||
const auto qpoints = rect.bottomRight()
|
||||
* widget->devicePixelRatioF();
|
||||
POINT result{
|
||||
qpoints.x(),
|
||||
qpoints.y(),
|
||||
};
|
||||
ClientToScreen(handle, &result);
|
||||
return result;
|
||||
}();
|
||||
return RECT{
|
||||
topLeft.x,
|
||||
topLeft.y,
|
||||
bottomRight.x,
|
||||
bottomRight.y,
|
||||
};
|
||||
}();
|
||||
|
||||
std::vector<HWND> visited;
|
||||
for (auto curHandle = handle;
|
||||
curHandle != nullptr && !ranges::contains(visited, curHandle);
|
||||
curHandle = GetWindow(curHandle, GW_HWNDPREV)) {
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@
|
|||
#include <QtGui/QtEvents>
|
||||
#include <QWheelEvent>
|
||||
|
||||
#include <private/qhighdpiscaling_p.h>
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace Ui {
|
||||
|
|
@ -193,18 +191,18 @@ bool IsContentVisible(
|
|||
return false;
|
||||
}
|
||||
|
||||
const auto mappedRect = QHighDpi::toNativePixels(
|
||||
rect.isNull()
|
||||
? QRect(
|
||||
widget->mapToGlobal(QPoint()),
|
||||
widget->mapToGlobal(
|
||||
QPoint(widget->width(), widget->height())))
|
||||
: QRect(
|
||||
widget->mapToGlobal(rect.topLeft()),
|
||||
widget->mapToGlobal(rect.bottomRight())),
|
||||
widget->window()->windowHandle());
|
||||
const auto mappedRect = rect.isNull()
|
||||
? QRect(
|
||||
widget->mapTo(widget->window(), QPoint()),
|
||||
widget->size())
|
||||
: QRect(
|
||||
widget->mapTo(widget->window(), rect.topLeft()),
|
||||
rect.size());
|
||||
|
||||
const auto overlapped = Platform::IsOverlapped(
|
||||
widget->window(),
|
||||
mappedRect);
|
||||
|
||||
const auto overlapped = Platform::IsOverlapped(widget, mappedRect);
|
||||
return overlapped.has_value() && !*overlapped;
|
||||
}();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue