mirror of
https://github.com/telegramdesktop/tdesktop
synced 2024-12-15 02:44:45 +00:00
Use QWidget::screen/QWidget::mask instead of QWindow ones
This commit is contained in:
parent
a3877570fe
commit
e5d8a1aa3c
@ -574,21 +574,18 @@ void ChooseSourceProcess::setupSourcesGeometry() {
|
||||
|
||||
void ChooseSourceProcess::setupGeometryWithParent(
|
||||
not_null<QWidget*> parent) {
|
||||
if (const auto handle = parent->windowHandle()) {
|
||||
_window->createWinId();
|
||||
const auto parentScreen = [&] {
|
||||
if (!::Platform::IsWayland()) {
|
||||
if (const auto screen = QGuiApplication::screenAt(
|
||||
parent->geometry().center())) {
|
||||
return screen;
|
||||
}
|
||||
const auto parentScreen = [&] {
|
||||
if (!::Platform::IsWayland()) {
|
||||
if (const auto screen = QGuiApplication::screenAt(
|
||||
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(
|
||||
parent->x() + (parent->width() - _window->width()) / 2,
|
||||
|
@ -339,7 +339,7 @@ OverlayWidget::OverlayWidget()
|
||||
if (shown) {
|
||||
const auto screenList = QGuiApplication::screens();
|
||||
DEBUG_LOG(("Viewer Pos: Shown, screen number: %1")
|
||||
.arg(screenList.indexOf(window()->screen())));
|
||||
.arg(screenList.indexOf(_widget->screen())));
|
||||
moveToScreen();
|
||||
} else {
|
||||
clearAfterHide();
|
||||
@ -490,10 +490,7 @@ void OverlayWidget::moveToScreen(bool inMove) {
|
||||
return screen;
|
||||
}
|
||||
}
|
||||
if (const auto handle = widget->windowHandle()) {
|
||||
return handle->screen();
|
||||
}
|
||||
return nullptr;
|
||||
return widget->screen();
|
||||
};
|
||||
const auto applicationWindow = Core::App().activeWindow()
|
||||
? 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")
|
||||
.arg(screenList.indexOf(myScreen))
|
||||
.arg(screenList.indexOf(activeWindowScreen)));
|
||||
window()->setScreen(activeWindowScreen);
|
||||
_widget->setScreen(activeWindowScreen);
|
||||
DEBUG_LOG(("Viewer Pos: New actual screen: %1")
|
||||
.arg(screenList.indexOf(window()->screen())));
|
||||
.arg(screenList.indexOf(_widget->screen())));
|
||||
}
|
||||
updateGeometry(inMove);
|
||||
}
|
||||
@ -516,8 +513,8 @@ void OverlayWidget::updateGeometry(bool inMove) {
|
||||
if (Platform::IsWayland()) {
|
||||
return;
|
||||
}
|
||||
const auto screen = window()->screen()
|
||||
? window()->screen()
|
||||
const auto screen = _widget->screen()
|
||||
? _widget->screen()
|
||||
: QApplication::primaryScreen();
|
||||
const auto available = screen->geometry();
|
||||
const auto openglWidget = _opengl
|
||||
@ -537,7 +534,7 @@ void OverlayWidget::updateGeometry(bool inMove) {
|
||||
return;
|
||||
}
|
||||
if ((_widget->geometry() == use)
|
||||
&& (!useSizeHack || window()->mask() == mask)) {
|
||||
&& (!useSizeHack || _widget->mask() == mask)) {
|
||||
return;
|
||||
}
|
||||
DEBUG_LOG(("Viewer Pos: Setting %1, %2, %3, %4")
|
||||
@ -547,7 +544,7 @@ void OverlayWidget::updateGeometry(bool inMove) {
|
||||
.arg(use.height()));
|
||||
_widget->setGeometry(use);
|
||||
if (useSizeHack) {
|
||||
window()->setMask(mask);
|
||||
_widget->setMask(mask);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1501,7 +1498,7 @@ void OverlayWidget::handleScreenChanged(QScreen *screen) {
|
||||
|
||||
void OverlayWidget::subscribeToScreenGeometry() {
|
||||
_screenGeometryLifetime.destroy();
|
||||
const auto screen = window()->screen();
|
||||
const auto screen = _widget->screen();
|
||||
if (!screen) {
|
||||
return;
|
||||
}
|
||||
|
@ -418,10 +418,7 @@ rpl::producer<> PipPanel::saveGeometryRequests() const {
|
||||
}
|
||||
|
||||
QScreen *PipPanel::myScreen() const {
|
||||
if (const auto window = widget()->windowHandle()) {
|
||||
return window->screen();
|
||||
}
|
||||
return nullptr;
|
||||
return widget()->screen();
|
||||
}
|
||||
|
||||
PipPanel::Position PipPanel::countPosition() const {
|
||||
@ -473,15 +470,12 @@ void PipPanel::setPositionDefault() {
|
||||
return screen;
|
||||
}
|
||||
}
|
||||
if (const auto handle = widget->windowHandle()) {
|
||||
return handle->screen();
|
||||
}
|
||||
return nullptr;
|
||||
return widget->screen();
|
||||
};
|
||||
const auto parentScreen = widgetScreen(_parent);
|
||||
const auto myScreen = widgetScreen(widget());
|
||||
if (parentScreen && myScreen && myScreen != parentScreen) {
|
||||
widget()->windowHandle()->setScreen(parentScreen);
|
||||
widget()->setScreen(parentScreen);
|
||||
}
|
||||
const auto screen = parentScreen
|
||||
? parentScreen
|
||||
|
@ -399,16 +399,10 @@ bool MainWindow::initGeometryFromSystem() {
|
||||
if (!hasTabletView()) {
|
||||
return false;
|
||||
}
|
||||
const auto screen = [&] {
|
||||
if (const auto result = windowHandle()->screen()) {
|
||||
return result;
|
||||
}
|
||||
return QGuiApplication::primaryScreen();
|
||||
}();
|
||||
if (!screen) {
|
||||
if (!screen()) {
|
||||
return false;
|
||||
}
|
||||
Ui::RpWidget::setGeometry(screen->availableGeometry());
|
||||
Ui::RpWidget::setGeometry(screen()->availableGeometry());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ void SeparatePanel::initGeometry(QSize size) {
|
||||
const auto active = QApplication::activeWindow();
|
||||
const auto available = !active
|
||||
? QGuiApplication::primaryScreen()->availableGeometry()
|
||||
: active->windowHandle()->screen()->availableGeometry();
|
||||
: active->screen()->availableGeometry();
|
||||
const auto parentGeometry = (active
|
||||
&& active->isVisible()
|
||||
&& active->isActiveWindow())
|
||||
|
@ -386,11 +386,9 @@ void Controller::invokeForSessionController(
|
||||
}
|
||||
|
||||
QPoint Controller::getPointForCallPanelCenter() const {
|
||||
Expects(_widget.windowHandle() != nullptr);
|
||||
|
||||
return _widget.isActive()
|
||||
? _widget.geometry().center()
|
||||
: _widget.windowHandle()->screen()->geometry().center();
|
||||
: _widget.screen()->geometry().center();
|
||||
}
|
||||
|
||||
void Controller::showLogoutConfirmation() {
|
||||
|
Loading…
Reference in New Issue
Block a user