mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Fix crash in main menu swipes on macOS.
This commit is contained in:
parent
af35beefc2
commit
fe0c1acd79
2 changed files with 23 additions and 4 deletions
|
@ -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() {
|
void MainMenu::setupSwipe() {
|
||||||
const auto outer = _controller->widget()->body();
|
const auto outer = _controller->widget()->body();
|
||||||
base::install_event_filter(this, outer, [=](not_null<QEvent*> e) {
|
base::install_event_filter(this, outer, [=](not_null<QEvent*> e) {
|
||||||
|
@ -1020,14 +1033,12 @@ void MainMenu::setupSwipe() {
|
||||||
|| type == QEvent::TouchUpdate
|
|| type == QEvent::TouchUpdate
|
||||||
|| type == QEvent::TouchEnd
|
|| type == QEvent::TouchEnd
|
||||||
|| type == QEvent::TouchCancel) {
|
|| type == QEvent::TouchCancel) {
|
||||||
QGuiApplication::sendEvent(_inner, e);
|
return redirectToInnerChecked(e);
|
||||||
return base::EventFilterResult::Cancel;
|
|
||||||
} else if (type == QEvent::Wheel) {
|
} else if (type == QEvent::Wheel) {
|
||||||
const auto w = static_cast<QWheelEvent*>(e.get());
|
const auto w = static_cast<QWheelEvent*>(e.get());
|
||||||
const auto d = Ui::ScrollDeltaF(w);
|
const auto d = Ui::ScrollDeltaF(w);
|
||||||
if (std::abs(d.x()) > std::abs(d.y())) {
|
if (std::abs(d.x()) > std::abs(d.y())) {
|
||||||
QGuiApplication::sendEvent(_inner, e);
|
return redirectToInnerChecked(e);
|
||||||
return base::EventFilterResult::Cancel;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return base::EventFilterResult::Continue;
|
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/controls/swipe_handler_data.h"
|
||||||
#include "ui/layers/layer_widget.h"
|
#include "ui/layers/layer_widget.h"
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
enum class EventFilterResult;
|
||||||
|
} // namespace base
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class IconButton;
|
class IconButton;
|
||||||
class FlatLabel;
|
class FlatLabel;
|
||||||
|
@ -76,6 +80,9 @@ private:
|
||||||
void chooseEmojiStatus();
|
void chooseEmojiStatus();
|
||||||
void setupSwipe();
|
void setupSwipe();
|
||||||
|
|
||||||
|
[[nodiscard]] base::EventFilterResult redirectToInnerChecked(
|
||||||
|
not_null<QEvent*> e);
|
||||||
|
|
||||||
void drawName(Painter &p);
|
void drawName(Painter &p);
|
||||||
|
|
||||||
const not_null<SessionController*> _controller;
|
const not_null<SessionController*> _controller;
|
||||||
|
@ -104,6 +111,7 @@ private:
|
||||||
Ui::Controls::SwipeBackResult _swipeBackData;
|
Ui::Controls::SwipeBackResult _swipeBackData;
|
||||||
|
|
||||||
rpl::variable<bool> _showFinished = false;
|
rpl::variable<bool> _showFinished = false;
|
||||||
|
bool _insideEventRedirect = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue