diff options
Diffstat (limited to 'examples/wayland/custom-extension/compositor/qml/main.qml')
-rw-r--r-- | examples/wayland/custom-extension/compositor/qml/main.qml | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/examples/wayland/custom-extension/compositor/qml/main.qml b/examples/wayland/custom-extension/compositor/qml/main.qml index 6739a5c9..a7d76227 100644 --- a/examples/wayland/custom-extension/compositor/qml/main.qml +++ b/examples/wayland/custom-extension/compositor/qml/main.qml @@ -139,6 +139,40 @@ WaylandCompositor { } } + + Component { + id: customObjectComponent + Rectangle { + id: customItem + property QtObject obj + property alias text: label.text + + width: 100 + height: 100 + radius: width/2 + x: Math.random() * (defaultOutput.surfaceArea.width - 100) + y: Math.random() * (defaultOutput.surfaceArea.height - 100) + + Text { + id: label + anchors.centerIn: parent + text: "?" + } + + MouseArea { + anchors.fill: parent + onClicked: obj.sendClicked() + } + + Connections { + target: obj + onResourceDestroyed: { + customItem.destroy() + } + } + } + } + WlShell { id: defaultShell onWlShellSurfaceCreated: { @@ -168,6 +202,9 @@ WaylandCompositor { var item = itemForSurface(surface) item.doSpin(ms) } + onCustomObjectCreated: { + var item = customObjectComponent.createObject(defaultOutput.surfaceArea, { "color": obj.color, "text": obj.text, "obj": obj } ); + } } function setDecorations(shown) { |