Skip to content

Commit

Permalink
Improve window handling
Browse files Browse the repository at this point in the history
Always maintain a list of all windows accepted by the system-ui
and their type. Depending on the type we know what needs to be
done in case the application is closed or stopped.

This is needed to properly release the surfaces of all windows
we accepted. IVI windows which are not minimized need to poped
from the stack first and a closing animation be played. All other
surfaces can be released once the surfaces are lost.

Change-Id: Ie8ede8c2b14b288d1a182d7c32095c2c4c90b845
Reviewed-by: Nedim Hadzic <[email protected]>
  • Loading branch information
Gagi2k committed Oct 12, 2016
1 parent 0b60c96 commit fc7ac09
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 33 deletions.
60 changes: 28 additions & 32 deletions imports/system/models/ApplicationManagerInterface.qml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ QtObject {
property string activeAppId

property variant blackListItems: []
property var minimizedItems: [] // Apps which will be started but not shown in full screen
property Item windowItem
property var preloadApplications: [] // Apps which will be started but not shown in full screen
property var windowTypes: ({})
property Item mapWidget
property var itemsToRelease: []

Expand All @@ -60,7 +60,7 @@ QtObject {
for (var i = 0; i < ApplicationManager.count; ++i) {
var app = ApplicationManager.get(i);
if (app.application.preload) {
minimizedItems.push(app.applicationId)
preloadApplications.push(app.applicationId)
}
}

Expand All @@ -83,22 +83,21 @@ QtObject {
var isMinimized = false;

if (isInWidgetState) {
windowTypes[item] = "widget"
if (ApplicationManager.get(appID).categories[0] === "navigation") {
root.mapWidget = item
}
return
}
else if (isClusterWidget) {
} else if (isClusterWidget) {
if (!Style.withCluster) {
acceptWindow = false
item.parent = null
} else {
if (ApplicationManager.get(appID).categories[0] === "navigation") {
windowTypes[item] = "cluster"
if (ApplicationManager.get(appID).categories[0] === "navigation")
root.clusterWidgetReady("navigation", item)
}
else if (ApplicationManager.get(appID).categories[0] === "media") {
else if (ApplicationManager.get(appID).categories[0] === "media")
root.clusterWidgetReady("media", item)
}
return
}
} else {
Expand All @@ -108,60 +107,58 @@ QtObject {
acceptWindow = false;
}

for (i = 0; i < root.minimizedItems.length; ++i) {
if (appID === root.minimizedItems[i]) {
root.minimizedItems.pop(appID)
for (i = 0; i < root.preloadApplications.length; ++i) {
if (appID === root.preloadApplications[i]) {
root.preloadApplications.pop(appID)
windowTypes[item] = "minimized"
isMinimized = true;
break
}
}

if (!isMinimized) {
windowTypes[item] = "ivi"
}
}

if (acceptWindow) {
root.windowItem = item
WindowManager.setWindowProperty(item, "visibility", !isMinimized)

root.applicationSurfaceReady(item, isMinimized)
} else {
// If nobody feels responsible for this window, we need to at least give it a
// parent, to not block the client process which would wait for result of the
// expose event indefinitely.

if (!item.parent) {
item.parent = root.windowItem
item.visible = false
item.paintingEnabled = false
}
console.error("window was not accepted: ", item)
}

}

function windowPropertyChanged(window, name, value) {
//print(":::LaunchController::: WindowManager:windowPropertyChanged", window, name, value)
if (name === "visibility" && value === false) {
if (name === "visibility" && value === false ) {
root.releaseApplicationSurface()
}
}

function windowClosingHandler(index, item) {
if (item === root.windowItem) { // start close animation
var type = windowTypes[item]
if (type === "ivi") { // start close animation
root.releaseApplicationSurface()
}
}

function windowLostHandler(index, item) {
var isClusterWidget = (WindowManager.windowProperty(item, "windowType") === "clusterWidget")
//We don't have a closing transition for widgets so it's save to release them immediately
if (isClusterWidget) {
WindowManager.releaseWindow(item)
} else {
//If the item is visible the closing application hasn't been played yet and we need to wait unti it is finished
var type = windowTypes[item]

//For special windows (cluster, widgets) we don't have a closing anmiation, close them directly
if (type === "ivi") {
//If the item is visible the closing application hasn't been played yet and we need to wait until it is finished
if (item.visible) {
itemsToRelease.push(item)
root.releaseApplicationSurface()
} else {
WindowManager.releaseWindow(item)
}
} else {
delete windowTypes[item]
WindowManager.releaseWindow(item)
}
}

Expand Down Expand Up @@ -190,7 +187,6 @@ QtObject {

if (!isMapWidget && !isClusterWidget) {
WindowManager.setWindowProperty(item, "visibility", true)
root.windowItem = item
root.applicationSurfaceReady(item, false)
break
}
Expand Down
11 changes: 10 additions & 1 deletion sysui/LaunchController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ StackView {
}

ScriptAction {
script: { exitItem.visible = false; ApplicationManagerInterface.releasingApplicationSurfaceDone(exitItem) }
script: {
exitItem.visible = false;
ApplicationManagerInterface.releasingApplicationSurfaceDone(exitItem)
}
}
}
}
Expand All @@ -140,6 +143,9 @@ StackView {
target: ApplicationManagerInterface

onApplicationSurfaceReady: {
if (root.busy)
root.completeTransition()

if (isMinimized)
item.parent = dummyitem
else
Expand All @@ -150,6 +156,9 @@ StackView {
if (root.depth <= 1)
return;

if (root.busy)
root.completeTransition()

root.pop(null)
}
}
Expand Down

0 comments on commit fc7ac09

Please sign in to comment.