From eb675096ee48e274384234865b210cd2fbc5582b Mon Sep 17 00:00:00 2001 From: liuyuanpeng Date: Thu, 1 Jun 2023 10:28:05 +0800 Subject: [PATCH] fix(wayland): Fixed 990 machine crashing when running under the machine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description:修复990机器下运行会崩溃的问题 Log: 无 --- Common/CMakeLists.txt | 2 +- Common/plasma-shell-manager.cpp | 4 ++++ VirtualKeyboard/src/letterswidget.cpp | 2 +- src/fullbackgroundwidget.cpp | 4 ++-- src/ukui-screensaver-dialog.cpp | 8 +++----- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Common/CMakeLists.txt b/Common/CMakeLists.txt index a53f577..1f4d3b7 100644 --- a/Common/CMakeLists.txt +++ b/Common/CMakeLists.txt @@ -28,4 +28,4 @@ set(Common_SRC ) add_library(Common STATIC ${Common_SRC}) -target_link_libraries(Common Qt5::Core Qt5::DBus Qt5::Widgets ${GIOUNIX2_LIBRARIES} ${KF5Wayland_LIBRARIES} -lKF5WaylandClient -lKF5WaylandServer KF5::WindowSystem) +target_link_libraries(Common Qt5::Core Qt5::DBus Qt5::Widgets Qt5::X11Extras ${GIOUNIX2_LIBRARIES} ${KF5Wayland_LIBRARIES} -lKF5WaylandClient -lKF5WaylandServer KF5::WindowSystem) diff --git a/Common/plasma-shell-manager.cpp b/Common/plasma-shell-manager.cpp index eeea7e4..e8336b4 100644 --- a/Common/plasma-shell-manager.cpp +++ b/Common/plasma-shell-manager.cpp @@ -19,6 +19,7 @@ #include "plasma-shell-manager.h" #include +#include #include #include @@ -31,6 +32,9 @@ static PlasmaShellManager* global_instance = nullptr; PlasmaShellManager *PlasmaShellManager::getInstance() { + if(QString(qgetenv("XDG_SESSION_TYPE")) != "wayland" || QX11Info::isPlatformX11()){ + return nullptr; + } if (!global_instance) { global_instance = new PlasmaShellManager; diff --git a/VirtualKeyboard/src/letterswidget.cpp b/VirtualKeyboard/src/letterswidget.cpp index 102d64b..f93b522 100644 --- a/VirtualKeyboard/src/letterswidget.cpp +++ b/VirtualKeyboard/src/letterswidget.cpp @@ -28,7 +28,7 @@ LettersWidget::LettersWidget(QWidget *parent/* = nullptr*/) this->setAttribute(Qt::WA_TranslucentBackground);//背景透明 initUI(); - if(QString(qgetenv("XDG_SESSION_TYPE")) == "wayland") { + if(QString(qgetenv("XDG_SESSION_TYPE")) == "wayland" && !QX11Info::isPlatformX11()) { isWayland = true; } diff --git a/src/fullbackgroundwidget.cpp b/src/fullbackgroundwidget.cpp index 56e6d51..ae7695d 100644 --- a/src/fullbackgroundwidget.cpp +++ b/src/fullbackgroundwidget.cpp @@ -365,7 +365,7 @@ bool FullBackgroundWidget::eventFilter(QObject *obj, QEvent *event) if(event->type() == QEvent::WindowDeactivate){ QTimer::singleShot(50,this,SLOT(laterActivate())); }else if(event->type() == QEvent::WindowActivate){ - if(QString(qgetenv("XDG_SESSION_TYPE")) == "wayland") { + if(QString(qgetenv("XDG_SESSION_TYPE")) == "wayland" && !QX11Info::isPlatformX11()) { PlasmaShellManager::getInstance()->setAppWindowKeepAbove(true); } @@ -1222,7 +1222,7 @@ void FullBackgroundWidget::onDesktopResized() update(); #endif - if(QString(qgetenv("XDG_SESSION_TYPE")) == "wayland") { + if(QString(qgetenv("XDG_SESSION_TYPE")) == "wayland" && !QX11Info::isPlatformX11() ) { PlasmaShellManager::getInstance()->setPos(this->windowHandle(),QPoint(0,0)); } } diff --git a/src/ukui-screensaver-dialog.cpp b/src/ukui-screensaver-dialog.cpp index ef1a3f7..9443b8a 100644 --- a/src/ukui-screensaver-dialog.cpp +++ b/src/ukui-screensaver-dialog.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include "plasma-shell-manager.h" @@ -253,10 +254,7 @@ int main(int argc, char *argv[]) } #ifndef USE_INTEL - if (QString(qgetenv("XDG_SESSION_TYPE")) == "wayland") - window->show(); - else - window->show(); + window->show(); window->activateWindow(); #endif if(parser.isSet(lockOption)) @@ -300,7 +298,7 @@ int main(int argc, char *argv[]) bool isWayland = false; - if(QString(qgetenv("XDG_SESSION_TYPE")) == "wayland") { + if(QString(qgetenv("XDG_SESSION_TYPE")) == "wayland" && !QX11Info::isPlatformX11()) { isWayland = true; } if (isWayland){