Try to always use QWidget::screen

This commit is contained in:
Ilya Fedin 2024-09-09 01:33:23 +04:00 committed by John Preston
parent 4befb125e3
commit 3a9eb8463d
3 changed files with 5 additions and 30 deletions

View file

@ -23,7 +23,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <tgcalls/desktop_capturer/DesktopCaptureSourceManager.h>
#include <tgcalls/desktop_capturer/DesktopCaptureSourceHelper.h>
#include <QtGui/QGuiApplication>
#include <QtGui/QWindow>
namespace Calls::Group::Ui::DesktopCapture {
@ -585,13 +584,7 @@ void ChooseSourceProcess::setupSourcesGeometry() {
void ChooseSourceProcess::setupGeometryWithParent(
not_null<QWidget*> parent) {
const auto parentScreen = [&] {
if (const auto screen = QGuiApplication::screenAt(
parent->geometry().center())) {
return screen;
}
return parent->screen();
}();
const auto parentScreen = parent->screen();
const auto myScreen = _window->screen();
if (parentScreen && myScreen != parentScreen) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)

View file

@ -860,20 +860,12 @@ void OverlayWidget::moveToScreen(bool inMove) {
if (!_fullscreen || _wasWindowedMode) {
return;
}
const auto widgetScreen = [&](auto &&widget) -> QScreen* {
if (!widget) {
return nullptr;
}
if (const auto screen = QGuiApplication::screenAt(
widget->geometry().center())) {
return screen;
}
return widget->screen();
};
const auto applicationWindow = Core::App().activeWindow()
? Core::App().activeWindow()->widget().get()
: nullptr;
const auto activeWindowScreen = widgetScreen(applicationWindow);
const auto activeWindowScreen = applicationWindow
? applicationWindow->screen()
: nullptr;
const auto myScreen = _window->screen();
if (activeWindowScreen && myScreen != activeWindowScreen) {
const auto screenList = QGuiApplication::screens();

View file

@ -481,17 +481,7 @@ PipPanel::Position PipPanel::countPosition() const {
}
void PipPanel::setPositionDefault() {
const auto widgetScreen = [&](auto &&widget) -> QScreen* {
if (!widget) {
return nullptr;
}
if (const auto screen = QGuiApplication::screenAt(
widget->geometry().center())) {
return screen;
}
return widget->screen();
};
const auto parentScreen = widgetScreen(_parent);
const auto parentScreen = _parent ? _parent->screen() : nullptr;
const auto myScreen = widget()->screen();
if (parentScreen && myScreen != parentScreen) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)