!23 merge master

From: @dou33 
Reviewed-by: @peijiankang 
Signed-off-by: @peijiankang
This commit is contained in:
openeuler-ci-bot 2023-05-23 08:22:16 +00:00 committed by Gitee
commit 859df5d563
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 477 additions and 19 deletions

View File

@ -0,0 +1,46 @@
From 2f4033cf0d53323a70fbbae1d45ee9a82cf4e1d2 Mon Sep 17 00:00:00 2001
From: peijiankang <peijiankang@kylinos.cn>
Date: Tue, 12 Jul 2022 14:06:29 +0800
Subject: [PATCH] Touch hotkeys touch pad without customized driver
---
daemon/kmdaemon.cpp | 7 ++++++-
debian/changelog | 7 +++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/daemon/kmdaemon.cpp b/daemon/kmdaemon.cpp
index 868255f..de12c4a 100644
--- a/daemon/kmdaemon.cpp
+++ b/daemon/kmdaemon.cpp
@@ -491,7 +491,12 @@ void KMDaemon::touchpadToggle(){
XDeviceInfo deviceinfo = deviceinfos[i];
if (deviceinfo.type != XInternAtom (display, XI_TOUCHPAD, False)){
- continue;
+ if (deviceinfo.type == XInternAtom(display, XI_MOUSE, False) && strstr(deviceinfo.name, "PS\/2")){
+
+ } else {
+ continue;
+ }
+
}
prop = XInternAtom (display, "Device Enabled", False);
diff --git a/debian/changelog b/debian/changelog
index b9f4c8b..e4113af 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+kylin-display-switch (3.0.13kylin18~rc1) v101; urgency=medium
+
+ * ChangeDesc1: 适配PS/2触摸板没有厂商定制驱动情况下的触摸板热键
+ * ChangeDesc2: quilt -> native
+
+ -- hebing <hebing@kylinos.cn> Mon, 21 Jun 2021 16:51:24 +0800
+
kylin-display-switch (3.0.13-1) focal; urgency=medium
* New upstream release.
--
2.33.0

View File

@ -0,0 +1,102 @@
From a12c1bd8864b29f11ec299eb180891143616b553 Mon Sep 17 00:00:00 2001
From: peijiankang <peijiankang@kylinos.cn>
Date: Wed, 13 Jul 2022 17:36:14 +0800
Subject: [PATCH] Set 4 modes to synchronize the current state
---
kds/widget.cpp | 14 ++++++++++++++
kds/widget.h | 4 ++++
2 files changed, 18 insertions(+)
diff --git a/kds/widget.cpp b/kds/widget.cpp
index 6231623..ef45758 100644
--- a/kds/widget.cpp
+++ b/kds/widget.cpp
@@ -22,6 +22,7 @@
#include <QDebug>
#include <QScreen>
+#include <QDBusInterface>
#include <QDBusConnection>
#include <kwindowsystem.h>
@@ -50,6 +51,7 @@ Widget::Widget(QWidget *parent) :
Widget::~Widget()
{
delete ui;
+ delete ukcciface;
}
void Widget::beginSetup(){
@@ -57,6 +59,11 @@ void Widget::beginSetup(){
setAttribute(Qt::WA_TranslucentBackground, true);
+ ukcciface = new QDBusInterface("org.ukui.ukcc.session",
+ "/",
+ "org.ukui.ukcc.session.interface",
+ QDBusConnection::sessionBus());
+
/* 不在任务栏显示图标 */
KWindowSystem::setState(winId(), NET::SkipTaskbar | NET::SkipPager);
@@ -442,6 +449,8 @@ void Widget::closeApp(){
MateRRConfig * Widget::makeCloneSetup() {
+ ukcciface->call("setScreenMode", "copy");
+
MateRRConfig * current;
MateRROutputInfo ** outputs;
@@ -496,6 +505,8 @@ MateRRConfig * Widget::makeCloneSetup() {
MateRRConfig * Widget::makePrimarySetup(){
+ ukcciface->call("setScreenMode", "first");
+
char * firstName;
/* Turn on the first screen, disable everything else */
@@ -532,6 +543,7 @@ MateRRConfig * Widget::makePrimarySetup(){
}
MateRRConfig * Widget::makeOtherSetup(){
+ ukcciface->call("setScreenMode", "second");
char * firstName;
@@ -568,6 +580,8 @@ MateRRConfig * Widget::makeOtherSetup(){
}
MateRRConfig * Widget::makeXineramaSetup(){
+
+ ukcciface->call("setScreenMode", "expand");
/* Turn on everything that has a preferred mode, and position it from left to right */
MateRRConfig * current = mate_rr_config_new_current(kScreen, NULL);
diff --git a/kds/widget.h b/kds/widget.h
index 8947a16..e033365 100644
--- a/kds/widget.h
+++ b/kds/widget.h
@@ -36,6 +36,8 @@ extern "C" {
#include <gtk/gtk.h>
}
+class QDBusInterface;
+
namespace Ui {
class Widget;
@@ -66,6 +68,8 @@ public:
void initCurrentStatus(int id);
void setCurrentFirstOutputTip();
+ QDBusInterface * ukcciface;
+
private:
Ui::Widget *ui;
QButtonGroup * btnsGroup;
--
2.33.0

View File

@ -0,0 +1,291 @@
From 677d21aeb763366d7e6d63015106715da8e47cd5 Mon Sep 17 00:00:00 2001
From: peijiankang <peijiankang@kylinos.cn>
Date: Thu, 14 Jul 2022 14:23:52 +0800
Subject: [PATCH] Fix the display error of flight mode icon
---
conf/org.ukui.kds.gschema.xml | 12 ++-
registerdbus/classrealize.cpp | 183 +++++++++++++++++++++++++++++++++-
registerdbus/classrealize.h | 4 +
3 files changed, 197 insertions(+), 2 deletions(-)
diff --git a/conf/org.ukui.kds.gschema.xml b/conf/org.ukui.kds.gschema.xml
index fc89bc2..89610e8 100644
--- a/conf/org.ukui.kds.gschema.xml
+++ b/conf/org.ukui.kds.gschema.xml
@@ -9,6 +9,16 @@
<default>true</default>
<summary>microphone enable or not</summary>
<description>current microphone enable or not</description>
- </key>
+ </key>
+ <key type="b" name="airplanemode">
+ <default>false</default>
+ <summary>microphone enable or not</summary>
+ <description>current microphone enable or not</description>
+ </key>
+ <key type="as" name="beforeairplanemode">
+ <default>['0']</default>
+ <summary>microphone enable or not</summary>
+ <description>current microphone enable or not</description>
+ </key>
</schema>
</schemalist>
diff --git a/registerdbus/classrealize.cpp b/registerdbus/classrealize.cpp
index 82f8f22..9133aba 100755
--- a/registerdbus/classrealize.cpp
+++ b/registerdbus/classrealize.cpp
@@ -33,6 +33,11 @@ extern "C" {
#define RFKILL_EVENT_SIZE_V1 8
+#define VIRTUAL_PATH "/sys/devices/virtual/ieee80211"
+
+const char * getRFkillType(__u32 idx);
+const char * getRFkillName(__u32 idx);
+
struct rfkill_event {
__u32 idx;
__u8 type;
@@ -233,6 +238,36 @@ QString ClassRealize::toggleCameraDevice(QString businfo){
}
}
+bool ClassRealize::isVirtualWlan(QString dp){
+ QDir dir(VIRTUAL_PATH);
+ if (!dir.exists()){
+ return false;
+ }
+
+ dir.setFilter(QDir::Dirs);
+ dir.setSorting(QDir::Name);
+
+ int count = dir.count();
+ if (count <= 0){
+ return false;
+ }
+
+ QFileInfoList fileinfoList = dir.entryInfoList();
+
+ for(QFileInfo fileinfo : fileinfoList){
+ if (fileinfo.fileName() == "." || fileinfo.fileName() == ".."){
+ continue;
+ }
+
+ if (QString::compare(fileinfo.fileName(), dp) == 0){
+ return true;
+ }
+ }
+
+ return false;
+
+}
+
int ClassRealize::getCurrentWlanMode(){
struct rfkill_event event;
ssize_t len;
@@ -271,6 +306,10 @@ int ClassRealize::getCurrentWlanMode(){
if (event.type != RFKILL_TYPE_WLAN)
continue;
+ if (isVirtualWlan(QString(getRFkillName(event.idx)))){
+ continue;
+ }
+
status.append(event.soft ? 1 : 0);
}
@@ -418,6 +457,94 @@ QString ClassRealize::toggleBluetoothMode(bool enable){
return block ? QString("blocked") : QString("unblocked");
}
+QList<int> ClassRealize::getStatusBeforeFlightModeEnable(){
+
+ QList<int> re;
+
+ struct rfkill_event event;
+ ssize_t len;
+ int fd;
+ int bls = 0, unbls = 0;
+
+ QList<int> status;
+
+ fd = open("/dev/rfkill", O_RDONLY);
+ if (fd < 0) {
+ qCritical("Can't open RFKILL control device");
+ return re;
+ }
+
+ if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) {
+ qCritical("Can't set RFKILL control device to non-blocking");
+ close(fd);
+ return re;
+ }
+
+ while (1) {
+ len = read(fd, &event, sizeof(event));
+
+ if (len < 0) {
+ if (errno == EAGAIN)
+ break;
+ qWarning("Reading of RFKILL events failed");
+ break;
+ }
+
+ if (len != RFKILL_EVENT_SIZE_V1) {
+ qWarning("Wrong size of RFKILL event\n");
+ continue;
+ }
+
+ if (isVirtualWlan(QString(getRFkillName(event.idx)))){
+ continue;
+ }
+
+// printf("%u: %u\n", event.idx, event.soft);
+// status.append(event.soft ? 1 : 0);
+ if (!event.soft && !re.contains(event.type)){
+ re.append(event.type);
+ }
+
+ }
+
+ close(fd);
+
+ return re;
+}
+
+QString ClassRealize::setSingleFlightMode(int type){
+
+ struct rfkill_event event;
+ int fd;
+ ssize_t len;
+
+ __u8 block = 0;
+
+ fd = open("/dev/rfkill", O_RDWR);
+ if (fd < 0) {
+ return QString("Can't open RFKILL control device");
+ }
+
+ memset(&event, 0, sizeof(event));
+
+ event.op= RFKILL_OP_CHANGE_ALL;
+
+ /* RFKILL_TYPE_ALL = 0 */
+ event.type = type;
+
+ event.soft = block;
+
+ len = write(fd, &event, sizeof(event));
+
+ if (len < 0){
+ return QString("Failed to change RFKILL state");
+ }
+
+ close(fd);
+ return QString();
+}
+
+
int ClassRealize::getCurrentFlightMode(){
struct rfkill_event event;
@@ -454,6 +581,10 @@ int ClassRealize::getCurrentFlightMode(){
continue;
}
+ if (isVirtualWlan(QString(getRFkillName(event.idx)))){
+ continue;
+ }
+
// printf("%u: %u\n", event.idx, event.soft);
status.append(event.soft ? 1 : 0);
@@ -509,7 +640,7 @@ QString ClassRealize::toggleFlightMode(bool enable){
}
close(fd);
- return block ? QString("blocked") : QString("unblocked");
+ return QString();
}
int ClassRealize::setCameraKeyboardLight(bool lightup){
@@ -543,3 +674,53 @@ int ClassRealize::setAirplaneModeKeyboardLight(bool lightup){
return 1;
}
+
+const char * getRFkillName(__u32 idx){
+
+ static char name[128] = {};
+ char *pos, filename[64];
+ int fd;
+
+ snprintf(filename, sizeof(filename) - 1,
+ "/sys/class/rfkill/rfkill%u/name", idx);
+
+ fd = open(filename, O_RDONLY);
+ if (fd < 0)
+ return NULL;
+
+ memset(name, 0, sizeof(name));
+ read(fd, name, sizeof(name) - 1);
+
+ pos = strchr(name, '\n');
+ if (pos)
+ *pos = '\0';
+
+ close(fd);
+
+ return name;
+}
+
+const char * getRFkillType(__u32 idx){
+
+ static char name[128] = {};
+ char *pos, filename[64];
+ int fd;
+
+ snprintf(filename, sizeof(filename) - 1,
+ "/sys/class/rfkill/rfkill%u/type", idx);
+
+ fd = open(filename, O_RDONLY);
+ if (fd < 0)
+ return NULL;
+
+ memset(name, 0, sizeof(name));
+ read(fd, name, sizeof(name) - 1);
+
+ pos = strchr(name, '\n');
+ if (pos)
+ *pos = '\0';
+
+ close(fd);
+
+ return name;
+}
diff --git a/registerdbus/classrealize.h b/registerdbus/classrealize.h
index 32efd06..cbb4ee3 100644
--- a/registerdbus/classrealize.h
+++ b/registerdbus/classrealize.h
@@ -35,6 +35,8 @@ public:
explicit ClassRealize();
~ClassRealize();
+public:
+ bool isVirtualWlan(QString dp);
signals:
Q_SCRIPTABLE void debug0(QString);
@@ -66,6 +68,8 @@ public slots:
Q_SCRIPTABLE QString toggleCameraDevice(QString businfo);
Q_SCRIPTABLE int setCameraKeyboardLight(bool lightup);
Q_SCRIPTABLE int getCurrentFlightMode();
+ Q_SCRIPTABLE QList<int> getStatusBeforeFlightModeEnable();
+ Q_SCRIPTABLE QString setSingleFlightMode(int type);
Q_SCRIPTABLE QString toggleFlightMode(bool enable);
Q_SCRIPTABLE int setAirplaneModeKeyboardLight(bool lightup);
Q_SCRIPTABLE int getCurrentWlanMode();
--
2.33.0

View File

@ -1,23 +1,26 @@
%define debug_package %{nil}
Name: kylin-display-switch
Version: 3.0.13
Release: 1
Release: 5
Summary: Gui tool for display switching
License: GPL-3
URL: https://github.com/ukui/kylin-display-switch
Source0: %{name}-%{version}.tar.gz
BuildRequires: python3-rpm-macros
BuildRequires: python-rpm-macros
BuildRequires: qt5-qtbase-devel
BuildRequires: libxcb-devel
BuildRequires: xcb-util-devel
BuildRequires: libX11-devel
BuildRequires: libXtst-devel
BuildRequires: gsettings-qt-devel
BuildRequires: mate-desktop-devel
BuildRequires: kf5-kwindowsystem-devel
BuildRequires: libkscreen-qt5-devel
BuildRequires: libxkbcommon-devel
Patch1: 0001-Touch-hotkeys-touch-pad-without-customized-driver.patch
Patch2: 0002-Set-4-modes-to-synchronize-the-current-state.patch
Patch3: 0003-Fix-the-display-error-of-flight-mode-icon.patch
BuildRequires: python3-rpm-macros
BuildRequires: python-rpm-macros
BuildRequires: qt5-qtbase-devel
BuildRequires: libxcb-devel
BuildRequires: xcb-util-devel
BuildRequires: libX11-devel
BuildRequires: libXtst-devel
BuildRequires: gsettings-qt-devel
BuildRequires: mate-desktop-devel
BuildRequires: kf5-kwindowsystem-devel
BuildRequires: libkscreen-qt5-devel
BuildRequires: libxkbcommon-devel
%description
@ -28,8 +31,11 @@ BuildRequires: libxkbcommon-devel
buttons are clicked, corresponding reminder will popper up.
%prep
%setup -q
%patch1 -p1
%patch2 -p1
%patch3 -p1
%build
%{qmake_qt5} %{_qt5_qmake_flags} CONFIG+=enable-by-default kylin-display-switch.pro
%{make_build}
@ -58,13 +64,22 @@ make INSTALL_ROOT=%{buildroot} install
%{_datadir}/glib-2.0/schemas/org.ukui.kds.gschema.xml
%changelog
* Mon Feb 06 2023 peijiankang <peijiankang@kylinos.cn> - 3.0.13-5
- add build debuginfo and debugsource
* Thu Jul 14 2022 peijiankang <peijiankang@kylinos.cn> - 3.0.13-4
- 修复多次开关飞行模式热键,飞行模式图标显示错误
* Wed Jul 13 2022 peijiankang <peijiankang@kylinos.cn> - 3.0.13-3
- 设置4种模式前调用控制面板的dbus以便告知控制面板同步当前状态
* Tue Jul 12 2022 peijiankang <peijiankang@kylinos.cn> - 3.0.13-2
- Touch hotkeys touch pad without customized driver
* Wed Mar 02 2022 tanyulong <tanyulong@kylinos.cn> - 3.0.13-1
- update upstream version 3.0.13
* Thu Feb 10 2022 tanyulong <tanyulong@kylinos.cn> - 2.0.13-3
- rebuild
* Wed Jun 8 2021 douyan <douyan@kylinos.cn> - 2.0.13-2
* Tue Jun 8 2021 douyan <douyan@kylinos.cn> - 2.0.13-2
- fix issue: enable kylin-display-switch.service failed
* Wen Nov 11 2020 douyan <douyan@kylinos.cn> - 2.0.13-1

View File

@ -0,0 +1,4 @@
version_control: github
src_repo: ukui/kylin-display-switch.git
tag_prefix: "v"
separator: "."