on xenial help sign in
[Stage] handle "Application" level focus request
be956d1Ratchanan Srirattanamet
qml/Stage/Stage.qml+20
@@ -485,6 +485,26 @@ FocusScope {
485 ? (!model.application.isTouchApp || isExemptFromLifecycle(model.application.appId))
485 ? (!model.application.isTouchApp || isExemptFromLifecycle(model.application.appId))
486 : false
486 : false
487 }
487 }
488+
489+ property var focusRequestedConnection: Connections {
490+ target: model.application
491+
492+ onFocusRequested: {
493+ // Application emits focusRequested when it has no surface (i.e. their processes died).
494+ // Find the topmost window for this application and activate it, after which the app
495+ // will be requested to be running.
496+
497+ for (var i = 0; i < appRepeater.count; i++) {
498+ var appDelegate = appRepeater.itemAt(i);
499+ if (appDelegate.application.appId === model.application.appId) {
500+ appDelegate.activate();
501+ return;
502+ }
503+ }
504+
505+ console.warn("Application requested te be focused but no window for it. What should we do?");
506+ }
507+ }
488 }
508 }
489 }
509 }
490
510