mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-05 08:55:59 +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:
@@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include <rpl/map.h>
|
||||
#include <rpl/distinct_until_changed.h>
|
||||
#include "base/unique_qptr.h"
|
||||
#include "core/qt_signal_producer.h"
|
||||
|
||||
namespace Ui {
|
||||
namespace details {
|
||||
@@ -173,6 +174,25 @@ public:
|
||||
visibilityChangedHook(wasVisible, !this->isHidden());
|
||||
}
|
||||
|
||||
auto windowDeactivateEvents() const {
|
||||
Expects(Widget::window()->windowHandle() != nullptr);
|
||||
|
||||
const auto window = Widget::window()->windowHandle();
|
||||
return Core::QtSignalProducer(
|
||||
window,
|
||||
&QWindow::activeChanged
|
||||
) | rpl::filter([=] {
|
||||
return !window->isActive();
|
||||
});
|
||||
}
|
||||
auto macWindowDeactivateEvents() const {
|
||||
#ifdef Q_OS_MAC
|
||||
return windowDeactivateEvents();
|
||||
#else // Q_OS_MAC
|
||||
return rpl::never<rpl::empty_value>();
|
||||
#endif // Q_OS_MAC
|
||||
}
|
||||
|
||||
~RpWidgetWrap() {
|
||||
base::take(_lifetime);
|
||||
base::take(_eventStreams);
|
||||
|
Reference in New Issue
Block a user