Skip to content

Commit 034b761

Browse files
committed
fix: popup can not auto hide on treeland
Qt popup get event from other window, so it's necessary to make dock can get focus. And add a PopupWindow to handle Popup auto hide. log: as title
1 parent d9bb23a commit 034b761

File tree

7 files changed

+75
-5
lines changed

7 files changed

+75
-5
lines changed

frame/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ add_library(dde-shell-frame SHARED
7070
models/kextracolumnsproxymodel.cpp
7171
models/listtotableproxymodel.cpp
7272
quick/dsquickdrag.cpp
73+
popupwindow.h
74+
popupwindow.cpp
7375
ddeshell_qml.qrc
7476
dsutility.cpp
7577
)
@@ -98,6 +100,7 @@ PUBLIC
98100
Qt${QT_VERSION_MAJOR}::Gui
99101
Qt${QT_VERSION_MAJOR}::Quick
100102
PRIVATE
103+
Qt${QT_VERSION_MAJOR}::QuickPrivate
101104
Qt${QT_VERSION_MAJOR}::Concurrent
102105
Qt${QT_VERSION_MAJOR}::GuiPrivate
103106
Qt${QT_VERSION_MAJOR}::WaylandClientPrivate

frame/plugin/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ add_library(dde-shell-plugin SHARED
1212
target_link_libraries(dde-shell-plugin
1313
PUBLIC
1414
dde-shell-frame
15+
PRIVATE
16+
Qt${QT_VERSION_MAJOR}::QuickPrivate
1517
)
1618

1719
string(REPLACE "." "/" URI_PATH ${URI})

frame/plugin/qmlplugin.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
#include "applet.h"
77
#include "appletitem.h"
88
#include "containmentitem.h"
9-
#include "panel.h"
109
#include "dstypes.h"
11-
#include "private/dsqmlglobal_p.h"
12-
#include "quick/dsquickdrag_p.h"
1310
#include "layershell/dlayershellwindow.h"
1411
#include "models/listtotableproxymodel.h"
12+
#include "panel.h"
13+
#include "popupwindow.h"
14+
#include "private/dsqmlglobal_p.h"
15+
#include "quick/dsquickdrag_p.h"
1516

1617
#include <qqml.h>
1718

@@ -45,6 +46,7 @@ void QmlpluginPlugin::registerTypes(const char *uri)
4546
qmlRegisterUncreatableType<DLayerShellWindow>(uri, 1, 0, "DLayerShellWindow","LayerShell Attached");
4647
qmlRegisterUncreatableType<DQuickDrag>(uri, 1, 0, "DQuickDrag","DQuickDrag Attached");
4748
qmlRegisterType<ListToTableProxyModel>(uri, 1, 0, "DListToTableProxyModel");
49+
qmlRegisterType<PopupWindow>(uri, 1, 0, "PopupWindow");
4850

4951
dsRegisterType(uri, 1, 0, "PanelPopup");
5052
dsRegisterType(uri, 1, 0, "PanelToolTip");

frame/popupwindow.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
2+
//
3+
// SPDX-License-Identifier: GPL-3.0-or-later
4+
5+
#include "popupwindow.h"
6+
7+
DS_BEGIN_NAMESPACE
8+
PopupWindow::PopupWindow(QWindow *parent)
9+
: QQuickWindowQmlImpl(parent)
10+
{
11+
}
12+
13+
void PopupWindow::mouseReleaseEvent(QMouseEvent *event)
14+
{
15+
auto rect = geometry();
16+
if (!rect.contains(event->globalPosition().toPoint())) {
17+
close();
18+
}
19+
20+
return QQuickWindowQmlImpl::mouseReleaseEvent(event);
21+
}
22+
23+
QWindow *PopupWindow::transientParent() const
24+
{
25+
return QWindow::transientParent();
26+
}
27+
28+
void PopupWindow::setTransientParent(QWindow *window)
29+
{
30+
QWindow::setTransientParent(window);
31+
}
32+
33+
DS_END_NAMESPACE

frame/popupwindow.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
2+
//
3+
// SPDX-License-Identifier: GPL-3.0-or-later
4+
5+
#pragma once
6+
7+
#include "dsglobal.h"
8+
#include <private/qquickwindowmodule_p.h>
9+
10+
DS_BEGIN_NAMESPACE
11+
class PopupWindow : public QQuickWindowQmlImpl
12+
{
13+
Q_OBJECT
14+
Q_PROPERTY(QWindow *transientParent READ transientParent WRITE setTransientParent NOTIFY transientParentChanged)
15+
QML_NAMED_ELEMENT(PopupWindow)
16+
17+
public:
18+
PopupWindow(QWindow *parent = nullptr);
19+
20+
QWindow *transientParent() const;
21+
void setTransientParent(QWindow *window);
22+
23+
Q_SIGNALS:
24+
void transientParentChanged(QWindow *window);
25+
26+
protected:
27+
void mouseReleaseEvent(QMouseEvent *event) override;
28+
};
29+
DS_END_NAMESPACE

frame/qml/PanelPopupWindow.qml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import org.deepin.ds 1.0
88
import org.deepin.dtk 1.0 as D
99
import org.deepin.dtk.style 1.0 as DStyle
1010

11-
Window {
11+
PopupWindow {
1212
id: root
1313

1414
property real xOffset: 0
@@ -53,7 +53,7 @@ Window {
5353

5454
width: 10
5555
height: 10
56-
flags: (Qt.platform.pluginName === "xcb" ? (Qt.Tool | Qt.WindowStaysOnTopHint) : Qt.Popup)
56+
flags: (Qt.platform.pluginName === "xcb" ? (Qt.Tool | Qt.WindowStaysOnTopHint) : Qt.Popup)
5757
D.DWindow.enabled: true
5858
D.DWindow.windowRadius: D.DTK.platformTheme.windowRadius < 0 ? 4 : D.DTK.platformTheme.windowRadius
5959
D.DWindow.enableSystemResize: false

panels/dock/package/main.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Window {
5454
DLayerShellWindow.layer: DLayerShellWindow.LayerTop
5555
DLayerShellWindow.exclusionZone: Panel.hideMode === Dock.KeepShowing ? Applet.dockSize : 0
5656
DLayerShellWindow.scope: "dde-shell/dock"
57+
DLayerShellWindow.keyboardInteractivity: DLayerShellWindow.KeyboardInteractivityOnDemand
5758

5859
D.DWindow.enabled: true
5960
D.DWindow.windowRadius: 0

0 commit comments

Comments
 (0)