mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
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:
parent
a9624bc059
commit
5c53f9b6d2
8 changed files with 53 additions and 31 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import org.kde.plasma.private.mobileshell.windowplugin as WindowPlugin
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
required property real topMargin
|
required property real topMargin
|
||||||
required property real bottomMargin
|
required property real bottomMargin
|
||||||
required property real leftMargin
|
required property real leftMargin
|
||||||
|
|
@ -24,7 +24,7 @@ Item {
|
||||||
|
|
||||||
required property bool interactive
|
required property bool interactive
|
||||||
required property var searchWidget
|
required property var searchWidget
|
||||||
|
|
||||||
property alias page: swipeView.currentIndex
|
property alias page: swipeView.currentIndex
|
||||||
|
|
||||||
property bool settingsOpen: false
|
property bool settingsOpen: false
|
||||||
|
|
@ -41,7 +41,7 @@ Item {
|
||||||
favoritesView.goToBeginning();
|
favoritesView.goToBeginning();
|
||||||
gridAppList.goToBeginning();
|
gridAppList.goToBeginning();
|
||||||
}
|
}
|
||||||
|
|
||||||
function openConfigure() {
|
function openConfigure() {
|
||||||
settingsOpen = true;
|
settingsOpen = true;
|
||||||
}
|
}
|
||||||
|
|
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -75,7 +76,7 @@ Item {
|
||||||
id: swipeView
|
id: swipeView
|
||||||
opacity: Math.min(1 - root.settingsOpenFactor, 1 - searchWidget.openFactor)
|
opacity: Math.min(1 - root.settingsOpenFactor, 1 - searchWidget.openFactor)
|
||||||
interactive: root.interactive
|
interactive: root.interactive
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.topMargin: root.topMargin
|
anchors.topMargin: root.topMargin
|
||||||
anchors.bottomMargin: root.bottomMargin
|
anchors.bottomMargin: root.bottomMargin
|
||||||
|
|
@ -104,7 +105,7 @@ Item {
|
||||||
|
|
||||||
onLongPressed: root.openConfigure()
|
onLongPressed: root.openConfigure()
|
||||||
}
|
}
|
||||||
|
|
||||||
FavoritesView {
|
FavoritesView {
|
||||||
id: favoritesView
|
id: favoritesView
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
@ -128,7 +129,7 @@ Item {
|
||||||
|
|
||||||
GridAppList {
|
GridAppList {
|
||||||
id: gridAppList
|
id: gridAppList
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
property int horizontalMargin: Math.round(swipeView.width * 0.05)
|
property int horizontalMargin: Math.round(swipeView.width * 0.05)
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,13 @@ import org.kde.plasma.private.mobileshell.windowplugin as WindowPlugin
|
||||||
|
|
||||||
ContainmentItem {
|
ContainmentItem {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
Halcyon.ApplicationListModel.loadApplications();
|
Halcyon.ApplicationListModel.loadApplications();
|
||||||
Halcyon.PinnedModel.applet = root.plasmoid;
|
Halcyon.PinnedModel.applet = root.plasmoid;
|
||||||
forceActiveFocus();
|
forceActiveFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
Plasmoid.onActivated: {
|
Plasmoid.onActivated: {
|
||||||
// there's a couple of steps:
|
// there's a couple of steps:
|
||||||
// - minimize windows (only if we are in an app)
|
// - minimize windows (only if we are in an app)
|
||||||
|
|
@ -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))
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue