Use QWidget::screen/QWidget::mask instead of QWindow ones

This commit is contained in:
Ilya Fedin 2022-03-21 11:41:02 +04:00 committed by John Preston
parent a3877570fe
commit e5d8a1aa3c
6 changed files with 26 additions and 46 deletions

View file

@ -574,21 +574,18 @@ void ChooseSourceProcess::setupSourcesGeometry() {
void ChooseSourceProcess::setupGeometryWithParent( void ChooseSourceProcess::setupGeometryWithParent(
not_null<QWidget*> parent) { not_null<QWidget*> parent) {
if (const auto handle = parent->windowHandle()) { const auto parentScreen = [&] {
_window->createWinId(); if (!::Platform::IsWayland()) {
const auto parentScreen = [&] { if (const auto screen = QGuiApplication::screenAt(
if (!::Platform::IsWayland()) { parent->geometry().center())) {
if (const auto screen = QGuiApplication::screenAt( return screen;
parent->geometry().center())) {
return screen;
}
} }
return handle->screen();
}();
const auto myScreen = _window->windowHandle()->screen();
if (parentScreen && myScreen != parentScreen) {
_window->windowHandle()->setScreen(parentScreen);
} }
return parent->screen();
}();
const auto myScreen = _window->screen();
if (parentScreen && myScreen != parentScreen) {
_window->setScreen(parentScreen);
} }
_window->move( _window->move(
parent->x() + (parent->width() - _window->width()) / 2, parent->x() + (parent->width() - _window->width()) / 2,

View file

@ -339,7 +339,7 @@ OverlayWidget::OverlayWidget()
if (shown) { if (shown) {
const auto screenList = QGuiApplication::screens(); const auto screenList = QGuiApplication::screens();
DEBUG_LOG(("Viewer Pos: Shown, screen number: %1") DEBUG_LOG(("Viewer Pos: Shown, screen number: %1")
.arg(screenList.indexOf(window()->screen()))); .arg(screenList.indexOf(_widget->screen())));
moveToScreen(); moveToScreen();
} else { } else {
clearAfterHide(); clearAfterHide();
@ -490,10 +490,7 @@ void OverlayWidget::moveToScreen(bool inMove) {
return screen; return screen;
} }
} }
if (const auto handle = widget->windowHandle()) { return widget->screen();
return handle->screen();
}
return nullptr;
}; };
const auto applicationWindow = Core::App().activeWindow() const auto applicationWindow = Core::App().activeWindow()
? Core::App().activeWindow()->widget().get() ? Core::App().activeWindow()->widget().get()
@ -505,9 +502,9 @@ void OverlayWidget::moveToScreen(bool inMove) {
DEBUG_LOG(("Viewer Pos: Currently on screen %1, moving to screen %2") DEBUG_LOG(("Viewer Pos: Currently on screen %1, moving to screen %2")
.arg(screenList.indexOf(myScreen)) .arg(screenList.indexOf(myScreen))
.arg(screenList.indexOf(activeWindowScreen))); .arg(screenList.indexOf(activeWindowScreen)));
window()->setScreen(activeWindowScreen); _widget->setScreen(activeWindowScreen);
DEBUG_LOG(("Viewer Pos: New actual screen: %1") DEBUG_LOG(("Viewer Pos: New actual screen: %1")
.arg(screenList.indexOf(window()->screen()))); .arg(screenList.indexOf(_widget->screen())));
} }
updateGeometry(inMove); updateGeometry(inMove);
} }
@ -516,8 +513,8 @@ void OverlayWidget::updateGeometry(bool inMove) {
if (Platform::IsWayland()) { if (Platform::IsWayland()) {
return; return;
} }
const auto screen = window()->screen() const auto screen = _widget->screen()
? window()->screen() ? _widget->screen()
: QApplication::primaryScreen(); : QApplication::primaryScreen();
const auto available = screen->geometry(); const auto available = screen->geometry();
const auto openglWidget = _opengl const auto openglWidget = _opengl
@ -537,7 +534,7 @@ void OverlayWidget::updateGeometry(bool inMove) {
return; return;
} }
if ((_widget->geometry() == use) if ((_widget->geometry() == use)
&& (!useSizeHack || window()->mask() == mask)) { && (!useSizeHack || _widget->mask() == mask)) {
return; return;
} }
DEBUG_LOG(("Viewer Pos: Setting %1, %2, %3, %4") DEBUG_LOG(("Viewer Pos: Setting %1, %2, %3, %4")
@ -547,7 +544,7 @@ void OverlayWidget::updateGeometry(bool inMove) {
.arg(use.height())); .arg(use.height()));
_widget->setGeometry(use); _widget->setGeometry(use);
if (useSizeHack) { if (useSizeHack) {
window()->setMask(mask); _widget->setMask(mask);
} }
} }
@ -1501,7 +1498,7 @@ void OverlayWidget::handleScreenChanged(QScreen *screen) {
void OverlayWidget::subscribeToScreenGeometry() { void OverlayWidget::subscribeToScreenGeometry() {
_screenGeometryLifetime.destroy(); _screenGeometryLifetime.destroy();
const auto screen = window()->screen(); const auto screen = _widget->screen();
if (!screen) { if (!screen) {
return; return;
} }

View file

@ -418,10 +418,7 @@ rpl::producer<> PipPanel::saveGeometryRequests() const {
} }
QScreen *PipPanel::myScreen() const { QScreen *PipPanel::myScreen() const {
if (const auto window = widget()->windowHandle()) { return widget()->screen();
return window->screen();
}
return nullptr;
} }
PipPanel::Position PipPanel::countPosition() const { PipPanel::Position PipPanel::countPosition() const {
@ -473,15 +470,12 @@ void PipPanel::setPositionDefault() {
return screen; return screen;
} }
} }
if (const auto handle = widget->windowHandle()) { return widget->screen();
return handle->screen();
}
return nullptr;
}; };
const auto parentScreen = widgetScreen(_parent); const auto parentScreen = widgetScreen(_parent);
const auto myScreen = widgetScreen(widget()); const auto myScreen = widgetScreen(widget());
if (parentScreen && myScreen && myScreen != parentScreen) { if (parentScreen && myScreen && myScreen != parentScreen) {
widget()->windowHandle()->setScreen(parentScreen); widget()->setScreen(parentScreen);
} }
const auto screen = parentScreen const auto screen = parentScreen
? parentScreen ? parentScreen

View file

@ -399,16 +399,10 @@ bool MainWindow::initGeometryFromSystem() {
if (!hasTabletView()) { if (!hasTabletView()) {
return false; return false;
} }
const auto screen = [&] { if (!screen()) {
if (const auto result = windowHandle()->screen()) {
return result;
}
return QGuiApplication::primaryScreen();
}();
if (!screen) {
return false; return false;
} }
Ui::RpWidget::setGeometry(screen->availableGeometry()); Ui::RpWidget::setGeometry(screen()->availableGeometry());
return true; return true;
} }

View file

@ -357,7 +357,7 @@ void SeparatePanel::initGeometry(QSize size) {
const auto active = QApplication::activeWindow(); const auto active = QApplication::activeWindow();
const auto available = !active const auto available = !active
? QGuiApplication::primaryScreen()->availableGeometry() ? QGuiApplication::primaryScreen()->availableGeometry()
: active->windowHandle()->screen()->availableGeometry(); : active->screen()->availableGeometry();
const auto parentGeometry = (active const auto parentGeometry = (active
&& active->isVisible() && active->isVisible()
&& active->isActiveWindow()) && active->isActiveWindow())

View file

@ -386,11 +386,9 @@ void Controller::invokeForSessionController(
} }
QPoint Controller::getPointForCallPanelCenter() const { QPoint Controller::getPointForCallPanelCenter() const {
Expects(_widget.windowHandle() != nullptr);
return _widget.isActive() return _widget.isActive()
? _widget.geometry().center() ? _widget.geometry().center()
: _widget.windowHandle()->screen()->geometry().center(); : _widget.screen()->geometry().center();
} }
void Controller::showLogoutConfirmation() { void Controller::showLogoutConfirmation() {