Fix full screen OpenGL native child window.

This commit is contained in:
John Preston 2021-06-21 11:28:53 +04:00
parent 685db2ab5e
commit f646439624
3 changed files with 25 additions and 6 deletions

View file

@ -11,6 +11,8 @@
#include "base/platform/base_platform_info.h" #include "base/platform/base_platform_info.h"
#include "base/debug_log.h" #include "base/debug_log.h"
#include <QtGui/QScreen>
namespace Ui::GL { namespace Ui::GL {
namespace { namespace {
@ -95,9 +97,19 @@ std::unique_ptr<Ui::RpWidget> Window::createNativeBodyWrap() {
raw->setParent(nativeParent); raw->setParent(nativeParent);
raw->show(); raw->show();
raw->update(); raw->update();
_window->sizeValue( _window->sizeValue(
) | rpl::start_with_next([=](QSize size) { ) | rpl::start_with_next([=](QSize size) {
raw->setGeometry(QRect(QPoint(), size)); auto geometry = QRect(QPoint(), size);
if constexpr (::Platform::IsWindows()) {
if (const auto screen = _window->screen()) {
if (screen->size() == size) {
// Fix flicker in FullScreen OpenGL window on Windows.
geometry = geometry.marginsAdded({ 0, 0, 0, 1 });
}
}
}
raw->setGeometry(geometry);
}, raw->lifetime()); }, raw->lifetime());
return result; return result;

View file

@ -585,12 +585,18 @@ not_null<WindowHelper::NativeFilter*> WindowHelper::GetNativeFilter() {
return GlobalFilter; return GlobalFilter;
} }
HWND GetWindowHandle(not_null<RpWidget*> widget) { HWND GetWindowHandle(not_null<QWidget*> widget) {
widget->window()->createWinId(); const auto toplevel = widget->window();
toplevel->createWinId();
return GetWindowHandle(toplevel->windowHandle());
}
HWND GetWindowHandle(not_null<QWindow*> window) {
if (!window->winId()) {
window->create();
}
const auto window = widget->window()->windowHandle();
const auto native = QGuiApplication::platformNativeInterface(); const auto native = QGuiApplication::platformNativeInterface();
Assert(window != nullptr);
Assert(native != nullptr); Assert(native != nullptr);
return static_cast<HWND>(native->nativeResourceForWindow( return static_cast<HWND>(native->nativeResourceForWindow(

View file

@ -58,7 +58,8 @@ private:
}; };
[[nodiscard]] HWND GetWindowHandle(not_null<RpWidget*> widget); [[nodiscard]] HWND GetWindowHandle(not_null<QWidget*> widget);
[[nodiscard]] HWND GetWindowHandle(not_null<QWindow*> window);
} // namespace Platform } // namespace Platform
} // namespace Ui } // namespace Ui