deepin-system-monitor/0003-feat-add-build-option-to-disable-wayland-support.patch
leeffo 1127950f67 upgrade to version 5.9.31
(cherry picked from commit 916d9fb71205a56d9c6de98ffa8772821c8a75ff)
2023-08-15 16:58:05 +08:00

122 lines
4.7 KiB
Diff
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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