From ec8d48042e069be15854ff2bb69c5052e92adae7 Mon Sep 17 00:00:00 2001 From: chenyuanbo Date: Tue, 24 Nov 2026 14:24:16 +0800 Subject: [PATCH] fix(osd): speed up checkmark updates during Super+P cycling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Dispatch repeat display-mode requests without the 100 ms delay when the OSD is visible and no earlier request is pending. 2. Advance the checkmark directly on repeat presses without resyncing. 3. Cancel pending hides on request receipt and OSD refresh to keep the window visible while delayed requests wait. Log: Make the Super+P display-mode selection respond to repeat presses Influence: 1. Verify the first Super+P press shows the current mode. 2. Verify each repeat advances the checkmark and only the final mode is applied after two seconds without another press. 3. Press again just before the OSD hides and verify it stays visible. fix(osd): 加快 Super+P 连按轮选显示模式时的勾选更新 1. 显示模式 OSD 已打开且无较早请求等待时,立即分发连按事件。 2. 连按时使用已有列表直接更新勾选,跳过同步读取。 3. 收到请求和刷新 OSD 时取消待执行的隐藏动作,避免延迟分发期间闪烁。 Influence: 1. 首按 Super+P,确认界面显示当前模式。 2. 连按时确认勾选逐次前进,停手两秒后只应用最后选中的模式。 3. 在 OSD 即将隐藏时再次按键,确认窗口继续显示。 Log: 改善 Super+P 连按时显示模式勾选的响应速度 PMS: BUG-383567 --- .../osd/displaymode/package/main.qml | 23 +++++++--------- panels/notification/osd/osdpanel.cpp | 27 ++++++++++++++----- panels/notification/osd/osdpanel.h | 4 ++- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/panels/notification/osd/displaymode/package/main.qml b/panels/notification/osd/displaymode/package/main.qml index df1d933f9..1f1e6a20a 100644 --- a/panels/notification/osd/displaymode/package/main.qml +++ b/panels/notification/osd/displaymode/package/main.qml @@ -18,22 +18,19 @@ AppletItem { function update(osdType) { - Applet.sync() - if (match(osdType)) { - - if (osdType === "DirectSwitchLayout") { - if (Applet.state !== 2) { - Applet.doAction() - } - } else if (osdType === "SwitchMonitors") { - if (Panel.lastOsdType() === osdType) { - Applet.next() - } - } + if (!match(osdType)) + return false + if (osdType === "SwitchMonitors" && Panel.lastOsdType() === osdType) { + Applet.next() return true } - return false + + Applet.sync() + if (osdType === "DirectSwitchLayout" && Applet.state !== 2) + Applet.doAction() + + return true } function match(osdType) { diff --git a/panels/notification/osd/osdpanel.cpp b/panels/notification/osd/osdpanel.cpp index 6d47be03d..8dc5d8a58 100644 --- a/panels/notification/osd/osdpanel.cpp +++ b/panels/notification/osd/osdpanel.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -48,6 +48,9 @@ bool OsdPanel::init() m_osdTimer->setInterval(m_interval); m_osdTimer->setSingleShot(true); QObject::connect(m_osdTimer, &QTimer::timeout, this, &OsdPanel::doneSetting); + m_hideTimer = new QTimer(this); + m_hideTimer->setSingleShot(true); + connect(m_hideTimer, &QTimer::timeout, this, &OsdPanel::hideOsd); return DPanel::init(); } @@ -65,12 +68,25 @@ bool OsdPanel::visible() const void OsdPanel::ShowOSD(const QString &text) { + m_hideTimer->stop(); qCInfo(osdLog()) << "show text" << text; m_osdTimer->setInterval(text == "SwitchWM3D" ? 2000 : 1000); - - QTimer::singleShot(100, this, [this, text]() { + const auto dispatch = [this, text] { setOsdType(text); showOsd(); + }; + + // Keep repeat presses behind any OSD requests already scheduled for delivery. + if (m_visible && m_pendingDispatches == 0 && text == QLatin1String("SwitchMonitors") + && m_lastOsdType == text) { + dispatch(); + return; + } + + ++m_pendingDispatches; + QTimer::singleShot(100, this, [this, dispatch] { + dispatch(); + --m_pendingDispatches; }); } @@ -83,9 +99,7 @@ void OsdPanel::doneSetting() int delay = m_osdTimer->interval() - m_osdTimer->remainingTime(); if (delay < 0) delay = 0; - QTimer::singleShot(delay,this, [this](){ - hideOsd(); - }); + m_hideTimer->start(delay); } void OsdPanel::hideOsd() @@ -97,6 +111,7 @@ void OsdPanel::hideOsd() void OsdPanel::showOsd() { + m_hideTimer->stop(); m_osdTimer->stop(); m_osdTimer->start(); diff --git a/panels/notification/osd/osdpanel.h b/panels/notification/osd/osdpanel.h index d01334189..cccffc734 100644 --- a/panels/notification/osd/osdpanel.h +++ b/panels/notification/osd/osdpanel.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -46,6 +46,8 @@ private Q_SLOTS: private: bool m_visible = false; QTimer *m_osdTimer = nullptr; + QTimer *m_hideTimer = nullptr; + int m_pendingDispatches = 0; QString m_osdType; QString m_lastOsdType; int m_interval {2000};