Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frame/popupwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
42 changes: 35 additions & 7 deletions frame/qml/PanelMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand All @@ -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()
Expand All @@ -90,6 +113,11 @@ Item {
control.close()
}
}

function onUpdateGeometryFinished()
{
control.finalizeOpen()
}
}

Item {
Expand Down
71 changes: 42 additions & 29 deletions frame/qml/PanelPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}
Expand All @@ -61,31 +60,54 @@ Item {
if (popupWindow.visible) {
popupWindow.close()
popupWindow.currentItem = null
Qt.callLater(function () {
if (!popup.visible) {
control.open()
}
})
return
}

readyBinding = Qt.binding(function () {
return popupWindow && popupWindow.currentItem === control
})

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
Expand All @@ -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
Expand All @@ -140,6 +148,11 @@ Item {
}
}

function onUpdateGeometryFinished()
{
control.finalizeOpen()
}

function onX11FocusOutByGrab()
{
if (!popupWindow || !readyBinding || !popup.visible || popupWindow.currentItem !== control) {
Expand Down
18 changes: 11 additions & 7 deletions frame/qml/PanelPopupWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ PopupWindow {
property Item currentItem
property int requestedWidth: 10
property int requestedHeight: 10
property bool geometryUpdatePending: false
signal requestUpdateGeometry()
signal updateGeometryFinished()

Expand Down Expand Up @@ -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 {
Expand All @@ -163,4 +167,4 @@ PopupWindow {
DStyle.Style.behindWindowBlur.darkNoBlurColor)
}
}
}
}
55 changes: 38 additions & 17 deletions frame/qml/PanelToolTip.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand All @@ -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

Expand All @@ -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
Expand Down
Loading