mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Fix crash in main menu swipes on macOS.
This commit is contained in:
@@ -1012,6 +1012,19 @@ rpl::producer<OthersUnreadState> OtherAccountsUnreadState(
|
||||
});
|
||||
}
|
||||
|
||||
base::EventFilterResult MainMenu::redirectToInnerChecked(not_null<QEvent*> e) {
|
||||
if (_insideEventRedirect) {
|
||||
return base::EventFilterResult::Continue;
|
||||
}
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
_insideEventRedirect = true;
|
||||
QGuiApplication::sendEvent(_inner, e);
|
||||
if (weak) {
|
||||
_insideEventRedirect = false;
|
||||
}
|
||||
return base::EventFilterResult::Cancel;
|
||||
}
|
||||
|
||||
void MainMenu::setupSwipe() {
|
||||
const auto outer = _controller->widget()->body();
|
||||
base::install_event_filter(this, outer, [=](not_null<QEvent*> e) {
|
||||
@@ -1020,14 +1033,12 @@ void MainMenu::setupSwipe() {
|
||||
|| type == QEvent::TouchUpdate
|
||||
|| type == QEvent::TouchEnd
|
||||
|| type == QEvent::TouchCancel) {
|
||||
QGuiApplication::sendEvent(_inner, e);
|
||||
return base::EventFilterResult::Cancel;
|
||||
return redirectToInnerChecked(e);
|
||||
} else if (type == QEvent::Wheel) {
|
||||
const auto w = static_cast<QWheelEvent*>(e.get());
|
||||
const auto d = Ui::ScrollDeltaF(w);
|
||||
if (std::abs(d.x()) > std::abs(d.y())) {
|
||||
QGuiApplication::sendEvent(_inner, e);
|
||||
return base::EventFilterResult::Cancel;
|
||||
return redirectToInnerChecked(e);
|
||||
}
|
||||
}
|
||||
return base::EventFilterResult::Continue;
|
||||
|
@@ -15,6 +15,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/controls/swipe_handler_data.h"
|
||||
#include "ui/layers/layer_widget.h"
|
||||
|
||||
namespace base {
|
||||
enum class EventFilterResult;
|
||||
} // namespace base
|
||||
|
||||
namespace Ui {
|
||||
class IconButton;
|
||||
class FlatLabel;
|
||||
@@ -76,6 +80,9 @@ private:
|
||||
void chooseEmojiStatus();
|
||||
void setupSwipe();
|
||||
|
||||
[[nodiscard]] base::EventFilterResult redirectToInnerChecked(
|
||||
not_null<QEvent*> e);
|
||||
|
||||
void drawName(Painter &p);
|
||||
|
||||
const not_null<SessionController*> _controller;
|
||||
@@ -104,6 +111,7 @@ private:
|
||||
Ui::Controls::SwipeBackResult _swipeBackData;
|
||||
|
||||
rpl::variable<bool> _showFinished = false;
|
||||
bool _insideEventRedirect = false;
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user