diff --git a/frame/popupwindow.h b/frame/popupwindow.h index 8a6eb2f54..24481389d 100644 --- a/frame/popupwindow.h +++ b/frame/popupwindow.h @@ -34,8 +34,8 @@ class PopupWindow : public QQuickApplicationWindow private: void setX11GrabFocusTransition(bool transition); - bool m_dragging; - bool m_pressing; + bool m_dragging = false; + bool m_pressing = false; bool m_x11GrabFocusTransition = false; }; DS_END_NAMESPACE diff --git a/frame/qml/PanelMenu.qml b/frame/qml/PanelMenu.qml index 0108cbd22..c6a06efaa 100644 --- a/frame/qml/PanelMenu.qml +++ b/frame/qml/PanelMenu.qml @@ -15,6 +15,7 @@ Item { property int menuX: 0 property int menuY: 0 property bool readyBinding: false + property bool openPending: false // WM_NAME, used for kwin. property string windowTitle: "dde-shell/panelmenu" width: menu.childrenRect.width @@ -32,13 +33,11 @@ Item { } Binding { when: readyBinding - delayed: true target: menuWindow; property: "xOffset" value: control.menuX } Binding { when: readyBinding - delayed: true target: menuWindow; property: "yOffset" value: control.menuY } @@ -53,32 +52,56 @@ Item { if (!menuWindow) return + if (menuWindow.visible) { + menuWindow.close() + menuWindow.currentItem = null + Qt.callLater(function () { + if (!menu.visible) { + control.open() + } + }) + return + } + readyBinding = Qt.binding(function () { return menuWindow && menuWindow.currentItem === control }) menuWindow.currentItem = control Qt.callLater(function () { - menuWindow.title = windowTitle - menuWindow.show() - DS.grabMouse(menuWindow) - DS.grabKeyboard(menuWindow) + if (!menuWindow || menuWindow.currentItem !== control) + return + openPending = true + menuWindow.requestUpdateGeometry() }) } function close() { + openPending = false if (!menuWindow) return if (!readyBinding) return - + menuWindow.close() menuWindow.currentItem = null DS.grabKeyboard(menuWindow, false) } + function finalizeOpen() + { + if (!menuWindow || !openPending || !readyBinding || menuWindow.currentItem !== control) + return + + openPending = false + menuWindow.title = windowTitle + menuWindow.show() + DS.grabMouse(menuWindow) + DS.grabKeyboard(menuWindow) + } + Connections { target: menuWindow function onActiveChanged() @@ -90,6 +113,11 @@ Item { control.close() } } + + function onUpdateGeometryFinished() + { + control.finalizeOpen() + } } Item { diff --git a/frame/qml/PanelPopup.qml b/frame/qml/PanelPopup.qml index b0bdb8995..625c13abe 100644 --- a/frame/qml/PanelPopup.qml +++ b/frame/qml/PanelPopup.qml @@ -15,6 +15,7 @@ Item { property int popupX: 0 property int popupY: 0 property bool readyBinding: false + property bool openPending: false property bool grabInactivePending: false property int grabInactiveTimeout: 200 // WM_NAME, used for kwin. @@ -34,13 +35,11 @@ Item { } Binding { when: readyBinding - delayed: true target: popupWindow; property: "xOffset" value: control.popupX } Binding { when: readyBinding - delayed: true target: popupWindow; property: "yOffset" value: control.popupY } @@ -61,6 +60,12 @@ Item { if (popupWindow.visible) { popupWindow.close() popupWindow.currentItem = null + Qt.callLater(function () { + if (!popup.visible) { + control.open() + } + }) + return } readyBinding = Qt.binding(function () { @@ -68,24 +73,41 @@ Item { }) popupWindow.currentItem = control - timer.start() + openPending = true + Qt.callLater(function () { + if (!popupWindow || !openPending || !readyBinding || popupWindow.currentItem !== control) + return + popupWindow.requestUpdateGeometry() + }) } - Timer { - id: timer - interval: 10 - onTriggered: { - if (!popupWindow) - return + function close() + { + openPending = false + grabInactivePending = false + grabInactiveTimer.stop() + if (!popupWindow) + return - if (!readyBinding) - return + // avoid to closing window by other PanelPopup. + if (!readyBinding) + return - popupWindow.title = windowTitle - popupWindow.show() - popupWindow.requestActivate() - } + popupWindow.close() + popupWindow.currentItem = null } + + function finalizeOpen() + { + if (!popupWindow || !openPending || !readyBinding || popupWindow.currentItem !== control) + return + + openPending = false + popupWindow.title = windowTitle + popupWindow.show() + popupWindow.requestActivate() + } + Timer { id: grabInactiveTimer interval: control.grabInactiveTimeout @@ -100,20 +122,6 @@ Item { } } } - function close() - { - grabInactivePending = false - grabInactiveTimer.stop() - if (!popupWindow) - return - - // avoid to closing window by other PanelPopup. - if (!readyBinding) - return - - popupWindow.close() - popupWindow.currentItem = null - } Connections { target: popupWindow @@ -140,6 +148,11 @@ Item { } } + function onUpdateGeometryFinished() + { + control.finalizeOpen() + } + function onX11FocusOutByGrab() { if (!popupWindow || !readyBinding || !popup.visible || popupWindow.currentItem !== control) { diff --git a/frame/qml/PanelPopupWindow.qml b/frame/qml/PanelPopupWindow.qml index 4de58dd69..78a452fec 100644 --- a/frame/qml/PanelPopupWindow.qml +++ b/frame/qml/PanelPopupWindow.qml @@ -17,6 +17,7 @@ PopupWindow { property Item currentItem property int requestedWidth: 10 property int requestedHeight: 10 + property bool geometryUpdatePending: false signal requestUpdateGeometry() signal updateGeometryFinished() @@ -135,12 +136,15 @@ PopupWindow { onYOffsetChanged: requestUpdateGeometry() onRequestUpdateGeometry: { - if (updateGeometryer) { - Qt.callLater(function () { - updateGeometryer() - updateGeometryFinished() - }) - } + if (!updateGeometryer || geometryUpdatePending) + return + + geometryUpdatePending = true + Qt.callLater(function () { + geometryUpdatePending = false + updateGeometryer() + updateGeometryFinished() + }) } D.StyledBehindWindowBlur { @@ -163,4 +167,4 @@ PopupWindow { DStyle.Style.behindWindowBlur.darkNoBlurColor) } } -} \ No newline at end of file +} diff --git a/frame/qml/PanelToolTip.qml b/frame/qml/PanelToolTip.qml index 1ef671329..0141df5dc 100644 --- a/frame/qml/PanelToolTip.qml +++ b/frame/qml/PanelToolTip.qml @@ -18,6 +18,7 @@ Item { property int toolTipX: 0 property int toolTipY: 0 property bool readyBinding: false + property bool openPending: false // WM_NAME, used for kwin. property string windowTitle: "dde-shell/paneltooltip" width: toolTip.width @@ -35,13 +36,11 @@ Item { } Binding { when: readyBinding - delayed: true target: toolTipWindow; property: "xOffset" value: control.toolTipX - (toolTip.leftPadding + toolTip.rightPadding) / 2 } Binding { when: readyBinding - delayed: true target: toolTipWindow; property: "yOffset" value: control.toolTipY } @@ -51,31 +50,34 @@ Item { if (!toolTipWindow) return + if (toolTipWindow.visible) { + toolTipWindow.close() + toolTipWindow.currentItem = null + Qt.callLater(function () { + if (!toolTip.visible) { + control.open() + } + }) + return + } + readyBinding = Qt.binding(function () { return toolTipWindow && toolTipWindow.currentItem === control }) toolTipWindow.currentItem = control - timer.start() - } - - Timer { - id: timer - interval: 10 - onTriggered: { - if (!toolTipWindow) + openPending = true + Qt.callLater(function () { + if (!toolTipWindow || !openPending || !readyBinding || toolTipWindow.currentItem !== control) return - if (!readyBinding) - return - - toolTipWindow.title = windowTitle - toolTipWindow.show() - } + toolTipWindow.requestUpdateGeometry() + }) } - + function close() { + openPending = false if (!toolTipWindow) return @@ -85,11 +87,30 @@ Item { toolTipWindow.close() toolTipWindow.currentItem = null } + function hide() { close() } + function finalizeOpen() + { + if (!toolTipWindow || !openPending || !readyBinding || toolTipWindow.currentItem !== control) + return + + openPending = false + toolTipWindow.title = windowTitle + toolTipWindow.show() + } + + Connections { + target: toolTipWindow + function onUpdateGeometryFinished() + { + control.finalizeOpen() + } + } + Control { id: toolTip visible: readyBinding