9 Star 6 Fork 15

src-openEuler/deepin-system-monitor

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0003-feat-add-build-option-to-disable-wayland-support.patch 4.71 KB
一键复制 编辑 原始数据 按行查看 历史
Venland 提交于 2023-07-24 17:48 . upgrade to version 5.9.31
From 982cf2a7b7a60843f17b103ecafa150dd4f557da Mon Sep 17 00:00:00 2001
From: leeffo <liweiganga@uniontech.com>
Date: Tue, 25 Jul 2023 11:33:00 +0800
Subject: [PATCH] feat: add build option to disable wayland support
---
.../gui/xwin_kill_preview_widget.cpp | 26 +++++++++++++++----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/deepin-system-monitor-main/gui/xwin_kill_preview_widget.cpp b/deepin-system-monitor-main/gui/xwin_kill_preview_widget.cpp
index 077aa1e..26ec724 100644
--- a/deepin-system-monitor-main/gui/xwin_kill_preview_widget.cpp
+++ b/deepin-system-monitor-main/gui/xwin_kill_preview_widget.cpp
@@ -37,12 +37,14 @@ XWinKillPreviewWidget::XWinKillPreviewWidget(QWidget *parent) : QWidget(parent)
{
// new window manager instance
m_wminfo = new WMInfo();
-//不再使用CMakeList开关宏的方式,改用全局变量运行时控制
-//WaylandCentered定义在common/common.h中,在main函数开头进行初始化判断
+// 如果在编译时选择支持Wayland,运行时会由全局变量WaylandCentered控制
+// WaylandCentered定义在common/common.h中,在main函数开头进行初始化判断
+#ifdef USE_DEEPIN_WAYLAND
if (WaylandCentered) {
m_connectionThread = new QThread(this);
m_connectionThreadObject = new ConnectionThread();
}
+#endif // USE_DEEPIN_WAYLAND
// init ui components & connections
initUI();
@@ -66,11 +68,13 @@ XWinKillPreviewWidget::~XWinKillPreviewWidget()
releaseMouse();
releaseKeyboard();
delete m_wminfo;
+#ifdef USE_DEEPIN_WAYLAND
if (WaylandCentered) {
m_connectionThread->quit();
m_connectionThread->wait();
m_connectionThreadObject->deleteLater();
}
+#endif // USE_DEEPIN_WAYLAND
}
// mouse press event
@@ -82,6 +86,7 @@ void XWinKillPreviewWidget::mousePressEvent(QMouseEvent *event)
}
// get the list of windows under cursor in stacked order when mouse pressed
auto pos = QCursor::pos();
+#ifdef USE_DEEPIN_WAYLAND
if (WaylandCentered) {
double ratio = QGuiApplication::primaryScreen()->devicePixelRatio(); // 获得当前的缩放比例
QRect screenRect;
@@ -119,7 +124,9 @@ void XWinKillPreviewWidget::mousePressEvent(QMouseEvent *event)
break;
}
}
- } else {
+ }
+#endif // USE_DEEPIN_WAYLAND
+ if (!WaylandCentered) {
double ratio = QGuiApplication::primaryScreen()->devicePixelRatio(); // 获得当前的缩放比例
QRect screenRect;
for (auto screen : QApplication::screens()) {
@@ -165,6 +172,7 @@ void XWinKillPreviewWidget::mousePressEvent(QMouseEvent *event)
// mouse move event handler
void XWinKillPreviewWidget::mouseMoveEvent(QMouseEvent *)
{
+#ifdef USE_DEEPIN_WAYLAND
if (WaylandCentered) {
double ratio = QGuiApplication::primaryScreen()->devicePixelRatio(); // 获得当前的缩放比例
auto pos = QCursor::pos();
@@ -236,7 +244,9 @@ void XWinKillPreviewWidget::mouseMoveEvent(QMouseEvent *)
bg->clearSelection();
emit cursorUpdated(m_defaultCursor);
}
- } else {
+ }
+#endif // USE_DEEPIN_WAYLAND
+ if (!WaylandCentered) {
double ratio = QGuiApplication::primaryScreen()->devicePixelRatio(); // 获得当前的缩放比例
auto pos = QCursor::pos();
QRect screenRect;
@@ -351,9 +361,10 @@ void XWinKillPreviewWidget::initUI()
// snapshot current scree
auto pixmap = screen->grabWindow(m_wminfo->getRootWindow());
+#ifdef USE_DEEPIN_WAYLAND
if (WaylandCentered)
pixmap = screen->grabWindow(m_windowStates.end()->windowId);
-
+#endif // USE_DEEPIN_WAYLAND
pixmap = pixmap.copy(geom.x(), geom.y(), static_cast<int>(geom.width() * devicePixelRatioF()), static_cast<int>(geom.height() * devicePixelRatioF()));
// create preview background widget for each screen
auto *background = new XWinKillPreviewBackgroundWidget(pixmap, this);
@@ -378,6 +389,7 @@ void XWinKillPreviewWidget::initUI()
// wayland协议下建立连接
void XWinKillPreviewWidget::initConnections()
{
+#ifdef USE_DEEPIN_WAYLAND
if (WaylandCentered) {
connect(m_connectionThreadObject, &ConnectionThread::connected, this,
[this] {
@@ -394,7 +406,10 @@ void XWinKillPreviewWidget::initConnections()
m_connectionThreadObject->initConnection();
}
+#endif // USE_DEEPIN_WAYLAND
}
+
+#ifdef USE_DEEPIN_WAYLAND
//打印当前窗口信息接口
void XWinKillPreviewWidget::print_window_states(const QVector<ClientManagement::WindowState> &m_windowStates)
{
@@ -447,3 +462,4 @@ void XWinKillPreviewWidget::setupRegistry(Registry *registry)
}
}
+#endif // USE_DEEPIN_WAYLAND
--
2.20.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/deepin-system-monitor.git
git@gitee.com:src-openeuler/deepin-system-monitor.git
src-openeuler
deepin-system-monitor
deepin-system-monitor
master

搜索帮助