mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 15:13:57 +02:00
Version 5.0.2: Fix IME-to-search on macOS.
This commit is contained in:
parent
f4864cddc9
commit
31fcca245f
2 changed files with 40 additions and 2 deletions
|
@ -20,8 +20,6 @@ class MainWindow : public Window::MainWindow {
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(not_null<Window::Controller*> controller);
|
explicit MainWindow(not_null<Window::Controller*> controller);
|
||||||
|
|
||||||
bool psFilterNativeEvent(void *event);
|
|
||||||
|
|
||||||
int getCustomTitleHeight() const {
|
int getCustomTitleHeight() const {
|
||||||
return _customTitleHeight;
|
return _customTitleHeight;
|
||||||
}
|
}
|
||||||
|
@ -47,6 +45,11 @@ protected:
|
||||||
private:
|
private:
|
||||||
friend class Private;
|
friend class Private;
|
||||||
|
|
||||||
|
bool nativeEvent(
|
||||||
|
const QByteArray &eventType,
|
||||||
|
void *message,
|
||||||
|
qintptr *result) override;
|
||||||
|
|
||||||
void hideAndDeactivate();
|
void hideAndDeactivate();
|
||||||
void updateDockCounter();
|
void updateDockCounter();
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,26 @@ namespace {
|
||||||
// fullscreen mode, after that we'll hide the window no matter what.
|
// fullscreen mode, after that we'll hide the window no matter what.
|
||||||
constexpr auto kHideAfterFullscreenTimeoutMs = 3000;
|
constexpr auto kHideAfterFullscreenTimeoutMs = 3000;
|
||||||
|
|
||||||
|
[[nodiscard]] bool PossiblyTextTypingEvent(NSEvent *e) {
|
||||||
|
if ([e type] != NSEventTypeKeyDown) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
NSEventModifierFlags flags = [e modifierFlags]
|
||||||
|
& NSEventModifierFlagDeviceIndependentFlagsMask;
|
||||||
|
if ((flags & ~NSEventModifierFlagShift) != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
NSString *text = [e characters];
|
||||||
|
const auto length = int([text length]);
|
||||||
|
for (auto i = 0; i != length; ++i) {
|
||||||
|
const auto utf16 = [text characterAtIndex:i];
|
||||||
|
if (utf16 >= 32) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
class MainWindow::Private {
|
class MainWindow::Private {
|
||||||
|
@ -280,6 +300,21 @@ void MainWindow::initHook() {
|
||||||
void MainWindow::updateWindowIcon() {
|
void MainWindow::updateWindowIcon() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MainWindow::nativeEvent(
|
||||||
|
const QByteArray &eventType,
|
||||||
|
void *message,
|
||||||
|
qintptr *result) {
|
||||||
|
if (message && eventType == "NSEvent") {
|
||||||
|
const auto event = static_cast<NSEvent*>(message);
|
||||||
|
if (PossiblyTextTypingEvent(event)) {
|
||||||
|
Core::Sandbox::Instance().customEnterFromEventLoop([&] {
|
||||||
|
imeCompositionStartReceived();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::hideAndDeactivate() {
|
void MainWindow::hideAndDeactivate() {
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue