mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-02 15:35:51 +00:00
Redirect IME to search on Windows.
This commit is contained in:
@@ -356,6 +356,14 @@ Widget::Widget(
|
|||||||
Ui::PostponeCall(this, [=] { listScrollUpdated(); });
|
Ui::PostponeCall(this, [=] { listScrollUpdated(); });
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
setAttribute(Qt::WA_InputMethodEnabled);
|
||||||
|
controller->widget()->imeCompositionStarts(
|
||||||
|
) | rpl::filter([=] {
|
||||||
|
return redirectImeToSearch();
|
||||||
|
}) | rpl::start_with_next([=] {
|
||||||
|
_search->setFocusFast();
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
_search->changes(
|
_search->changes(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
applySearchUpdate();
|
applySearchUpdate();
|
||||||
@@ -3290,12 +3298,17 @@ void Widget::keyPressEvent(QKeyEvent *e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Widget::redirectToSearchPossible() const {
|
||||||
|
return !_openedFolder
|
||||||
|
&& !_openedForum
|
||||||
|
&& !_childList
|
||||||
|
&& _search->isVisible()
|
||||||
|
&& !_search->hasFocus()
|
||||||
|
&& hasFocus();
|
||||||
|
}
|
||||||
|
|
||||||
bool Widget::redirectKeyToSearch(QKeyEvent *e) const {
|
bool Widget::redirectKeyToSearch(QKeyEvent *e) const {
|
||||||
if (_openedFolder
|
if (!redirectToSearchPossible()) {
|
||||||
|| _openedForum
|
|
||||||
|| _childList
|
|
||||||
|| !_search->isVisible()
|
|
||||||
|| _search->hasFocus()) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto character = !(e->modifiers() & ~Qt::ShiftModifier)
|
const auto character = !(e->modifiers() & ~Qt::ShiftModifier)
|
||||||
@@ -3316,6 +3329,10 @@ bool Widget::redirectKeyToSearch(QKeyEvent *e) const {
|
|||||||
return data && data->hasText();
|
return data && data->hasText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Widget::redirectImeToSearch() const {
|
||||||
|
return redirectToSearchPossible();
|
||||||
|
}
|
||||||
|
|
||||||
void Widget::paintEvent(QPaintEvent *e) {
|
void Widget::paintEvent(QPaintEvent *e) {
|
||||||
if (controller()->contentOverlapped(this, e)) {
|
if (controller()->contentOverlapped(this, e)) {
|
||||||
return;
|
return;
|
||||||
|
@@ -250,7 +250,9 @@ private:
|
|||||||
void updateSuggestions(anim::type animated);
|
void updateSuggestions(anim::type animated);
|
||||||
void processSearchFocusChange();
|
void processSearchFocusChange();
|
||||||
|
|
||||||
|
[[nodiscard]] bool redirectToSearchPossible() const;
|
||||||
[[nodiscard]] bool redirectKeyToSearch(QKeyEvent *e) const;
|
[[nodiscard]] bool redirectKeyToSearch(QKeyEvent *e) const;
|
||||||
|
[[nodiscard]] bool redirectImeToSearch() const;
|
||||||
|
|
||||||
MTP::Sender _api;
|
MTP::Sender _api;
|
||||||
|
|
||||||
|
@@ -480,6 +480,21 @@ bool MainWindow::initGeometryFromSystem() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MainWindow::nativeEvent(
|
||||||
|
const QByteArray &eventType,
|
||||||
|
void *message,
|
||||||
|
long *result) {
|
||||||
|
if (message) {
|
||||||
|
const auto msg = static_cast<MSG*>(message);
|
||||||
|
if (msg->message == WM_IME_STARTCOMPOSITION) {
|
||||||
|
Core::Sandbox::Instance().customEnterFromEventLoop([&] {
|
||||||
|
imeCompositionStartReceived();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::updateWindowIcon() {
|
void MainWindow::updateWindowIcon() {
|
||||||
updateTaskbarAndIconCounters();
|
updateTaskbarAndIconCounters();
|
||||||
}
|
}
|
||||||
|
@@ -48,6 +48,11 @@ protected:
|
|||||||
|
|
||||||
bool initGeometryFromSystem() override;
|
bool initGeometryFromSystem() override;
|
||||||
|
|
||||||
|
bool nativeEvent(
|
||||||
|
const QByteArray &eventType,
|
||||||
|
void *message,
|
||||||
|
long *result) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Private;
|
struct Private;
|
||||||
|
|
||||||
|
@@ -795,10 +795,18 @@ void MainWindow::setPositionInited() {
|
|||||||
_positionInited = true;
|
_positionInited = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::imeCompositionStartReceived() {
|
||||||
|
_imeCompositionStartReceived.fire({});
|
||||||
|
}
|
||||||
|
|
||||||
rpl::producer<> MainWindow::leaveEvents() const {
|
rpl::producer<> MainWindow::leaveEvents() const {
|
||||||
return _leaveEvents.events();
|
return _leaveEvents.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpl::producer<> MainWindow::imeCompositionStarts() const {
|
||||||
|
return _imeCompositionStartReceived.events();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::leaveEventHook(QEvent *e) {
|
void MainWindow::leaveEventHook(QEvent *e) {
|
||||||
_leaveEvents.fire({});
|
_leaveEvents.fire({});
|
||||||
}
|
}
|
||||||
|
@@ -119,7 +119,8 @@ public:
|
|||||||
|
|
||||||
void launchDrag(std::unique_ptr<QMimeData> data, Fn<void()> &&callback);
|
void launchDrag(std::unique_ptr<QMimeData> data, Fn<void()> &&callback);
|
||||||
|
|
||||||
rpl::producer<> leaveEvents() const;
|
[[nodiscard]] rpl::producer<> leaveEvents() const;
|
||||||
|
[[nodiscard]] rpl::producer<> imeCompositionStarts() const;
|
||||||
|
|
||||||
virtual void updateWindowIcon() = 0;
|
virtual void updateWindowIcon() = 0;
|
||||||
void updateTitle();
|
void updateTitle();
|
||||||
@@ -185,6 +186,7 @@ protected:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void imeCompositionStartReceived();
|
||||||
void setPositionInited();
|
void setPositionInited();
|
||||||
|
|
||||||
virtual QRect computeDesktopRect() const;
|
virtual QRect computeDesktopRect() const;
|
||||||
@@ -214,6 +216,7 @@ private:
|
|||||||
bool _isActive = false;
|
bool _isActive = false;
|
||||||
|
|
||||||
rpl::event_stream<> _leaveEvents;
|
rpl::event_stream<> _leaveEvents;
|
||||||
|
rpl::event_stream<> _imeCompositionStartReceived;
|
||||||
|
|
||||||
bool _maximizedBeforeHide = false;
|
bool _maximizedBeforeHide = false;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user