effects/overview: Add window filtering

This adds window filtering to the Overview effect. This satisfies both
Overview users' needs and the workflow of Windowview: When the user
starts typing, windows are filtered by default. If there is no matching
window, then the Milou UI is shown, including the option for opening a
new app is shown--the same one that currently gets shown when the user
starts typing. This leads to a very seamless experience, where the user
can type any app name and they will get it, no matter if it's already
opened or not.
This commit is contained in:
Niklas Stephanblome 2022-07-25 16:18:06 +00:00 committed by Nate Graham
parent dc92939908
commit 8407f88585

View file

@ -11,6 +11,7 @@ import org.kde.kwin.private.effects 1.0
import org.kde.milou 0.3 as Milou import org.kde.milou 0.3 as Milou
import org.kde.plasma.components 3.0 as PC3 import org.kde.plasma.components 3.0 as PC3
import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.kirigami 2.12 as Kirigami import org.kde.kirigami 2.12 as Kirigami
FocusScope { FocusScope {
@ -30,6 +31,7 @@ FocusScope {
function start() { function start() {
container.animationEnabled = true; container.animationEnabled = true;
container.organized = true; container.organized = true;
searchField.text = "";
} }
function stop() { function stop() {
@ -40,6 +42,12 @@ FocusScope {
Keys.priority: Keys.AfterItem Keys.priority: Keys.AfterItem
Keys.forwardTo: searchField Keys.forwardTo: searchField
Keys.onEnterPressed: {
heap.forceActiveFocus();
if (heap.count === 1) {
heap.activateCurrentClient();
}
}
KWinComponents.DesktopBackgroundItem { KWinComponents.DesktopBackgroundItem {
id: backgroundItem id: backgroundItem
@ -169,9 +177,18 @@ FocusScope {
focus: true focus: true
placeholderText: i18nd("kwin_effects", "Search...") placeholderText: i18nd("kwin_effects", "Search...")
clearButtonShown: true clearButtonShown: true
Keys.priority: Keys.AfterItem Keys.priority: Keys.BeforeItem
Keys.forwardTo: text ? searchResults : heap Keys.forwardTo: text && heap.count === 0 ? searchResults : heap
onTextEdited: forceActiveFocus(); onTextChanged: {
effect.searchText = text;
heap.resetSelected();
heap.selectNextItem(WindowHeap.Direction.Down);
}
Binding {
target: searchField
property: "text"
value: effect.searchText
}
} }
} }
} }
@ -180,11 +197,20 @@ FocusScope {
width: parent.width width: parent.width
height: parent.height - topBar.height height: parent.height - topBar.height
PlasmaExtras.PlaceholderMessage {
id: placeholderMessage
anchors.top: parent
anchors.horizontalCenter: parent.horizontalCenter
visible: container.organized && searchField.text && heap.count === 0
text: i18nd("kwin_effects", "No matching windows")
}
WindowHeap { WindowHeap {
id: heap id: heap
visible: !(container.organized && searchField.text) visible: !(container.organized && searchField.text) || heap.count !== 0
anchors.fill: parent anchors.fill: parent
layout.mode: effect.layout layout.mode: effect.layout
focus: true
padding: PlasmaCore.Units.largeSpacing padding: PlasmaCore.Units.largeSpacing
animationDuration: effect.animationDuration animationDuration: effect.animationDuration
animationEnabled: container.animationEnabled animationEnabled: container.animationEnabled
@ -195,11 +221,14 @@ FocusScope {
} }
window.closeWindow(); window.closeWindow();
} }
Keys.priority: Keys.AfterItem
Keys.forwardTo: searchResults
model: KWinComponents.ClientFilterModel { model: KWinComponents.ClientFilterModel {
activity: KWinComponents.Workspace.currentActivity activity: KWinComponents.Workspace.currentActivity
desktop: KWinComponents.Workspace.currentVirtualDesktop desktop: KWinComponents.Workspace.currentVirtualDesktop
screenName: targetScreen.name screenName: targetScreen.name
clientModel: stackModel clientModel: stackModel
filter: searchField.text
minimizedWindows: !effect.ignoreMinimized minimizedWindows: !effect.ignoreMinimized
windowType: ~KWinComponents.ClientFilterModel.Dock & windowType: ~KWinComponents.ClientFilterModel.Dock &
~KWinComponents.ClientFilterModel.Desktop & ~KWinComponents.ClientFilterModel.Desktop &
@ -226,11 +255,12 @@ FocusScope {
Milou.ResultsView { Milou.ResultsView {
id: searchResults id: searchResults
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
width: parent.width / 2 width: parent.width / 2
height: Math.min(contentHeight, parent.height) height: parent.height - placeholderMessage.height - PlasmaCore.Units.largeSpacing
queryString: searchField.text queryString: searchField.text
visible: container.organized && searchField.text visible: container.organized && searchField.text && heap.count === 0
onActivated: { onActivated: {
effect.deactivate(); effect.deactivate();