Remove unneeded primary screen fallbacks

QWidget::screen automatically fallbacks to primary screen as the last effort, so this is not needed
This commit is contained in:
Ilya Fedin 2022-04-19 08:43:43 +04:00 committed by John Preston
parent 9a4d2bc8f9
commit bf4fc2596a
3 changed files with 7 additions and 13 deletions

View File

@ -509,10 +509,7 @@ void OverlayWidget::updateGeometry(bool inMove) {
if (Platform::IsWayland()) {
return;
}
const auto screen = _widget->screen()
? _widget->screen()
: QApplication::primaryScreen();
const auto available = screen->geometry();
const auto available = _widget->screen()->geometry();
const auto openglWidget = _opengl
? static_cast<QOpenGLWidget*>(_widget.get())
: nullptr;

View File

@ -477,14 +477,11 @@ void PipPanel::setPositionDefault() {
if (parentScreen && myScreen && myScreen != parentScreen) {
widget()->setScreen(parentScreen);
}
const auto screen = parentScreen
? parentScreen
: QGuiApplication::primaryScreen();
auto position = Position();
position.snapped = RectPart::Top | RectPart::Left;
position.screen = screen->geometry();
position.screen = parentScreen->geometry();
position.geometry = QRect(0, 0, st::pipDefaultSize, st::pipDefaultSize);
setPositionOnScreen(position, screen->availableGeometry());
setPositionOnScreen(position, parentScreen->availableGeometry());
}
void PipPanel::setPositionOnScreen(Position position, QRect available) {

View File

@ -815,7 +815,7 @@ void MainWindow::updateUnreadCounter() {
}
QRect MainWindow::computeDesktopRect() const {
return (screen() ? screen() : QApplication::primaryScreen())->availableGeometry();
return screen()->availableGeometry();
}
void MainWindow::savePosition(Qt::WindowState state) {
@ -954,12 +954,12 @@ void MainWindow::showRightColumn(object_ptr<TWidget> widget) {
}
int MainWindow::maximalExtendBy() const {
auto desktop = (screen() ? screen() : QApplication::primaryScreen())->availableGeometry();
auto desktop = screen()->availableGeometry();
return std::max(desktop.width() - body()->width(), 0);
}
bool MainWindow::canExtendNoMove(int extendBy) const {
auto desktop = (screen() ? screen() : QApplication::primaryScreen())->availableGeometry();
auto desktop = screen()->availableGeometry();
auto inner = body()->mapToGlobal(body()->rect());
auto innerRight = (inner.x() + inner.width() + extendBy);
auto desktopRight = (desktop.x() + desktop.width());
@ -967,7 +967,7 @@ bool MainWindow::canExtendNoMove(int extendBy) const {
}
int MainWindow::tryToExtendWidthBy(int addToWidth) {
auto desktop = (screen() ? screen() : QApplication::primaryScreen())->availableGeometry();
auto desktop = screen()->availableGeometry();
auto inner = body()->mapToGlobal(body()->rect());
accumulate_min(
addToWidth,