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 <crl/crl_time.h>
#include <rpl/lifetime.h> #include <rpl/lifetime.h>
#include <QtCore/QObject>
namespace Ui { namespace Ui {
namespace Animations { namespace Animations {

View file

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

View file

@ -21,6 +21,7 @@
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION #endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
#include <QtCore/QPoint> #include <QtCore/QPoint>
#include <QtGui/QWindow>
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
namespace Ui { namespace Ui {
@ -236,9 +237,9 @@ std::optional<bool> XCBIsOverlapped(
const auto mappedRect = QRect( const auto mappedRect = QRect(
rect.topLeft() rect.topLeft()
* widget->devicePixelRatioF() * widget->windowHandle()->devicePixelRatio()
+ windowGeometry.topLeft(), + windowGeometry.topLeft(),
rect.size() * widget->devicePixelRatioF()); rect.size() * widget->windowHandle()->devicePixelRatio());
const auto cookie = xcb_query_tree(connection, *root); const auto cookie = xcb_query_tree(connection, *root);
const auto reply = base::Platform::XCB::MakeReplyPointer( const auto reply = base::Platform::XCB::MakeReplyPointer(
@ -304,7 +305,9 @@ void SetXCBFrameExtents(not_null<QWidget*> widget, const QMargins &extents) {
return; return;
} }
const auto nativeExtents = extents * widget->devicePixelRatioF(); const auto nativeExtents = extents
* widget->windowHandle()->devicePixelRatio();
const auto extentsVector = std::vector<uint>{ const auto extentsVector = std::vector<uint>{
uint(nativeExtents.left()), uint(nativeExtents.left()),
uint(nativeExtents.right()), uint(nativeExtents.right()),
@ -368,7 +371,7 @@ void ShowXCBWindowMenu(not_null<QWidget*> widget, const QPoint &point) {
} }
const auto globalPos = point const auto globalPos = point
* widget->devicePixelRatioF() * widget->windowHandle()->devicePixelRatio()
+ windowGeometry.topLeft(); + windowGeometry.topLeft();
xcb_client_message_event_t xev; xcb_client_message_event_t xev;

View file

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

View file

@ -9,6 +9,7 @@
#include "base/platform/win/base_windows_h.h" #include "base/platform/win/base_windows_h.h"
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
#include <QtGui/QWindow>
#include <wrl/client.h> #include <wrl/client.h>
#include <Shobjidl.h> #include <Shobjidl.h>
@ -75,7 +76,7 @@ std::optional<bool> IsOverlapped(
const auto nativeRect = [&] { const auto nativeRect = [&] {
const auto topLeft = [&] { const auto topLeft = [&] {
const auto qpoints = rect.topLeft() const auto qpoints = rect.topLeft()
* widget->devicePixelRatioF(); * widget->windowHandle()->devicePixelRatio();
POINT result{ POINT result{
qpoints.x(), qpoints.x(),
qpoints.y(), qpoints.y(),
@ -85,7 +86,7 @@ std::optional<bool> IsOverlapped(
}(); }();
const auto bottomRight = [&] { const auto bottomRight = [&] {
const auto qpoints = rect.bottomRight() const auto qpoints = rect.bottomRight()
* widget->devicePixelRatioF(); * widget->windowHandle()->devicePixelRatio();
POINT result{ POINT result{
qpoints.x(), qpoints.x(),
qpoints.y(), qpoints.y(),
@ -122,7 +123,7 @@ std::optional<bool> IsOverlapped(
void ShowWindowMenu(not_null<QWidget*> widget, const QPoint &point) { void ShowWindowMenu(not_null<QWidget*> widget, const QPoint &point) {
const auto handle = HWND(widget->winId()); 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() }; POINT p{ mapped.x(), mapped.y() };
ClientToScreen(handle, &p); ClientToScreen(handle, &p);
SendMessage( SendMessage(

View file

@ -205,7 +205,8 @@ void TitleWidget::refreshAdditionalPaddings(
return -1; return -1;
} }
const auto pixels = (factor + 50) / 100; const auto pixels = (factor + 50) / 100;
return int(base::SafeRound(pixels / window()->devicePixelRatioF())); return int(base::SafeRound(
pixels / window()->windowHandle()->devicePixelRatio()));
}(); }();
if (padding < 0) { if (padding < 0) {
return; return;

View file

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