fix(power):Fix poweroff action while button event duplicate once clicked
-适配单次点击电源按钮触发多次按键事件下电源响应操作 Related #28620
This commit is contained in:
parent
b3a685f1d6
commit
734c1da15e
112
0016-fix-power-Fix-poweroff-action-while-button-event-dup.patch
Normal file
112
0016-fix-power-Fix-poweroff-action-while-button-event-dup.patch
Normal file
@ -0,0 +1,112 @@
|
||||
From e75c9d9f6b83705482053f1b5451e96820da1e9c Mon Sep 17 00:00:00 2001
|
||||
From: meizhigang <meizhigang@kylinsec.com.cn>
|
||||
Date: Mon, 22 Apr 2024 11:26:16 +0800
|
||||
Subject: [PATCH] fix(power):Fix poweroff action while button event duplicate
|
||||
once clicked
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
-适配单次点击电源按钮触发多次按键事件下电源响应操作
|
||||
|
||||
Related #28620
|
||||
---
|
||||
plugins/power/event/power-event-button.cpp | 38 ++++++++++++++++++++++
|
||||
plugins/power/event/power-event-button.h | 8 +++++
|
||||
2 files changed, 46 insertions(+)
|
||||
|
||||
diff --git a/plugins/power/event/power-event-button.cpp b/plugins/power/event/power-event-button.cpp
|
||||
index 8a17c5f..01db8eb 100644
|
||||
--- a/plugins/power/event/power-event-button.cpp
|
||||
+++ b/plugins/power/event/power-event-button.cpp
|
||||
@@ -19,6 +19,7 @@
|
||||
namespace Kiran
|
||||
{
|
||||
#define POWER_BUTTON_DUPLICATE_TIMEOUT 0.125f
|
||||
+#define POWER_BUTTON_POWEROFF_TIMEOUT_MILLISECONDS 125
|
||||
|
||||
PowerEventButton::PowerEventButton() : login1_inhibit_fd_(-1)
|
||||
{
|
||||
@@ -40,6 +41,11 @@ PowerEventButton::~PowerEventButton()
|
||||
{
|
||||
close(this->login1_inhibit_fd_);
|
||||
}
|
||||
+
|
||||
+ if (this->poweroff_timeout_id_)
|
||||
+ {
|
||||
+ this->poweroff_timeout_id_.disconnect();
|
||||
+ }
|
||||
}
|
||||
|
||||
void PowerEventButton::init()
|
||||
@@ -106,8 +112,40 @@ bool PowerEventButton::register_button(uint32_t keysym, PowerEvent type)
|
||||
return true;
|
||||
}
|
||||
|
||||
+bool PowerEventButton::on_poweroff_timeout()
|
||||
+{
|
||||
+ this->button_changed_.emit(POWER_EVENT_RELEASE_POWEROFF);
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+void PowerEventButton::add_poweroff_timeout()
|
||||
+{
|
||||
+ if (!this->poweroff_timeout_id_)
|
||||
+ {
|
||||
+ this->poweroff_timeout_id_ = Glib::signal_timeout().connect(
|
||||
+ sigc::mem_fun(this, &PowerEventButton::on_poweroff_timeout),
|
||||
+ POWER_BUTTON_POWEROFF_TIMEOUT_MILLISECONDS);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void PowerEventButton::remove_poweroff_timeout()
|
||||
+{
|
||||
+ if (this->poweroff_timeout_id_)
|
||||
+ {
|
||||
+ this->poweroff_timeout_id_.disconnect();
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void PowerEventButton::emit_button_signal(PowerEvent type)
|
||||
{
|
||||
+ // 仅电源按键事件延迟处理,避免单次点击电源按钮短时间触发多次按键事件,导致息屏又立即唤醒
|
||||
+ if (type == POWER_EVENT_RELEASE_POWEROFF)
|
||||
+ {
|
||||
+ this->remove_poweroff_timeout();
|
||||
+ this->add_poweroff_timeout();
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
unsigned long elapsed_msec;
|
||||
if (this->button_signal_timer_.elapsed(elapsed_msec) < POWER_BUTTON_DUPLICATE_TIMEOUT)
|
||||
{
|
||||
diff --git a/plugins/power/event/power-event-button.h b/plugins/power/event/power-event-button.h
|
||||
index 94c0b2d..6f0aff7 100644
|
||||
--- a/plugins/power/event/power-event-button.h
|
||||
+++ b/plugins/power/event/power-event-button.h
|
||||
@@ -41,6 +41,12 @@ private:
|
||||
// 发送按键信号,如果跟上一次发送的按键信号相同且时间间隔较短,则忽略该次按键信号的发送
|
||||
void emit_button_signal(PowerEvent type);
|
||||
|
||||
+ bool on_poweroff_timeout();
|
||||
+
|
||||
+ void add_poweroff_timeout();
|
||||
+
|
||||
+ void remove_poweroff_timeout();
|
||||
+
|
||||
void on_lid_is_closed_change(bool lid_is_closed);
|
||||
static GdkFilterReturn window_event(GdkXEvent *gdk_event, GdkEvent *event, gpointer data);
|
||||
|
||||
@@ -59,6 +65,8 @@ private:
|
||||
std::map<std::string, PowerEvent> buttons_;
|
||||
Glib::Timer button_signal_timer_;
|
||||
|
||||
+ sigc::connection poweroff_timeout_id_;
|
||||
+
|
||||
sigc::signal<void, PowerEvent> button_changed_;
|
||||
};
|
||||
} // namespace Kiran
|
||||
\ No newline at end of file
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: kiran-cc-daemon
|
||||
Version: 2.6.1
|
||||
Release: 14%{?dist}
|
||||
Release: 15%{?dist}
|
||||
Summary: DBus daemon for Kiran Desktop
|
||||
|
||||
License: MulanPSL-2.0
|
||||
@ -24,6 +24,7 @@ Patch0012: 0012-fix-power-Fix-battery-charging-and-discharging-time.patch
|
||||
Patch0013: 0013-fix-power-Fix-sys-backlight-set-only-in-notebook-wit.patch
|
||||
Patch0014: 0014-fix-touchpad-Fix-touchpad-control-with-the-type-psmo.patch
|
||||
Patch0015: 0015-fix-display-Fix-handling-Dbus-method-calls-returning.patch
|
||||
Patch0016: 0016-fix-power-Fix-poweroff-action-while-button-event-dup.patch
|
||||
|
||||
BuildRequires: cmake >= 3.2
|
||||
BuildRequires: pkgconfig(glibmm-2.4)
|
||||
@ -210,6 +211,9 @@ glib-compile-schemas /usr/share/glib-2.0/schemas &> /dev/nulls || :
|
||||
%{_libdir}/pkgconfig/kiran-cc-daemon.pc
|
||||
|
||||
%changelog
|
||||
* Mon Apr 22 2024 meizhigang <meizhigang@kylinsec.com.cn> - 2.6.1-15
|
||||
- KYOS-B: Fix poweroff action while button event duplicate once clicked (#28620)
|
||||
|
||||
* Thu Apr 18 2024 liuxinhao <liuxinhao@kylinsec.com.cn> - 2.6.1-14
|
||||
- KYOS-B: Fix handling Dbus method calls returning twice causing crashes(#35488)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user