From 80adc3c2ca1c90e974d5d1a15e12eb426f39cd04 Mon Sep 17 00:00:00 2001 From: chenbin Date: Thu, 9 Dec 2021 18:46:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0wayland=E4=B8=8B?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=A0=8F=E9=BC=A0=E6=A0=87=E6=82=AC=E6=B5=AE?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E7=AA=97=E5=8F=A3=E5=85=B3=E9=97=AD=E7=9A=84?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 适配wayland下关闭任务栏鼠标悬浮应用窗口的功能,wayland下调用后端CloseWindow接口 Log: 修复wayland下任务栏鼠标悬浮窗口关闭应用失败的问题 Bug: https://pms.uniontech.com/zentao/bug-view-105849.html Influence: wayland下任务栏鼠标悬浮窗口关闭应用 Change-Id: I4c65e2382e479c4a8a691535c042b9f8eb5a1d42 --- frame/item/components/appsnapshot.cpp | 42 +++++++++++++++------------ 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/frame/item/components/appsnapshot.cpp b/frame/item/components/appsnapshot.cpp index 26b2c1e0b..a61322a3d 100644 --- a/frame/item/components/appsnapshot.cpp +++ b/frame/item/components/appsnapshot.cpp @@ -143,26 +143,30 @@ void AppSnapshot::setTitleVisible(bool bVisible) void AppSnapshot::closeWindow() const { - const auto display = Utils::IS_WAYLAND_DISPLAY ? XOpenDisplay(nullptr) : QX11Info::display(); - if (!display) { - qWarning() << "Error: get display failed!"; - return; + if (Utils::IS_WAYLAND_DISPLAY) { + m_dockDaemonInter->CloseWindow(static_cast(m_wid)); + } else { + const auto display = QX11Info::display(); + if (!display) { + qWarning() << "Error: get display failed!"; + return; + } + + XEvent e; + + memset(&e, 0, sizeof(e)); + e.xclient.type = ClientMessage; + e.xclient.window = m_wid; + e.xclient.message_type = XInternAtom(display, "WM_PROTOCOLS", true); + e.xclient.format = 32; + e.xclient.data.l[0] = XInternAtom(display, "WM_DELETE_WINDOW", false); + e.xclient.data.l[1] = CurrentTime; + + Q_EMIT requestCloseAppSnapshot(); + + XSendEvent(display, m_wid, false, NoEventMask, &e); + XFlush(display); } - - XEvent e; - - memset(&e, 0, sizeof(e)); - e.xclient.type = ClientMessage; - e.xclient.window = m_wid; - e.xclient.message_type = XInternAtom(display, "WM_PROTOCOLS", true); - e.xclient.format = 32; - e.xclient.data.l[0] = XInternAtom(display, "WM_DELETE_WINDOW", false); - e.xclient.data.l[1] = CurrentTime; - - Q_EMIT requestCloseAppSnapshot(); - - XSendEvent(display, m_wid, false, NoEventMask, &e); - XFlush(display); } void AppSnapshot::compositeChanged() const