Replace fullscreen mask workaround with Qt one

This commit is contained in:
Ilya Fedin 2024-09-03 10:09:41 +04:00 committed by John Preston
parent 3a9eb8463d
commit a307e7a798
2 changed files with 14 additions and 27 deletions

View file

@ -998,35 +998,15 @@ void OverlayWidget::updateGeometry(bool inMove) {
void OverlayWidget::updateGeometryToScreen(bool inMove) {
const auto available = _window->screen()->geometry();
const auto openglWidget = _opengl
? static_cast<QOpenGLWidget*>(_widget.get())
: nullptr;
const auto possibleSizeHack = Platform::IsWindows() && openglWidget;
const auto useSizeHack = possibleSizeHack
&& (openglWidget->format().renderableType()
!= QSurfaceFormat::OpenGLES);
const auto use = useSizeHack
? available.marginsAdded({ 0, 0, 0, 1 })
: available;
const auto mask = useSizeHack
? QRegion(QRect(QPoint(), available.size()))
: QRegion();
if (inMove && use.contains(_window->geometry())) {
return;
}
if ((_window->geometry() == use)
&& (!possibleSizeHack || _window->mask() == mask)) {
if (_window->geometry() == available) {
return;
}
DEBUG_LOG(("Viewer Pos: Setting %1, %2, %3, %4")
.arg(use.x())
.arg(use.y())
.arg(use.width())
.arg(use.height()));
_window->setGeometry(use);
if (possibleSizeHack) {
_window->setMask(mask);
}
.arg(available.x())
.arg(available.y())
.arg(available.width())
.arg(available.height()));
_window->setGeometry(available);
}
void OverlayWidget::updateControlsGeometry() {

View file

@ -19,8 +19,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "tray.h"
#include "styles/style_window.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QAbstractNativeEventFilter>
#include <private/qguiapplication_p.h>
#include <propvarutil.h>
#include <propkey.h>
@ -28,6 +28,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Platform {
void WindowsIntegration::init() {
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
using namespace QNativeInterface::Private;
const auto native = qApp->nativeInterface<QWindowsApplication>();
if (native) {
native->setHasBorderInFullScreenDefault(true);
}
#endif // Qt >= 6.5.0
QCoreApplication::instance()->installNativeEventFilter(this);
_taskbarCreatedMsgId = RegisterWindowMessage(L"TaskbarButtonCreated");
}