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/debug_log.h"
#include <QtGui/QScreen>
namespace Ui::GL {
namespace {
@ -95,9 +97,19 @@ std::unique_ptr<Ui::RpWidget> Window::createNativeBodyWrap() {
raw->setParent(nativeParent);
raw->show();
raw->update();
_window->sizeValue(
) | 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());
return result;

View file

@ -585,12 +585,18 @@ not_null<WindowHelper::NativeFilter*> WindowHelper::GetNativeFilter() {
return GlobalFilter;
}
HWND GetWindowHandle(not_null<RpWidget*> widget) {
widget->window()->createWinId();
HWND GetWindowHandle(not_null<QWidget*> widget) {
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();
Assert(window != nullptr);
Assert(native != nullptr);
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 Ui