2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Show preview on Force-Click on macOS.

This commit is contained in:
John Preston
2024-05-29 12:06:30 +04:00
parent d6e827e982
commit 2b9e7a6b25
5 changed files with 44 additions and 3 deletions

View File

@@ -28,6 +28,10 @@ public:
void updateWindowIcon() override;
rpl::producer<QPoint> globalForceClicks() override {
return _forceClicks.events();
}
class Private;
protected:
@@ -85,7 +89,9 @@ private:
QAction *psMonospace = nullptr;
QAction *psClearFormat = nullptr;
rpl::event_stream<QPoint> _forceClicks;
int _customTitleHeight = 0;
int _lastPressureStage = 0;
};

View File

@@ -310,6 +310,16 @@ bool MainWindow::nativeEvent(
Core::Sandbox::Instance().customEnterFromEventLoop([&] {
imeCompositionStartReceived();
});
} else if ([event type] == NSEventTypePressure) {
const auto stage = [event stage];
if (_lastPressureStage != stage) {
_lastPressureStage = stage;
if (stage == 2) {
Core::Sandbox::Instance().customEnterFromEventLoop([&] {
_forceClicks.fire(QCursor::pos());
});
}
}
}
}
return false;