From 79cc71ca15c6827930e33081bc3c843604477a2c Mon Sep 17 00:00:00 2001
From: Felix Gerking <felix.gerking@garz-fricke.com>
Date: Wed, 11 May 2022 13:37:39 +0200
Subject: [PATCH] dual-espresso: Added application to screen mapping for
 IVI-Shell

If more than one screen is present and an application is started with
IVI-Shell plugin, the application is mapped to a screen by evaluating
the set IVI-ID. For now IDs greater or equal 2000 are mapped to screen
2.

BCS 746-000666
---
 qml/main.qml | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/qml/main.qml b/qml/main.qml
index 37ec653..a898926 100644
--- a/qml/main.qml
+++ b/qml/main.qml
@@ -129,10 +129,16 @@ WaylandCompositor {
     }
 
     function handleIviSurfaceCreated(iviSurface) {
-        if (current_screen+1 > screens.count-1)
-                current_screen = 0;
-        else
-                current_screen++;
-        createIviSurfaceItem(iviSurface, screens.objectAt(current_screen));
+        // We select the screen by evaluating the iviId of the app,
+        // if more than one screen is present.
+        // If the unique ivi id is greater or equal 2000 we select screen 2
+        if (screens.count > 1) {
+            if (iviSurface.iviId > 1999)
+                createIviSurfaceItem(iviSurface, screens.objectAt(1));
+            else
+                createIviSurfaceItem(iviSurface, screens.objectAt(0));
+        } else {
+            createIviSurfaceItem(iviSurface, screens.objectAt(0));
+        }
     }
 }
-- 
GitLab