fix(power):Change poweroff action from key press to release
- 修改关机动作从按键按下时变为释放时触发 Related #11422
This commit is contained in:
parent
24aa925a49
commit
6a7a510b42
134
0001-fix-power-Change-poweroff-action-from-key-press-to-r.patch
Normal file
134
0001-fix-power-Change-poweroff-action-from-key-press-to-r.patch
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
From ca64260a4385ec5dd31e9481bb6f3f9b567a9e02 Mon Sep 17 00:00:00 2001
|
||||||
|
From: meizhigang <meizhigang@kylinsec.com.cn>
|
||||||
|
Date: Mon, 21 Aug 2023 10:53:20 +0800
|
||||||
|
Subject: [PATCH] fix(power):Change poweroff action from key press to release
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
- 修改关机动作从按键按下时变为释放时触发
|
||||||
|
|
||||||
|
Related #11422
|
||||||
|
---
|
||||||
|
include/power-i.h | 4 ++--
|
||||||
|
plugins/power/event/power-event-button.cpp | 13 ++++++++++---
|
||||||
|
plugins/power/event/power-event-control.cpp | 2 +-
|
||||||
|
plugins/power/power-manager.cpp | 6 +++---
|
||||||
|
plugins/power/power-utils.cpp | 4 ++--
|
||||||
|
5 files changed, 18 insertions(+), 11 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/include/power-i.h b/include/power-i.h
|
||||||
|
index 895c93e..ace2ec6 100644
|
||||||
|
--- a/include/power-i.h
|
||||||
|
+++ b/include/power-i.h
|
||||||
|
@@ -67,8 +67,8 @@ extern "C"
|
||||||
|
|
||||||
|
enum PowerEvent
|
||||||
|
{
|
||||||
|
- // 按下关机键
|
||||||
|
- POWER_EVENT_PRESSED_POWEROFF = 0,
|
||||||
|
+ // 释放关机键
|
||||||
|
+ POWER_EVENT_RELEASE_POWEROFF = 0,
|
||||||
|
// 按下睡眠键
|
||||||
|
POWER_EVENT_PRESSED_SLEEP,
|
||||||
|
// 按下挂起键
|
||||||
|
diff --git a/plugins/power/event/power-event-button.cpp b/plugins/power/event/power-event-button.cpp
|
||||||
|
index 082397b..4fe7747 100644
|
||||||
|
--- a/plugins/power/event/power-event-button.cpp
|
||||||
|
+++ b/plugins/power/event/power-event-button.cpp
|
||||||
|
@@ -48,7 +48,7 @@ void PowerEventButton::init()
|
||||||
|
auto login1 = PowerWrapperManager::get_instance()->get_default_login1();
|
||||||
|
this->login1_inhibit_fd_ = login1->inhibit("handle-power-key:handle-suspend-key:handle-lid-switch");
|
||||||
|
|
||||||
|
- this->register_button(XF86XK_PowerOff, PowerEvent::POWER_EVENT_PRESSED_POWEROFF);
|
||||||
|
+ this->register_button(XF86XK_PowerOff, PowerEvent::POWER_EVENT_RELEASE_POWEROFF);
|
||||||
|
this->register_button(XF86XK_Suspend, PowerEvent::POWER_EVENT_PRESSED_SUSPEND);
|
||||||
|
this->register_button(XF86XK_Sleep, PowerEvent::POWER_EVENT_PRESSED_SLEEP);
|
||||||
|
this->register_button(XF86XK_Hibernate, PowerEvent::POWER_EVENT_PRESSED_HIBERNATE);
|
||||||
|
@@ -136,7 +136,14 @@ GdkFilterReturn PowerEventButton::window_event(GdkXEvent *gdk_event, GdkEvent *e
|
||||||
|
auto button = (PowerEventButton *)data;
|
||||||
|
XEvent *xevent = (XEvent *)gdk_event;
|
||||||
|
|
||||||
|
- RETURN_VAL_IF_TRUE(xevent->type != KeyPress, GDK_FILTER_CONTINUE);
|
||||||
|
+ if (xevent->xkey.keycode == XKeysymToKeycode(button->xdisplay_, XF86XK_PowerOff))
|
||||||
|
+ {
|
||||||
|
+ RETURN_VAL_IF_TRUE(xevent->type != KeyRelease, GDK_FILTER_CONTINUE);
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ RETURN_VAL_IF_TRUE(xevent->type != KeyPress, GDK_FILTER_CONTINUE);
|
||||||
|
+ }
|
||||||
|
|
||||||
|
auto keycode = xevent->xkey.keycode;
|
||||||
|
auto keycode_str = fmt::format("0x{:x}", keycode);
|
||||||
|
@@ -148,7 +155,7 @@ GdkFilterReturn PowerEventButton::window_event(GdkXEvent *gdk_event, GdkEvent *e
|
||||||
|
return GDK_FILTER_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
- KLOG_DEBUG("Receipt keycode signal: %s.", keycode_str.c_str());
|
||||||
|
+ KLOG_DEBUG("Receipt keycode signal: %s, event type: %d.", keycode_str.c_str(), xevent->type);
|
||||||
|
button->emit_button_signal(iter->second);
|
||||||
|
|
||||||
|
return GDK_FILTER_REMOVE;
|
||||||
|
diff --git a/plugins/power/event/power-event-control.cpp b/plugins/power/event/power-event-control.cpp
|
||||||
|
index d852c80..c3c0345 100644
|
||||||
|
--- a/plugins/power/event/power-event-control.cpp
|
||||||
|
+++ b/plugins/power/event/power-event-control.cpp
|
||||||
|
@@ -157,7 +157,7 @@ void PowerEventControl::on_button_changed(PowerEvent evnet)
|
||||||
|
|
||||||
|
switch (evnet)
|
||||||
|
{
|
||||||
|
- case POWER_EVENT_PRESSED_POWEROFF:
|
||||||
|
+ case POWER_EVENT_RELEASE_POWEROFF:
|
||||||
|
{
|
||||||
|
action = PowerAction(this->power_settings_->get_enum(POWER_SCHEMA_BUTTON_POWER_ACTION));
|
||||||
|
PowerSave::get_instance()->do_save(action, error);
|
||||||
|
diff --git a/plugins/power/power-manager.cpp b/plugins/power/power-manager.cpp
|
||||||
|
index cf5d8d5..e1f90d2 100644
|
||||||
|
--- a/plugins/power/power-manager.cpp
|
||||||
|
+++ b/plugins/power/power-manager.cpp
|
||||||
|
@@ -188,7 +188,7 @@ void PowerManager::SetEventAction(gint32 event,
|
||||||
|
|
||||||
|
switch (event)
|
||||||
|
{
|
||||||
|
- case PowerEvent::POWER_EVENT_PRESSED_POWEROFF:
|
||||||
|
+ case PowerEvent::POWER_EVENT_RELEASE_POWEROFF:
|
||||||
|
result = this->power_settings_->set_enum(POWER_SCHEMA_BUTTON_POWER_ACTION, action);
|
||||||
|
break;
|
||||||
|
case PowerEvent::POWER_EVENT_PRESSED_SLEEP:
|
||||||
|
@@ -225,7 +225,7 @@ void PowerManager::GetEventAction(gint32 event,
|
||||||
|
|
||||||
|
switch (event)
|
||||||
|
{
|
||||||
|
- case PowerEvent::POWER_EVENT_PRESSED_POWEROFF:
|
||||||
|
+ case PowerEvent::POWER_EVENT_RELEASE_POWEROFF:
|
||||||
|
action = this->power_settings_->get_enum(POWER_SCHEMA_BUTTON_POWER_ACTION);
|
||||||
|
break;
|
||||||
|
case PowerEvent::POWER_EVENT_PRESSED_SLEEP:
|
||||||
|
@@ -428,7 +428,7 @@ void PowerManager::on_settings_changed(const Glib::ustring& key)
|
||||||
|
this->EventActionChanged_signal.emit(PowerEvent::POWER_EVENT_PRESSED_HIBERNATE);
|
||||||
|
break;
|
||||||
|
case CONNECT(POWER_SCHEMA_BUTTON_POWER_ACTION, _hash):
|
||||||
|
- this->EventActionChanged_signal.emit(PowerEvent::POWER_EVENT_PRESSED_POWEROFF);
|
||||||
|
+ this->EventActionChanged_signal.emit(PowerEvent::POWER_EVENT_RELEASE_POWEROFF);
|
||||||
|
break;
|
||||||
|
case CONNECT(POWER_SCHEMA_LID_CLOSED_ACTION, _hash):
|
||||||
|
this->EventActionChanged_signal.emit(PowerEvent::POWER_EVENT_LID_CLOSED);
|
||||||
|
diff --git a/plugins/power/power-utils.cpp b/plugins/power/power-utils.cpp
|
||||||
|
index f04670e..a55b6df 100644
|
||||||
|
--- a/plugins/power/power-utils.cpp
|
||||||
|
+++ b/plugins/power/power-utils.cpp
|
||||||
|
@@ -77,8 +77,8 @@ std::string PowerUtils::event_enum2str(uint32_t event)
|
||||||
|
{
|
||||||
|
switch (event)
|
||||||
|
{
|
||||||
|
- case PowerEvent::POWER_EVENT_PRESSED_POWEROFF:
|
||||||
|
- return "power off pressed";
|
||||||
|
+ case PowerEvent::POWER_EVENT_RELEASE_POWEROFF:
|
||||||
|
+ return "power off release";
|
||||||
|
case PowerEvent::POWER_EVENT_PRESSED_SLEEP:
|
||||||
|
return "sleep pressed";
|
||||||
|
case PowerEvent::POWER_EVENT_PRESSED_SUSPEND:
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Name: kiran-cc-daemon
|
Name: kiran-cc-daemon
|
||||||
Version: 2.5.1
|
Version: 2.5.1
|
||||||
Release: 20
|
Release: 21
|
||||||
Summary: DBus daemon for Kiran Desktop
|
Summary: DBus daemon for Kiran Desktop
|
||||||
|
|
||||||
License: MulanPSL-2.0
|
License: MulanPSL-2.0
|
||||||
@ -24,6 +24,7 @@ Patch0015: 0001-fix-display-Fix-nvidia-display-while-no-enabled-moni.patch
|
|||||||
Patch0016: 0001-fix-xsettings-Fix-the-problem-that-variable-serial-i.patch
|
Patch0016: 0001-fix-xsettings-Fix-the-problem-that-variable-serial-i.patch
|
||||||
Patch0017: 0001-fix-accounts-Fix-user-icon-file-display-while-change.patch
|
Patch0017: 0001-fix-accounts-Fix-user-icon-file-display-while-change.patch
|
||||||
Patch0018: 0001-fix-keybindings-Remove-power-and-logout-invalid-key-.patch
|
Patch0018: 0001-fix-keybindings-Remove-power-and-logout-invalid-key-.patch
|
||||||
|
Patch0019: 0001-fix-power-Change-poweroff-action-from-key-press-to-r.patch
|
||||||
|
|
||||||
BuildRequires: cmake >= 3.2
|
BuildRequires: cmake >= 3.2
|
||||||
BuildRequires: pkgconfig(glibmm-2.4)
|
BuildRequires: pkgconfig(glibmm-2.4)
|
||||||
@ -193,6 +194,9 @@ glib-compile-schemas /usr/share/glib-2.0/schemas &> /dev/nulls || :
|
|||||||
%{_libdir}/pkgconfig/kiran-cc-daemon.pc
|
%{_libdir}/pkgconfig/kiran-cc-daemon.pc
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Aug 21 2023 meizhigang <meizhigang@kylinsec.com.cn> - 2.5.1-21
|
||||||
|
- KYOS-B: Change poweroff action from key press to release (#11422)
|
||||||
|
|
||||||
* Fri Aug 18 2023 meizhigang <meizhigang@kylinsec.com.cn> - 2.5.1-20
|
* Fri Aug 18 2023 meizhigang <meizhigang@kylinsec.com.cn> - 2.5.1-20
|
||||||
- KYOS-B: Remove power and logout invalid key from normal desktop (#11242)
|
- KYOS-B: Remove power and logout invalid key from normal desktop (#11242)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user