windowplugin: Add per-screen support for WindowMaximizedTracker

Contributes to #317

This refactor changes WindowMaximizedTracker from being a Singleton, and allows for it to be created in a way such that screens can be filtered out.

This fixes external screens from having their homescreen "zoom out" when an app is maximized on another screen.
This commit is contained in:
Devin Lin 2024-06-23 18:47:24 -04:00
parent a9624bc059
commit 5c53f9b6d2
8 changed files with 53 additions and 31 deletions

View file

@ -86,7 +86,7 @@ Item {
target: MobileShellState.ShellDBusClient target: MobileShellState.ShellDBusClient
function onOpenHomeScreenRequested() { function onOpenHomeScreenRequested() {
if (WindowPlugin.WindowMaximizedTracker.showingWindow) { if (windowMaximizedTracker.showingWindow) {
itemContainer.zoomIn(); itemContainer.zoomIn();
} }
@ -125,7 +125,7 @@ Item {
function onIsTaskSwitcherVisibleChanged() { function onIsTaskSwitcherVisibleChanged() {
if (MobileShellState.ShellDBusClient.isTaskSwitcherVisible) { if (MobileShellState.ShellDBusClient.isTaskSwitcherVisible) {
itemContainer.zoomOutImmediately(); itemContainer.zoomOutImmediately();
} else if (!WindowPlugin.WindowMaximizedTracker.showingWindow) { } else if (!windowMaximizedTracker.showingWindow) {
itemContainer.zoomIn(); itemContainer.zoomIn();
} }
} }
@ -151,6 +151,15 @@ Item {
evaluateMargins(); evaluateMargins();
} }
WindowPlugin.WindowMaximizedTracker {
id: windowMaximizedTracker
screenGeometry: Plasmoid.containment.screenGeometry
onShowingWindowChanged: {
itemContainer.evaluateAnimChange();
}
}
// homescreen visual component // homescreen visual component
MobileShell.BaseItem { MobileShell.BaseItem {
id: itemContainer id: itemContainer
@ -199,21 +208,13 @@ Item {
function evaluateAnimChange() { function evaluateAnimChange() {
// only animate if homescreen is visible // only animate if homescreen is visible
if (!WindowPlugin.WindowMaximizedTracker.showingWindow && !MobileShellState.ShellDBusClient.isTaskSwitcherVisible) { if (!windowMaximizedTracker.showingWindow && !MobileShellState.ShellDBusClient.isTaskSwitcherVisible) {
itemContainer.zoomIn(); itemContainer.zoomIn();
} else { } else {
itemContainer.zoomOut(); itemContainer.zoomOut();
} }
} }
Connections {
target: WindowPlugin.WindowMaximizedTracker
function onShowingWindowChanged() {
itemContainer.evaluateAnimChange();
}
}
transform: Scale { transform: Scale {
origin.x: itemContainer.width / 2; origin.x: itemContainer.width / 2;
origin.y: itemContainer.height / 2; origin.y: itemContainer.height / 2;

View file

@ -5,7 +5,6 @@ ecm_add_qml_module(windowplugin URI org.kde.plasma.private.mobileshell.windowplu
target_sources(windowplugin PRIVATE windowutil.cpp) target_sources(windowplugin PRIVATE windowutil.cpp)
set_source_files_properties(qml/WindowMaximizedTracker.qml PROPERTIES QT_QML_SINGLETON_TYPE TRUE)
ecm_target_qml_sources(windowplugin SOURCES qml/WindowMaximizedTracker.qml) ecm_target_qml_sources(windowplugin SOURCES qml/WindowMaximizedTracker.qml)
target_link_libraries(windowplugin PRIVATE target_link_libraries(windowplugin PRIVATE

View file

@ -8,11 +8,12 @@ import org.kde.taskmanager as TaskManager
import org.kde.plasma.private.mobileshell.windowplugin as WindowPlugin import org.kde.plasma.private.mobileshell.windowplugin as WindowPlugin
import org.kde.kitemmodels as KItemModels import org.kde.kitemmodels as KItemModels
pragma Singleton
// Helper component that uses Plasma's tasks model to provide whether a maximized window is showing on the current screen. // Helper component that uses Plasma's tasks model to provide whether a maximized window is showing on the current screen.
QtObject { QtObject {
// Setting this property is necessary to filter by screen, otherwise the model will use all screens.
// Set it to Plasmoid.containment.screenGeometry in a plasmoid to accomplish this.
property alias screenGeometry: tasksModel.screenGeometry
readonly property bool showingWindow: __internal.count > 0 && !WindowPlugin.WindowUtil.isShowingDesktop readonly property bool showingWindow: __internal.count > 0 && !WindowPlugin.WindowUtil.isShowingDesktop
property var __internal: KItemModels.KSortFilterProxyModel { property var __internal: KItemModels.KSortFilterProxyModel {

View file

@ -72,8 +72,13 @@ ContainmentItem {
} }
} }
WindowPlugin.WindowMaximizedTracker {
id: windowMaximizedTracker
screenGeometry: Plasmoid.containment.screenGeometry
}
function homeAction() { function homeAction() {
const isInWindow = (!WindowPlugin.WindowUtil.isShowingDesktop && WindowPlugin.WindowMaximizedTracker.showingWindow); const isInWindow = (!WindowPlugin.WindowUtil.isShowingDesktop && windowMaximizedTracker.showingWindow);
// Always close action drawer // Always close action drawer
if (MobileShellState.ShellDBusClient.isActionDrawerOpen) { if (MobileShellState.ShellDBusClient.isActionDrawerOpen) {

View file

@ -51,11 +51,12 @@ Item {
Plasmoid.editMode = false; Plasmoid.editMode = false;
} }
Connections { WindowPlugin.WindowMaximizedTracker {
target: WindowPlugin.WindowMaximizedTracker id: windowMaximizedTracker
screenGeometry: Plasmoid.containment.screenGeometry
function onShowingWindowChanged(){ onShowingWindowChanged: {
if (WindowPlugin.WindowMaximizedTracker.showingWindow) { if (windowMaximizedTracker.showingWindow) {
swipeView.focusChild(); swipeView.focusChild();
} }
} }

View file

@ -34,7 +34,7 @@ ContainmentItem {
MobileShellState.ShellDBusClient.closeActionDrawer(); MobileShellState.ShellDBusClient.closeActionDrawer();
} }
if (!WindowPlugin.WindowUtil.isShowingDesktop && WindowPlugin.WindowMaximizedTracker.showingWindow || search.isOpen) { if (!WindowPlugin.WindowUtil.isShowingDesktop && windowMaximizedTracker.showingWindow || search.isOpen) {
// Always close the search widget as well // Always close the search widget as well
if (search.isOpen) { if (search.isOpen) {
search.close(); search.close();
@ -51,6 +51,11 @@ ContainmentItem {
} }
} }
WindowPlugin.WindowMaximizedTracker {
id: windowMaximizedTracker
screenGeometry: Plasmoid.containment.screenGeometry
}
Rectangle { Rectangle {
id: darkenBackground id: darkenBackground
color: homeScreen.overlayShown ? 'transparent' : (halcyonHomeScreen.page == 1 ? Qt.rgba(0, 0, 0, 0.7) : Qt.rgba(0, 0, 0, 0.2)) color: homeScreen.overlayShown ? 'transparent' : (halcyonHomeScreen.page == 1 ? Qt.rgba(0, 0, 0, 0.7) : Qt.rgba(0, 0, 0, 0.2))

View file

@ -34,9 +34,14 @@ ContainmentItem {
} }
// only opaque if there are no maximized windows on this screen // only opaque if there are no maximized windows on this screen
readonly property bool showingApp: WindowPlugin.WindowMaximizedTracker.showingWindow readonly property bool showingApp: windowMaximizedTracker.showingWindow
readonly property color backgroundColor: topPanel.colorScopeColor readonly property color backgroundColor: topPanel.colorScopeColor
WindowPlugin.WindowMaximizedTracker {
id: windowMaximizedTracker
screenGeometry: Plasmoid.containment.screenGeometry
}
// enforce thickness // enforce thickness
Binding { Binding {
target: panel // assumed to be plasma-workspace "PanelView" component target: panel // assumed to be plasma-workspace "PanelView" component

View file

@ -110,7 +110,12 @@ ContainmentItem {
Component.onCompleted: setWindowProperties(); Component.onCompleted: setWindowProperties();
// only opaque if there are no maximized windows on this screen // only opaque if there are no maximized windows on this screen
readonly property bool opaqueBar: WindowPlugin.WindowMaximizedTracker.showingWindow readonly property bool opaqueBar: windowMaximizedTracker.showingWindow
WindowPlugin.WindowMaximizedTracker {
id: windowMaximizedTracker
screenGeometry: Plasmoid.containment.screenGeometry
}
Item { Item {
anchors.fill: parent anchors.fill: parent