diff --git a/applets/kicker/package/contents/ui/ItemListDialog.qml b/applets/kicker/package/contents/ui/ItemListDialog.qml --- a/applets/kicker/package/contents/ui/ItemListDialog.qml +++ b/applets/kicker/package/contents/ui/ItemListDialog.qml @@ -30,15 +30,19 @@ property alias focusParent: itemListView.focusParent property alias model: funnelModel.sourceModel + property bool aboutToBeDestroyed: false + visible: false hideOnWindowDeactivate: plasmoid.hideOnWindowDeactivate location: PlasmaCore.Types.Floating offset: units.smallSpacing onWindowDeactivated: { - plasmoid.expanded = false; + if (!aboutToBeDestroyed) { + plasmoid.expanded = false; + } } mainItem: ItemListView { @@ -75,10 +79,12 @@ } function delayedDestroy() { + aboutToBeDestroyed = true; + plasmoid.hideOnWindowDeactivate = false; + visible = false; + Qt.callLater(function() { itemDialog.destroy(); }); } - - } diff --git a/applets/kicker/package/contents/ui/ItemListView.qml b/applets/kicker/package/contents/ui/ItemListView.qml --- a/applets/kicker/package/contents/ui/ItemListView.qml +++ b/applets/kicker/package/contents/ui/ItemListView.qml @@ -69,15 +69,10 @@ } 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 @@ childDialog.model = model.modelForRow(currentIndex); childDialog.visualParent = listView.currentItem; } else { - childDialog.visible = false; childDialog.delayedDestroy(); } @@ -186,7 +180,6 @@ dialogSpawnTimer.restart(); } } else if (childDialog != null) { - childDialog.visible = false; childDialog.delayedDestroy(); childDialog = null; } @@ -256,6 +249,8 @@ } Component.onCompleted: { + windowSystem.monitorWindowFocus(itemList); + if (dialog == null) { appendSearchText.connect(root.appendSearchText); } diff --git a/applets/kicker/package/contents/ui/main.qml b/applets/kicker/package/contents/ui/main.qml --- a/applets/kicker/package/contents/ui/main.qml +++ b/applets/kicker/package/contents/ui/main.qml @@ -262,7 +262,8 @@ if (plasmoid.hasOwnProperty("activationTogglesExpanded")) { plasmoid.activationTogglesExpanded = !isDash } - windowSystem.focusOut.connect(enableHideOnWindowDeactivate); + + windowSystem.focusIn.connect(enableHideOnWindowDeactivate); plasmoid.hideOnWindowDeactivate = true; if (plasmoid.immutability !== PlasmaCore.Types.SystemImmutable) { diff --git a/applets/kicker/plugin/windowsystem.h b/applets/kicker/plugin/windowsystem.h --- a/applets/kicker/plugin/windowsystem.h +++ b/applets/kicker/plugin/windowsystem.h @@ -44,7 +44,7 @@ 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: diff --git a/applets/kicker/plugin/windowsystem.cpp b/applets/kicker/plugin/windowsystem.cpp --- a/applets/kicker/plugin/windowsystem.cpp +++ b/applets/kicker/plugin/windowsystem.cpp @@ -34,8 +34,9 @@ bool WindowSystem::eventFilter(QObject* watched, QEvent* event) { - if (event->type() == QEvent::FocusOut) { - emit focusOut(qobject_cast(watched)); + if (event->type() == QEvent::FocusIn) { + removeEventFilter(watched); + emit focusIn(qobject_cast(watched)); } return false;