Fix IV window on Linux

This commit is contained in:
Ilya Fedin 2024-06-05 18:29:16 +04:00 committed by John Preston
parent 99e88d74bc
commit 2673e1df53

View file

@ -221,7 +221,7 @@ Controller::~Controller() {
void Controller::updateTitleGeometry(int newWidth) const { void Controller::updateTitleGeometry(int newWidth) const {
_subtitleWrap->setGeometry( _subtitleWrap->setGeometry(
0, 0,
st::windowTitleHeight, 0,
newWidth, newWidth,
st::ivSubtitleHeight); st::ivSubtitleHeight);
_subtitleWrap->paintRequest() | rpl::start_with_next([=](QRect clip) { _subtitleWrap->paintRequest() | rpl::start_with_next([=](QRect clip) {
@ -241,7 +241,7 @@ void Controller::updateTitleGeometry(int newWidth) const {
} }
void Controller::initControls() { void Controller::initControls() {
_subtitleWrap = std::make_unique<Ui::RpWidget>(_window.get()); _subtitleWrap = std::make_unique<Ui::RpWidget>(_window->body().get());
_subtitleText = _index.value() | rpl::filter( _subtitleText = _index.value() | rpl::filter(
rpl::mappers::_1 >= 0 rpl::mappers::_1 >= 0
) | rpl::map([=](int index) { ) | rpl::map([=](int index) {
@ -275,7 +275,7 @@ void Controller::initControls() {
_back->toggledValue( _back->toggledValue(
) | rpl::start_with_next([=](bool toggled) { ) | rpl::start_with_next([=](bool toggled) {
_subtitleLeft.start( _subtitleLeft.start(
[=] { updateTitleGeometry(_window->width()); }, [=] { updateTitleGeometry(_window->body()->width()); },
toggled ? 0. : 1., toggled ? 0. : 1.,
toggled ? 1. : 0., toggled ? 1. : 0.,
st::fadeWrapDuration); st::fadeWrapDuration);
@ -353,7 +353,7 @@ void Controller::createWindow() {
initControls(); initControls();
window->widthValue() | rpl::start_with_next([=](int width) { window->body()->widthValue() | rpl::start_with_next([=](int width) {
updateTitleGeometry(width); updateTitleGeometry(width);
}, _subtitle->lifetime()); }, _subtitle->lifetime());
@ -366,13 +366,13 @@ void Controller::createWindow() {
_delegate->ivSaveGeometry(window); _delegate->ivSaveGeometry(window);
}, window->lifetime()); }, window->lifetime());
_container = Ui::CreateChild<Ui::RpWidget>(window->window()); _container = Ui::CreateChild<Ui::RpWidget>(window->body().get());
rpl::combine( rpl::combine(
window->sizeValue(), window->body()->sizeValue(),
_subtitleWrap->heightValue() _subtitleWrap->heightValue()
) | rpl::start_with_next([=](QSize size, int title) { ) | rpl::start_with_next([=](QSize size, int title) {
_container->setGeometry(QRect(QPoint(), size).marginsRemoved( _container->setGeometry(QRect(QPoint(), size).marginsRemoved(
{ 0, title + st::windowTitleHeight, 0, 0 })); { 0, title, 0, 0 }));
}, _container->lifetime()); }, _container->lifetime());
_container->paintRequest() | rpl::start_with_next([=](QRect clip) { _container->paintRequest() | rpl::start_with_next([=](QRect clip) {
@ -807,11 +807,10 @@ void Controller::showShareMenu() {
} }
_shareWrap = std::make_unique<Ui::RpWidget>(_shareHidesContent _shareWrap = std::make_unique<Ui::RpWidget>(_shareHidesContent
? _window->window() ? _window->body().get()
: nullptr); : nullptr);
const auto margins = QMargins(0, st::windowTitleHeight, 0, 0);
if (!_shareHidesContent) { if (!_shareHidesContent) {
_shareWrap->setGeometry(_window->geometry().marginsRemoved(margins)); _shareWrap->setGeometry(_window->body()->rect());
_shareWrap->setWindowFlag(Qt::FramelessWindowHint); _shareWrap->setWindowFlag(Qt::FramelessWindowHint);
_shareWrap->setAttribute(Qt::WA_TranslucentBackground); _shareWrap->setAttribute(Qt::WA_TranslucentBackground);
_shareWrap->setAttribute(Qt::WA_NoSystemBackground); _shareWrap->setAttribute(Qt::WA_NoSystemBackground);
@ -819,14 +818,14 @@ void Controller::showShareMenu() {
_shareContainer.reset(QWidget::createWindowContainer( _shareContainer.reset(QWidget::createWindowContainer(
_shareWrap->windowHandle(), _shareWrap->windowHandle(),
_window.get(), _window->body().get(),
Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint)); Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint));
} }
_window->sizeValue() | rpl::start_with_next([=](QSize size) { _window->body()->sizeValue() | rpl::start_with_next([=](QSize size) {
const auto widget = _shareHidesContent const auto widget = _shareHidesContent
? _shareWrap.get() ? _shareWrap.get()
: _shareContainer.get(); : _shareContainer.get();
widget->setGeometry(QRect(QPoint(), size).marginsRemoved(margins)); widget->setGeometry(QRect(QPoint(), size));
}, _shareWrap->lifetime()); }, _shareWrap->lifetime());
auto result = _showShareBox({ auto result = _showShareBox({