Commit fc155e94 authored by Eike Hein's avatar Eike Hein

Don't close plasmoid when closing a subdialog

Summary:
This patch redoes the fencing mechanism around
plasmoid.hideOnWindowDeactivate for window focus
handovers to be more reliable and generic. It's now
always disabled when a dialog is about to be
destroyed, and renabled on focus-in or when exiting
the root list. The dialog code is also fixed not
to close the plasmoid when it knows it's window
deactivation is part of its own destruction.

WindowSystem::monitorWindowFocus is also changed
to work in a single-shot sort of way, removing
the event filter again once it caught an event.

Fixes a refactoring regression from 84f1cb1c.

BUG:388669

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9945
parent c9d7c9dd
......@@ -30,6 +30,8 @@ Kicker.SubMenu {
property alias focusParent: itemListView.focusParent
property alias model: funnelModel.sourceModel
property bool aboutToBeDestroyed: false
visible: false
hideOnWindowDeactivate: plasmoid.hideOnWindowDeactivate
......@@ -38,7 +40,9 @@ Kicker.SubMenu {
offset: units.smallSpacing
onWindowDeactivated: {
plasmoid.expanded = false;
if (!aboutToBeDestroyed) {
plasmoid.expanded = false;
}
}
mainItem: ItemListView {
......@@ -75,10 +79,12 @@ Kicker.SubMenu {
}
function delayedDestroy() {
aboutToBeDestroyed = true;
plasmoid.hideOnWindowDeactivate = false;
visible = false;
Qt.callLater(function() {
itemDialog.destroy();
});
}
}
......@@ -69,15 +69,10 @@ FocusScope {
}
if (childDialog != null) {
childDialog.visible = false;
childDialog.delayedDestroy();
}
windowSystem.monitorWindowFocus(itemList);
// Gets reenabled after the dialog spawn causes a focus out on this window.
// This avoids Kicker closing due to unreliable timing making Dialog::focusOutEvent()
// unable to tell focus moved to a child window.
// Gets reenabled after the dialog spawn causes a focus-in on the dialog window.
plasmoid.hideOnWindowDeactivate = false;
childDialog = itemListDialogComponent.createObject(itemList);
......@@ -168,7 +163,6 @@ FocusScope {
childDialog.model = model.modelForRow(currentIndex);
childDialog.visualParent = listView.currentItem;
} else {
childDialog.visible = false;
childDialog.delayedDestroy();
}
......@@ -186,7 +180,6 @@ FocusScope {
dialogSpawnTimer.restart();
}
} else if (childDialog != null) {
childDialog.visible = false;
childDialog.delayedDestroy();
childDialog = null;
}
......@@ -256,6 +249,8 @@ FocusScope {
}
Component.onCompleted: {
windowSystem.monitorWindowFocus(itemList);
if (dialog == null) {
appendSearchText.connect(root.appendSearchText);
}
......
......@@ -262,7 +262,8 @@ Item {
if (plasmoid.hasOwnProperty("activationTogglesExpanded")) {
plasmoid.activationTogglesExpanded = !isDash
}
windowSystem.focusOut.connect(enableHideOnWindowDeactivate);
windowSystem.focusIn.connect(enableHideOnWindowDeactivate);
plasmoid.hideOnWindowDeactivate = true;
if (plasmoid.immutability !== PlasmaCore.Types.SystemImmutable) {
......
......@@ -34,8 +34,9 @@ WindowSystem::~WindowSystem()
bool WindowSystem::eventFilter(QObject* watched, QEvent* event)
{
if (event->type() == QEvent::FocusOut) {
emit focusOut(qobject_cast<QQuickWindow *>(watched));
if (event->type() == QEvent::FocusIn) {
removeEventFilter(watched);
emit focusIn(qobject_cast<QQuickWindow *>(watched));
}
return false;
......
......@@ -44,7 +44,7 @@ class WindowSystem : public QObject
Q_INVOKABLE void monitorWindowVisibility(QQuickItem *item);
Q_SIGNALS:
void focusOut(QQuickWindow *window) const;
void focusIn(QQuickWindow *window) const;
void hidden(QQuickWindow *window) const;
private Q_SLOTS:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment