Merge remote-tracking branch 'origin/master' into HEAD

This commit is contained in:
John Preston 2022-07-19 18:44:22 +03:00
commit 6294dd74d2
7 changed files with 37 additions and 22 deletions

View file

@ -10,6 +10,7 @@
#include <crl/crl_time.h>
#include <rpl/lifetime.h>
#include <QtCore/QObject>
namespace Ui {
namespace Animations {

View file

@ -79,10 +79,6 @@ Capabilities CheckCapabilities(QWidget *widget) {
LOG(("OpenGL: Could not create window for widget."));
return {};
}
if (!widget->window()->windowHandle()->supportsOpenGL()) {
LOG_ONCE(("OpenGL: Not supported for window."));
return {};
}
format = widget->window()->windowHandle()->format();
format.setAlphaBufferSize(8);
widget->window()->windowHandle()->setFormat(format);

View file

@ -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;

View file

@ -262,10 +262,10 @@ void DefaultWindowHelper::init() {
Qt::WindowStates windowState) {
if (const auto handle = window()->windowHandle()) {
handle->setFlag(Qt::FramelessWindowHint, titleShown);
updateWindowExtents();
} else {
window()->setWindowFlag(Qt::FramelessWindowHint, titleShown);
}
updateWindowExtents();
}, window()->lifetime());
window()->events() | rpl::start_with_next([=](not_null<QEvent*> e) {
@ -315,7 +315,7 @@ void DefaultWindowHelper::updateRoundingOverlay() {
rect.topRight() - QPoint(radiusWithFix, 0),
radiusSize
)) || clip.intersects(QRect(
rect.bottomRight() - QPoint(0, radiusWithFix),
rect.bottomLeft() - QPoint(0, radiusWithFix),
radiusSize
)) || clip.intersects(QRect(
rect.bottomRight() - QPoint(radiusWithFix, radiusWithFix),

View file

@ -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(

View file

@ -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;

View file

@ -244,6 +244,18 @@ void WindowHelper::setNativeFrame(bool enabled) {
updateMargins();
updateWindowFrameColors();
fixMaximizedWindow();
SetWindowPos(
_handle,
0,
0,
0,
0,
0,
SWP_FRAMECHANGED
| SWP_NOMOVE
| SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE);
}
void WindowHelper::initialShadowUpdate() {
@ -403,17 +415,14 @@ bool WindowHelper::handleNativeEvent(
} return true;
case WM_NCCALCSIZE: {
if (_title->isHidden()) {
if (_title->isHidden() || !wParam) {
return false;
}
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
if (GetWindowPlacement(_handle, &wp)
&& (wp.showCmd == SW_SHOWMAXIMIZED)) {
const auto params = (LPNCCALCSIZE_PARAMS)lParam;
const auto r = (wParam == TRUE)
? &params->rgrc[0]
: (LPRECT)lParam;
const auto r = &((LPNCCALCSIZE_PARAMS)lParam)->rgrc[0];
const auto hMonitor = MonitorFromPoint(
{ (r->left + r->right) / 2, (r->top + r->bottom) / 2 },
MONITOR_DEFAULTTONEAREST);
@ -433,8 +442,10 @@ bool WindowHelper::handleNativeEvent(
}
}
}
if (result) *result = 0;
} else {
if (result) *result = WVR_REDRAW;
}
if (result) *result = 0;
return true;
}
@ -444,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;
@ -536,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;