parent
3179e82699
commit
5b6e2038fa
|
@ -37,7 +37,8 @@ Build-Depends: debhelper-compat (= 12),
|
|||
libkysdk-systime-dev,
|
||||
liblightdm-qt5-3-dev,
|
||||
libsystemd-dev,
|
||||
libssl-dev
|
||||
libssl-dev,
|
||||
libxrandr-dev
|
||||
Standards-Version: 4.5.0
|
||||
Rules-Requires-Root: no
|
||||
Homepage: https://www.github.com/ukui/ukui-screensaver
|
||||
|
|
|
@ -0,0 +1,296 @@
|
|||
From: =?utf-8?b?5p2o5pWP?= <yangmin@kylinos.cn>
|
||||
Date: Wed, 21 Feb 2024 06:57:15 +0000
|
||||
Subject: =?utf-8?q?!71_fixbug_Merge_pull_request_!71_from_=E6=9D=A8?=
|
||||
=?utf-8?q?=E6=95=8F/openkylin/nile?=
|
||||
|
||||
---
|
||||
src/CMakeLists.txt | 3 ++
|
||||
src/widgets/fullbackgroundwidget.cpp | 75 ++++++++++++++++++++++++++++++++++--
|
||||
src/widgets/fullbackgroundwidget.h | 11 +++++-
|
||||
src/widgets/loginnotifyinterface.h | 54 ++++++++++++++++++++++++++
|
||||
src/widgets/loginplugininterface.h | 3 +-
|
||||
5 files changed, 139 insertions(+), 7 deletions(-)
|
||||
create mode 100644 src/widgets/loginnotifyinterface.h
|
||||
|
||||
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
||||
index 4e14324..f0d38c8 100644
|
||||
--- a/src/CMakeLists.txt
|
||||
+++ b/src/CMakeLists.txt
|
||||
@@ -17,6 +17,7 @@ pkg_check_modules(kylin-nm-base REQUIRED kylin-nm-base)
|
||||
pkg_check_modules(IMLIB2 REQUIRED imlib2)
|
||||
pkg_check_modules(LIGHTDM-QT5-3 REQUIRED liblightdm-qt5-3)
|
||||
pkg_check_modules(LIBSYSTEMD REQUIRED libsystemd)
|
||||
+pkg_check_modules(LIBXRANDR REQUIRED xrandr)
|
||||
|
||||
# 查找pam动态库全路径并缓存到PAM_LIBRARIES变量
|
||||
find_library(PAM_LIBRARIES pam)
|
||||
@@ -62,6 +63,7 @@ include_directories(
|
||||
${OpenCV_INCLUDE_DIRS}
|
||||
${LIGHTDM-QT5-3_INCLUDE_DIRS}
|
||||
${LIBSYSTEMD_INCLUDE_DIRS}
|
||||
+ ${LIBXRANDR_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
set(EXTRA_LIBS
|
||||
@@ -74,6 +76,7 @@ set(EXTRA_LIBS
|
||||
${GLIB2_LIBRARIES}
|
||||
${MMIX_LIBRARIES}
|
||||
${IMLIB2_LIBRARIES}
|
||||
+ ${LIBXRANDR_LIBRARIES}
|
||||
-lrt
|
||||
-lpthread
|
||||
-llibnm-icon-kylin
|
||||
diff --git a/src/widgets/fullbackgroundwidget.cpp b/src/widgets/fullbackgroundwidget.cpp
|
||||
index 98ddbe7..39e768a 100644
|
||||
--- a/src/widgets/fullbackgroundwidget.cpp
|
||||
+++ b/src/widgets/fullbackgroundwidget.cpp
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "grab-x11.h"
|
||||
#include <unistd.h>
|
||||
#include <X11/extensions/XTest.h>
|
||||
+#include <X11/extensions/Xrandr.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
@@ -94,7 +95,7 @@ void FullBackgroundWidget::initUI()
|
||||
if (!m_lockWidget) {
|
||||
m_lockWidget = new LockWidget(m_modelLockDialog, this);
|
||||
connect(m_lockWidget, &LockWidget::authSucceed, this, &FullBackgroundWidget::onAuthSucceed);
|
||||
- onCursorMoved(QCursor::pos());
|
||||
+ moveToPrimaryScreen();
|
||||
}
|
||||
|
||||
if(m_modelLockDialog->getAgreementWindowShowLoginPrompt() && (/*IsStartupMode() || */(qgetenv("USER") == "lightdm"))){
|
||||
@@ -130,6 +131,15 @@ void FullBackgroundWidget::initUI()
|
||||
setWindowFlags(Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
|
||||
KWindowSystem::setType(this->winId(), NET::ScreenLock);
|
||||
|
||||
+ // 登录模式下监听屏幕插拔
|
||||
+ if (isGreeterMode()) {
|
||||
+ XRRQueryExtension(QX11Info::display(), &m_RREventBase, &m_RRErrorBase);
|
||||
+ XRRSelectInput(QX11Info::display(), QX11Info::appRootWindow(), RRScreenChangeNotifyMask);
|
||||
+ QtConcurrent::run([=](){
|
||||
+ RRScreenChangeEvent(true);
|
||||
+ });
|
||||
+ }
|
||||
+
|
||||
qApp->installNativeEventFilter(this);
|
||||
installEventFilter(this);
|
||||
}
|
||||
@@ -395,7 +405,7 @@ void FullBackgroundWidget::onDesktopResized()
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
setGeometry(desktop->geometry());
|
||||
if(m_lockWidget) {
|
||||
- this->onCursorMoved(QCursor::pos());
|
||||
+ moveToPrimaryScreen();
|
||||
m_lockWidget->reloadRootBackground();
|
||||
}
|
||||
update();
|
||||
@@ -492,7 +502,7 @@ QList<quint64> FullBackgroundWidget::GetSubWndIds()
|
||||
return m_listWndIds;
|
||||
}
|
||||
|
||||
-void FullBackgroundWidget::onCursorMoved(const QPoint &pos)
|
||||
+void FullBackgroundWidget::moveToPrimaryScreen()
|
||||
{
|
||||
if(!m_lockWidget) {
|
||||
return;
|
||||
@@ -660,7 +670,11 @@ bool FullBackgroundWidget::nativeEventFilter(const QByteArray &eventType, void *
|
||||
xcb_key_release_event_t *xc = reinterpret_cast<xcb_key_release_event_t*>(event);
|
||||
qDebug()<<"---------------------XCB_KEY_RELEASE:"<<xc->detail;
|
||||
onGlobalKeyRelease(xc->detail);
|
||||
- }
|
||||
+ } else if(responseType == m_RREventBase + RRScreenChangeNotify){
|
||||
+ if (isGreeterMode()) {
|
||||
+ RRScreenChangeEvent(false);
|
||||
+ }
|
||||
+ }
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -982,3 +996,56 @@ QPixmap* FullBackgroundWidget::getBackground(const QString &path, const QRect &r
|
||||
}
|
||||
return m_allBackgroundsDataMap[key];
|
||||
}
|
||||
+
|
||||
+void FullBackgroundWidget::RRScreenChangeEvent(bool isFirst)
|
||||
+{
|
||||
+ XRRScreenResources *screen;
|
||||
+ screen = XRRGetScreenResources(QX11Info::display(), QX11Info::appRootWindow());
|
||||
+ XRROutputInfo *info;
|
||||
+ QList<QString> listMonitors;
|
||||
+
|
||||
+ for (int i = 0; i < screen->noutput; i++) {
|
||||
+ info = XRRGetOutputInfo(QX11Info::display(), screen, screen->outputs[i]);
|
||||
+ if (info->connection == RR_Connected) {
|
||||
+ listMonitors.push_back(info->name);
|
||||
+ }
|
||||
+ XRRFreeOutputInfo(info);
|
||||
+ }
|
||||
+
|
||||
+ qDebug()<<"monitors = "<<listMonitors;
|
||||
+ if (isFirst && DisplayService::instance()->isSaveParamInUsed()) {
|
||||
+ m_listMonitors = listMonitors;
|
||||
+ } else {
|
||||
+ onScreensChanged(listMonitors);
|
||||
+ }
|
||||
+ XRRFreeScreenResources(screen);
|
||||
+}
|
||||
+
|
||||
+void FullBackgroundWidget::onScreensChanged(QList<QString> listMonitors)
|
||||
+{
|
||||
+ qDebug()<<"newList = "<<listMonitors<<" listMonitors = "<<m_listMonitors << DisplayService::instance()->isJJW7200();
|
||||
+ if (DisplayService::instance()->isJJW7200() == 0 && m_listMonitors.size() == listMonitors.size()) {
|
||||
+ bool isAllFound = true;
|
||||
+ for (auto monitor : listMonitors) {
|
||||
+ if (!m_listMonitors.contains(monitor)) {
|
||||
+ isAllFound = false;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ if (isAllFound) {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ m_listMonitors = listMonitors;
|
||||
+ if(m_listMonitors.size() < 2) {
|
||||
+ //默认设置显示最大分辨率
|
||||
+ DisplayService::instance()->setOneDisplayMode();
|
||||
+ } else {
|
||||
+ int mode = Configuration::instance()->getValue("display-mode").toInt();
|
||||
+ DisplayService::instance()->switchDisplayMode((DisplayMode)mode);
|
||||
+ }
|
||||
+ //在调用xrandr打开显示器以后,不能马上设置窗口大小,会设置不正确的
|
||||
+ //分辨率,延时1000ms正常。
|
||||
+ QTimer::singleShot(1000, this, SLOT(onDesktopResized()));
|
||||
+}
|
||||
diff --git a/src/widgets/fullbackgroundwidget.h b/src/widgets/fullbackgroundwidget.h
|
||||
index 4dad34d..2ec9609 100644
|
||||
--- a/src/widgets/fullbackgroundwidget.h
|
||||
+++ b/src/widgets/fullbackgroundwidget.h
|
||||
@@ -67,7 +67,6 @@ public:
|
||||
inline bool IsStartupMode() { return m_isStartupMode; }
|
||||
|
||||
public Q_SLOTS:
|
||||
- void onCursorMoved(const QPoint &pos);
|
||||
void onShowBlankScreensaver(int nDelay = 0, bool isHasLock = true);
|
||||
void onShowLock(bool isStartup);
|
||||
void onShowSessionIdle();
|
||||
@@ -106,6 +105,7 @@ private:
|
||||
QString getWindowNameFromWid(WId window);
|
||||
QString getFocusWindowName();
|
||||
void tryGrabKeyboard();
|
||||
+ void moveToPrimaryScreen();
|
||||
|
||||
void initCurrentBackground();
|
||||
QString getDefaultBackgroundPath();
|
||||
@@ -117,7 +117,7 @@ private:
|
||||
void startTransition();
|
||||
void stopTransition();
|
||||
void drawBackground(QPixmap * backgroundBack, QPixmap * backgroundFront,
|
||||
- const QRect &rect, float alpha);
|
||||
+ const QRect &rect, float alpha = 1.0);
|
||||
QPixmap* getBackground(const QString &path, const QRect &rect);
|
||||
|
||||
void delayLockScreen();
|
||||
@@ -129,6 +129,10 @@ private Q_SLOTS:
|
||||
void onGlobalKeyRelease(const quint8 &key);
|
||||
void onGlobalButtonDrag(int xPos, int yPos);
|
||||
void onGlobalButtonPressed(int xPos, int yPos);
|
||||
+
|
||||
+ void RRScreenChangeEvent(bool isFirst);
|
||||
+ void onScreensChanged(QList<QString> listMonitors);
|
||||
+
|
||||
private:
|
||||
LockDialogModel *m_modelLockDialog = nullptr;
|
||||
bool m_isStartupMode = false;
|
||||
@@ -150,6 +154,9 @@ private:
|
||||
int isBlank;
|
||||
|
||||
QTimer *m_timerLock = nullptr;
|
||||
+ int m_RREventBase;
|
||||
+ int m_RRErrorBase;
|
||||
+ QList<QString> m_listMonitors;
|
||||
};
|
||||
|
||||
#endif // FULLBACKGROUNDWIDGET_H
|
||||
diff --git a/src/widgets/loginnotifyinterface.h b/src/widgets/loginnotifyinterface.h
|
||||
new file mode 100644
|
||||
index 0000000..257b379
|
||||
--- /dev/null
|
||||
+++ b/src/widgets/loginnotifyinterface.h
|
||||
@@ -0,0 +1,54 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2023 KylinSoft Co., Ltd.
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License as published by
|
||||
+ * the Free Software Foundation; either version 3, or (at your option)
|
||||
+ * any later version.
|
||||
+ *
|
||||
+ * This program is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+ * GNU General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU General Public License
|
||||
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
+ *
|
||||
+**/
|
||||
+#ifndef LOGIN_NOTIFY_INTERFACE_H
|
||||
+#define LOGIN_NOTIFY_INTERFACE_H
|
||||
+
|
||||
+#include "loginplugininterface.h"
|
||||
+
|
||||
+/**
|
||||
+ * @brief 通知类窗口接口
|
||||
+ *
|
||||
+ */
|
||||
+class LoginNotifyInterface : public LoginPluginInterface
|
||||
+{
|
||||
+public:
|
||||
+ /**
|
||||
+ * @brief 构造函数
|
||||
+ *
|
||||
+ */
|
||||
+ LoginNotifyInterface(){}
|
||||
+
|
||||
+ /**
|
||||
+ * @brief 析构函数
|
||||
+ *
|
||||
+ */
|
||||
+ virtual ~LoginNotifyInterface(){}
|
||||
+
|
||||
+ /**
|
||||
+ * @brief 获取插件类型
|
||||
+ * @return 插件类型
|
||||
+ */
|
||||
+ int getPluginType() { return MODULETYPE_NOTIFY; }
|
||||
+
|
||||
+};
|
||||
+
|
||||
+#define LoginNotifyInterfaceIID "org.ukui.LoginNotifyInterface"
|
||||
+
|
||||
+Q_DECLARE_INTERFACE(LoginNotifyInterface, LoginNotifyInterfaceIID)
|
||||
+
|
||||
+#endif // LOGIN_NOTIFY_INTERFACE_H
|
||||
diff --git a/src/widgets/loginplugininterface.h b/src/widgets/loginplugininterface.h
|
||||
index dc3789e..abd88b7 100644
|
||||
--- a/src/widgets/loginplugininterface.h
|
||||
+++ b/src/widgets/loginplugininterface.h
|
||||
@@ -32,12 +32,13 @@ class LoginPluginInterface
|
||||
{
|
||||
public:
|
||||
/**
|
||||
- * @brief 插件模块类型枚举:认证、工具
|
||||
+ * @brief 插件模块类型枚举:认证、工具、通知
|
||||
*
|
||||
*/
|
||||
enum ModuleType{
|
||||
MODULETYPE_AUTH,
|
||||
MODULETYPE_TOOL,
|
||||
+ MODULETYPE_NOTIFY,
|
||||
MODULETYPE_MAX
|
||||
};
|
||||
/**
|
|
@ -15,3 +15,4 @@
|
|||
0015-65-fixbug.patch
|
||||
0016-69-fixbug.patch
|
||||
0017-68.patch
|
||||
0018-71-fixbug.patch
|
||||
|
|
Loading…
Reference in New Issue