~ci-train-bot/unity8/unity8-ubuntu-zesty-2702

« back to all changes in this revision

Viewing changes to qml/Stage/ChildWindowTree.qml

  • Committer: Bileto Bot
  • Author(s): Daniel d'Andrada
  • Date: 2017-03-28 21:46:10 UTC
  • mfrom: (2890.1.1 childWindowFocus)
  • Revision ID: ci-train-bot@canonical.com-20170328214610-p3dzgzaqvdmvaa26
Give active focus to child surface qml items (LP: #1671072)

Approved by: Lukáš Tinkl, Unity8 CI Bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2016 Canonical, Ltd.
 
2
 * Copyright (C) 2016-2017 Canonical, Ltd.
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License as published by
18
18
import Ubuntu.Components 1.3
19
19
import Unity.Application 0.1
20
20
 
21
 
Item {
 
21
FocusScope {
22
22
    id: root
23
23
 
24
24
    property alias surface: childWindow.surface
100
100
        onFocusRequested: {
101
101
            root.surface.activate();
102
102
        }
 
103
        onFocusedChanged: {
 
104
            if (root.surface.focused) {
 
105
                childWindow.focus = true;
 
106
                // Propagate
 
107
                root.focus = true;
 
108
            }
 
109
        }
103
110
    }
104
111
 
105
112
    // Using a loader here mainly to circunvent the "ChildWindowTree is instantiated recursively" error from the QML engine
119
126
            property: "boundsItem"
120
127
            value: root.boundsItem
121
128
        }
 
129
        onFocusChanged: {
 
130
            if (focus) {
 
131
                // A surface in some ChildWindowTree got focused.
 
132
                // Propagate
 
133
                root.focus = true;
 
134
            }
 
135
        }
122
136
    }
123
137
}