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
function onOpenHomeScreenRequested() {
if (WindowPlugin.WindowMaximizedTracker.showingWindow) {
if (windowMaximizedTracker.showingWindow) {
itemContainer.zoomIn();
}
@ -125,7 +125,7 @@ Item {
function onIsTaskSwitcherVisibleChanged() {
if (MobileShellState.ShellDBusClient.isTaskSwitcherVisible) {
itemContainer.zoomOutImmediately();
} else if (!WindowPlugin.WindowMaximizedTracker.showingWindow) {
} else if (!windowMaximizedTracker.showingWindow) {
itemContainer.zoomIn();
}
}
@ -151,6 +151,15 @@ Item {
evaluateMargins();
}
WindowPlugin.WindowMaximizedTracker {
id: windowMaximizedTracker
screenGeometry: Plasmoid.containment.screenGeometry
onShowingWindowChanged: {
itemContainer.evaluateAnimChange();
}
}
// homescreen visual component
MobileShell.BaseItem {
id: itemContainer
@ -199,21 +208,13 @@ Item {
function evaluateAnimChange() {
// only animate if homescreen is visible
if (!WindowPlugin.WindowMaximizedTracker.showingWindow && !MobileShellState.ShellDBusClient.isTaskSwitcherVisible) {
if (!windowMaximizedTracker.showingWindow && !MobileShellState.ShellDBusClient.isTaskSwitcherVisible) {
itemContainer.zoomIn();
} else {
itemContainer.zoomOut();
}
}
Connections {
target: WindowPlugin.WindowMaximizedTracker
function onShowingWindowChanged() {
itemContainer.evaluateAnimChange();
}
}
transform: Scale {
origin.x: itemContainer.width / 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)
set_source_files_properties(qml/WindowMaximizedTracker.qml PROPERTIES QT_QML_SINGLETON_TYPE TRUE)
ecm_target_qml_sources(windowplugin SOURCES qml/WindowMaximizedTracker.qml)
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.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.
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
property var __internal: KItemModels.KSortFilterProxyModel {

View file

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

View file

@ -16,7 +16,7 @@ import org.kde.plasma.private.mobileshell.windowplugin as WindowPlugin
Item {
id: root
required property real topMargin
required property real bottomMargin
required property real leftMargin
@ -24,7 +24,7 @@ Item {
required property bool interactive
required property var searchWidget
property alias page: swipeView.currentIndex
property bool settingsOpen: false
@ -41,7 +41,7 @@ Item {
favoritesView.goToBeginning();
gridAppList.goToBeginning();
}
function openConfigure() {
settingsOpen = true;
}
@ -51,11 +51,12 @@ Item {
Plasmoid.editMode = false;
}
Connections {
target: WindowPlugin.WindowMaximizedTracker
WindowPlugin.WindowMaximizedTracker {
id: windowMaximizedTracker
screenGeometry: Plasmoid.containment.screenGeometry
function onShowingWindowChanged(){
if (WindowPlugin.WindowMaximizedTracker.showingWindow) {
onShowingWindowChanged: {
if (windowMaximizedTracker.showingWindow) {
swipeView.focusChild();
}
}
@ -75,7 +76,7 @@ Item {
id: swipeView
opacity: Math.min(1 - root.settingsOpenFactor, 1 - searchWidget.openFactor)
interactive: root.interactive
anchors.fill: parent
anchors.topMargin: root.topMargin
anchors.bottomMargin: root.bottomMargin
@ -104,7 +105,7 @@ Item {
onLongPressed: root.openConfigure()
}
FavoritesView {
id: favoritesView
anchors.fill: parent
@ -128,7 +129,7 @@ Item {
GridAppList {
id: gridAppList
anchors.fill: parent
property int horizontalMargin: Math.round(swipeView.width * 0.05)

View file

@ -16,13 +16,13 @@ import org.kde.plasma.private.mobileshell.windowplugin as WindowPlugin
ContainmentItem {
id: root
Component.onCompleted: {
Halcyon.ApplicationListModel.loadApplications();
Halcyon.PinnedModel.applet = root.plasmoid;
forceActiveFocus();
}
Plasmoid.onActivated: {
// there's a couple of steps:
// - minimize windows (only if we are in an app)
@ -34,7 +34,7 @@ ContainmentItem {
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
if (search.isOpen) {
search.close();
@ -51,6 +51,11 @@ ContainmentItem {
}
}
WindowPlugin.WindowMaximizedTracker {
id: windowMaximizedTracker
screenGeometry: Plasmoid.containment.screenGeometry
}
Rectangle {
id: darkenBackground
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
readonly property bool showingApp: WindowPlugin.WindowMaximizedTracker.showingWindow
readonly property bool showingApp: windowMaximizedTracker.showingWindow
readonly property color backgroundColor: topPanel.colorScopeColor
WindowPlugin.WindowMaximizedTracker {
id: windowMaximizedTracker
screenGeometry: Plasmoid.containment.screenGeometry
}
// enforce thickness
Binding {
target: panel // assumed to be plasma-workspace "PanelView" component

View file

@ -110,7 +110,12 @@ ContainmentItem {
Component.onCompleted: setWindowProperties();
// 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 {
anchors.fill: parent