2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-30 22:25:12 +00:00

Fix window activations handling without event loop nesting.

This was causing an assertion violation in Ui::PostponeCall.

- Add a generic Core::QtSignalProducer to convert Qt signals to rpl::producer.
- Track event loop nesting inside QtSignalProducer.
- Use QtSignalProducer for QWindow::activeChanged tracking.
This commit is contained in:
John Preston
2019-04-05 14:13:54 +04:00
parent 41b2e7c9c7
commit 2bdce7dce6
20 changed files with 136 additions and 140 deletions

View File

@@ -718,7 +718,10 @@ void Inner::onSwitchPm() {
} // namespace internal
Widget::Widget(QWidget *parent, not_null<Window::Controller*> controller) : TWidget(parent)
Widget::Widget(
QWidget *parent,
not_null<Window::Controller*> controller)
: RpWidget(parent)
, _controller(controller)
, _contentMaxHeight(st::emojiPanMaxHeight)
, _contentHeight(_contentMaxHeight)
@@ -742,9 +745,12 @@ Widget::Widget(QWidget *parent, not_null<Window::Controller*> controller) : TWid
_inlineRequestTimer.setSingleShot(true);
connect(&_inlineRequestTimer, SIGNAL(timeout()), this, SLOT(onInlineRequest()));
if (cPlatform() == dbipMac || cPlatform() == dbipMacOld) {
connect(App::wnd()->windowHandle(), SIGNAL(activeChanged()), this, SLOT(onWndActiveChanged()));
}
macWindowDeactivateEvents(
) | rpl::filter([=] {
return !isHidden();
}) | rpl::start_with_next([=] {
leaveEvent(nullptr);
}, lifetime());
// Inner widget has OpaquePaintEvent attribute so it doesn't repaint on scroll.
// But we should force it to repaint so that GIFs will continue to animate without update() calls.
@@ -795,12 +801,6 @@ void Widget::updateContentHeight() {
update();
}
void Widget::onWndActiveChanged() {
if (!App::wnd()->windowHandle()->isActive() && !isHidden()) {
leaveEvent(0);
}
}
void Widget::paintEvent(QPaintEvent *e) {
Painter p(this);

View File

@@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "ui/twidget.h"
#include "ui/rp_widget.h"
#include "ui/abstract_button.h"
#include "ui/effects/animations.h"
#include "ui/effects/panel_animation.h"
@@ -161,7 +161,7 @@ private:
} // namespace internal
class Widget : public TWidget, private MTP::Sender {
class Widget : public Ui::RpWidget, private MTP::Sender {
Q_OBJECT
public:
@@ -192,8 +192,6 @@ protected:
void paintEvent(QPaintEvent *e) override;
private slots:
void onWndActiveChanged();
void onScroll();
void onInlineRequest();