From 3a3047e6f2cd4dab84a0a3f047e223ef1bf84b61 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Mon, 21 Sep 2020 15:20:59 +0300 Subject: Init homescreen-demo-ci app Bug-AGL: SPEC-3592 Signed-off-by: Marius Vlad Change-Id: Id58ed059cdd44c2931a7b5d67970cbafd9e25002 --- COPYING | 22 ++++ README.md | 4 + autobuild/agl/autobuild | 110 +++++++++++++++++ autobuild/linux/autobuild | 110 +++++++++++++++++ package/config.xml | 13 ++ package/icon.svg | 279 ++++++++++++++++++++++++++++++++++++++++++ package/package.pro | 27 ++++ shell.pro | 7 ++ shell/README.md | 0 shell/images/DividingLine.svg | 62 ++++++++++ shell/images/critical.svg | 146 ++++++++++++++++++++++ shell/images/exclamation.svg | 130 ++++++++++++++++++++ shell/images/images.qrc | 10 ++ shell/images/information.svg | 130 ++++++++++++++++++++ shell/images/question.svg | 130 ++++++++++++++++++++ shell/protocol/agl-shell.xml | 117 ++++++++++++++++++ shell/qml/background.qml | 11 ++ shell/qml/bg.qml | 27 ++++ shell/qml/bottom.qml | 13 ++ shell/qml/left.qml | 13 ++ shell/qml/main.qml | 12 ++ shell/qml/qml.qrc | 9 ++ shell/qml/right.qml | 13 ++ shell/qml/top.qml | 13 ++ shell/shell.pro | 22 ++++ shell/src/main.cpp | 191 +++++++++++++++++++++++++++++ shell/src/shell.cpp | 35 ++++++ shell/src/shell.h | 45 +++++++ 28 files changed, 1701 insertions(+) create mode 100644 COPYING create mode 100644 README.md create mode 100755 autobuild/agl/autobuild create mode 100755 autobuild/linux/autobuild create mode 100644 package/config.xml create mode 100644 package/icon.svg create mode 100644 package/package.pro create mode 100644 shell.pro create mode 100644 shell/README.md create mode 100644 shell/images/DividingLine.svg create mode 100644 shell/images/critical.svg create mode 100644 shell/images/exclamation.svg create mode 100644 shell/images/images.qrc create mode 100644 shell/images/information.svg create mode 100644 shell/images/question.svg create mode 100644 shell/protocol/agl-shell.xml create mode 100644 shell/qml/background.qml create mode 100644 shell/qml/bg.qml create mode 100644 shell/qml/bottom.qml create mode 100644 shell/qml/left.qml create mode 100644 shell/qml/main.qml create mode 100644 shell/qml/qml.qrc create mode 100644 shell/qml/right.qml create mode 100644 shell/qml/top.qml create mode 100644 shell/shell.pro create mode 100644 shell/src/main.cpp create mode 100644 shell/src/shell.cpp create mode 100644 shell/src/shell.h diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..74eaa45 --- /dev/null +++ b/COPYING @@ -0,0 +1,22 @@ +Copyright © 2020 Collabora, Ltd. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial +portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..843e484 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +homescreen-demo-ci +================== + +demo app for testing the screenshooter and application functionality. diff --git a/autobuild/agl/autobuild b/autobuild/agl/autobuild new file mode 100755 index 0000000..bbbc13e --- /dev/null +++ b/autobuild/agl/autobuild @@ -0,0 +1,110 @@ +#!/usr/bin/make -f +# Copyright (C) 2015 - 2018 "IoT.bzh" +# Copyright (C) 2020 Konsulko Group +# Author "Romain Forlot" +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +THISFILE := $(lastword $(MAKEFILE_LIST)) +ROOT_DIR := $(abspath $(dir $(THISFILE))/../..) + +# Build directories +# Note that the debug directory is defined in relation to the release +# directory (BUILD_DIR), this needs to be kept in mind if over-riding +# it and building that widget types, the specific widget type variable +# (e.g. BUILD_DIR_DEBUG) may also need to be specified to yield the +# desired output hierarchy. +BUILD_DIR = $(ROOT_DIR)/build +BUILD_DIR_DEBUG = $(abspath $(BUILD_DIR)/../build-debug) + +# Output directory variable for use in pattern rules. +# This is intended for internal use only, hence the explicit override +# definition. +override OUTPUT_DIR = $(BUILD_DIR) + +# Final install directory for widgets +DEST = $(OUTPUT_DIR) + +# Default build type for release builds +BUILD_TYPE = release + +.PHONY: all help update install distclean +.PHONY: clean clean-release clean-debug clean-all +.PHONY: configure configure-release configure-debug +.PHONY: build build-release build-debug build-all +.PHONY: package package-release package-debug package-all + +help: + @echo "List of targets available:" + @echo "" + @echo "- all" + @echo "- help" + @echo "- clean" + @echo "- distclean" + @echo "- configure" + @echo "- build: compilation, link and prepare files for package into a widget" + @echo "- package: output a widget file '*.wgt'" + @echo "- install: install in $(DEST) directory" + @echo "" + @echo "Usage: ./autobuild/agl/autobuild package DEST=${HOME}/opt" + @echo "Don't use your build dir as DEST as wgt file is generated at this location" + +all: package-all + +# Target specific variable over-rides so static pattern rules can be +# used for the various type-specific targets. + +configure-debug build-debug package-debug clean-debug: OUTPUT_DIR = $(BUILD_DIR_DEBUG) +configure-debug build-debug package-debug: BUILD_TYPE = debug + +clean-release clean-debug: + @if [ -d $(OUTPUT_DIR) ]; then \ + $(MAKE) -C $(OUTPUT_DIR) $(CLEAN_ARGS) clean; \ + else \ + echo Nothing to clean; \ + fi + +clean: clean-release + +clean-all: clean-release clean-debug + +distclean: clean-all + +configure-release configure-debug: + @mkdir -p $(OUTPUT_DIR) + @if [ ! -f $(OUTPUT_DIR)/Makefile ]; then \ + (cd $(OUTPUT_DIR) && qmake CONFIG+=$(BUILD_TYPE) $(CONFIGURE_ARGS) $(ROOT_DIR)); \ + fi + +configure: configure-release + +build-release build-debug: build-%: configure-% + @$(MAKE) -C $(OUTPUT_DIR) $(BUILD_ARGS) all + +build: build-release + +build-all: build-release build-debug + +package-release package-debug: package-%: build-% + @cp $(OUTPUT_DIR)/package/*.wgt $(OUTPUT_DIR)/ + @if [ "$(abspath $(DEST))" != "$(abspath $(OUTPUT_DIR))" ]; then \ + mkdir -p $(DEST) && cp $(OUTPUT_DIR)/*.wgt $(DEST); \ + fi + + +package: package-release + +package-all: package-release package-debug + +install: build + @$(MAKE) -C $(BUILD_DIR) $(INSTALL_ARGS) install diff --git a/autobuild/linux/autobuild b/autobuild/linux/autobuild new file mode 100755 index 0000000..bbbc13e --- /dev/null +++ b/autobuild/linux/autobuild @@ -0,0 +1,110 @@ +#!/usr/bin/make -f +# Copyright (C) 2015 - 2018 "IoT.bzh" +# Copyright (C) 2020 Konsulko Group +# Author "Romain Forlot" +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +THISFILE := $(lastword $(MAKEFILE_LIST)) +ROOT_DIR := $(abspath $(dir $(THISFILE))/../..) + +# Build directories +# Note that the debug directory is defined in relation to the release +# directory (BUILD_DIR), this needs to be kept in mind if over-riding +# it and building that widget types, the specific widget type variable +# (e.g. BUILD_DIR_DEBUG) may also need to be specified to yield the +# desired output hierarchy. +BUILD_DIR = $(ROOT_DIR)/build +BUILD_DIR_DEBUG = $(abspath $(BUILD_DIR)/../build-debug) + +# Output directory variable for use in pattern rules. +# This is intended for internal use only, hence the explicit override +# definition. +override OUTPUT_DIR = $(BUILD_DIR) + +# Final install directory for widgets +DEST = $(OUTPUT_DIR) + +# Default build type for release builds +BUILD_TYPE = release + +.PHONY: all help update install distclean +.PHONY: clean clean-release clean-debug clean-all +.PHONY: configure configure-release configure-debug +.PHONY: build build-release build-debug build-all +.PHONY: package package-release package-debug package-all + +help: + @echo "List of targets available:" + @echo "" + @echo "- all" + @echo "- help" + @echo "- clean" + @echo "- distclean" + @echo "- configure" + @echo "- build: compilation, link and prepare files for package into a widget" + @echo "- package: output a widget file '*.wgt'" + @echo "- install: install in $(DEST) directory" + @echo "" + @echo "Usage: ./autobuild/agl/autobuild package DEST=${HOME}/opt" + @echo "Don't use your build dir as DEST as wgt file is generated at this location" + +all: package-all + +# Target specific variable over-rides so static pattern rules can be +# used for the various type-specific targets. + +configure-debug build-debug package-debug clean-debug: OUTPUT_DIR = $(BUILD_DIR_DEBUG) +configure-debug build-debug package-debug: BUILD_TYPE = debug + +clean-release clean-debug: + @if [ -d $(OUTPUT_DIR) ]; then \ + $(MAKE) -C $(OUTPUT_DIR) $(CLEAN_ARGS) clean; \ + else \ + echo Nothing to clean; \ + fi + +clean: clean-release + +clean-all: clean-release clean-debug + +distclean: clean-all + +configure-release configure-debug: + @mkdir -p $(OUTPUT_DIR) + @if [ ! -f $(OUTPUT_DIR)/Makefile ]; then \ + (cd $(OUTPUT_DIR) && qmake CONFIG+=$(BUILD_TYPE) $(CONFIGURE_ARGS) $(ROOT_DIR)); \ + fi + +configure: configure-release + +build-release build-debug: build-%: configure-% + @$(MAKE) -C $(OUTPUT_DIR) $(BUILD_ARGS) all + +build: build-release + +build-all: build-release build-debug + +package-release package-debug: package-%: build-% + @cp $(OUTPUT_DIR)/package/*.wgt $(OUTPUT_DIR)/ + @if [ "$(abspath $(DEST))" != "$(abspath $(OUTPUT_DIR))" ]; then \ + mkdir -p $(DEST) && cp $(OUTPUT_DIR)/*.wgt $(DEST); \ + fi + + +package: package-release + +package-all: package-release package-debug + +install: build + @$(MAKE) -C $(BUILD_DIR) $(INSTALL_ARGS) install diff --git a/package/config.xml b/package/config.xml new file mode 100644 index 0000000..63d0d75 --- /dev/null +++ b/package/config.xml @@ -0,0 +1,13 @@ + + + homescreen-demo-ci + + + This is a demo application for homescreen-demo-ci + NONE + MIT + + + + + diff --git a/package/icon.svg b/package/icon.svg new file mode 100644 index 0000000..91661a7 --- /dev/null +++ b/package/icon.svg @@ -0,0 +1,279 @@ + + + +image/svg+xmlMULTIMEDIA + \ No newline at end of file diff --git a/package/package.pro b/package/package.pro new file mode 100644 index 0000000..eb177fa --- /dev/null +++ b/package/package.pro @@ -0,0 +1,27 @@ +DISTFILES = icon.svg config.xml + +copy_icon.target = $$OUT_PWD/root/icon.svg +copy_icon.depends = $$_PRO_FILE_PWD_/icon.svg +copy_icon.commands = $(COPY_FILE) \"$$replace(copy_icon.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_icon.target, /, $$QMAKE_DIR_SEP)\" +QMAKE_EXTRA_TARGETS += copy_icon +PRE_TARGETDEPS += $$copy_icon.target + +copy_config.target = $$OUT_PWD/root/config.xml +copy_config.depends = $$_PRO_FILE_PWD_/config.xml +copy_config.commands = $(COPY_FILE) \"$$replace(copy_config.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_config.target, /, $$QMAKE_DIR_SEP)\" +QMAKE_EXTRA_TARGETS += copy_config +PRE_TARGETDEPS += $$copy_config.target + +WGT_TYPE = +CONFIG(debug, debug|release) { + WGT_TYPE = -debug +} + +wgt.target = package +wgt.commands = wgtpkg-pack -f -o homescreen-demo-ci$${WGT_TYPE}.wgt root + +QMAKE_EXTRA_TARGETS += wgt + +deploy.files = homescreen-demo-ci.wgt +deploy.path = /usr/AGL/apps/autoinstall +INSTALLS += deploy diff --git a/shell.pro b/shell.pro new file mode 100644 index 0000000..c779949 --- /dev/null +++ b/shell.pro @@ -0,0 +1,7 @@ +TEMPLATE = subdirs + +load(configure) + +SUBDIRS = shell package + +package.depends += shell diff --git a/shell/README.md b/shell/README.md new file mode 100644 index 0000000..e69de29 diff --git a/shell/images/DividingLine.svg b/shell/images/DividingLine.svg new file mode 100644 index 0000000..788256c --- /dev/null +++ b/shell/images/DividingLine.svg @@ -0,0 +1,62 @@ + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/shell/images/critical.svg b/shell/images/critical.svg new file mode 100644 index 0000000..e2df6fc --- /dev/null +++ b/shell/images/critical.svg @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/shell/images/exclamation.svg b/shell/images/exclamation.svg new file mode 100644 index 0000000..c43ebdd --- /dev/null +++ b/shell/images/exclamation.svg @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + ! + + diff --git a/shell/images/images.qrc b/shell/images/images.qrc new file mode 100644 index 0000000..4b27259 --- /dev/null +++ b/shell/images/images.qrc @@ -0,0 +1,10 @@ + + + DividingLine.svg + critical.svg + exclamation.svg + information.svg + question.svg + + + diff --git a/shell/images/information.svg b/shell/images/information.svg new file mode 100644 index 0000000..44b0ef8 --- /dev/null +++ b/shell/images/information.svg @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + i + + diff --git a/shell/images/question.svg b/shell/images/question.svg new file mode 100644 index 0000000..7d55a46 --- /dev/null +++ b/shell/images/question.svg @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + ? + + diff --git a/shell/protocol/agl-shell.xml b/shell/protocol/agl-shell.xml new file mode 100644 index 0000000..5e31d98 --- /dev/null +++ b/shell/protocol/agl-shell.xml @@ -0,0 +1,117 @@ + + + + Copyright © 2019 Collabora, Ltd. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + + + + + + + + + + + + + + + + + + + + Tell the server that this client is ready to be shown. The server + will delay presentation during start-up until all shell clients are + ready to be shown, and will display a black screen instead. + This gives the client an oppurtunity to set up and configure several + surfaces into a coherent interface. + + The client that binds to this interface must send this request, otherwise + they may stall the compositor unnecessarily. + + If this request is called after the compositor has already finished + start-up, no operation is performed. + + + + + + Set the surface to act as the background of an output. After this + request, the server will immediately send a configure event with + the dimensions the client should use to cover the entire output. + + The surface must have a "desktop" surface role, as supported by + libweston-desktop. + + Only a single surface may be the background for any output. If a + background surface already exists, a protocol error is raised. + + + + + + + + Set the surface to act as a panel of an output. The 'edge' argument + says what edge of the output the surface will be anchored to. + After this request, the server will send a configure event with the + correponding width/height that the client should use, and 0 for the + other dimension. E.g. if the edge is 'top', the width will be the + output's width, and the height will be 0. + + The surface must have a "desktop" surface role, as supported by + libweston-desktop. + + The compositor will take the panel's window geometry into account when + positioning other windows, so the panels are not covered. + + XXX: What happens if e.g. both top and left are used at the same time? + Who gets to have the corner? + + Only a single surface may be the panel for an output's edge. If a + surface already exists on an edge, a protocol error is raised. + + + + + + + + + Asks the compositor to make a toplevel to become the current/focued + window for window management purposes. + + See xdg_toplevel.set_app_id from the xdg-shell protocol for a + description app_id. + + If multiple toplevels have the same app_id, the result is unspecified. + + XXX: Do we need feedback to say it didn't work? (e.g. client does + not exist) + + + + + + diff --git a/shell/qml/background.qml b/shell/qml/background.qml new file mode 100644 index 0000000..88b95c0 --- /dev/null +++ b/shell/qml/background.qml @@ -0,0 +1,11 @@ +import QtQuick 2.11 +import QtQuick.Window 2.11 + +Window { + id: background + width: Screen.width + height: Screen.height + flags: Qt.FramelessWindowHint + visible: true + color: '#fff000' +} diff --git a/shell/qml/bg.qml b/shell/qml/bg.qml new file mode 100644 index 0000000..9c8aedb --- /dev/null +++ b/shell/qml/bg.qml @@ -0,0 +1,27 @@ +import QtQuick 2.2 +import QtQuick.Window 2.11 +import QtQuick.Layouts 1.1 + +Window { + visible: true + flags: Qt.FramelessWindowHint + + //width: Screen.width + width: 300 + //height: Screen.height + height: 400 + + title: 'HomeScreen bg' + + color: 'red' + + property string appid: 'naq-activate' + + MouseArea { + anchors.fill: parent + onClicked: { + console.log('activating ' + appid) + shell.activate_app(Window.window, appid) + } + } +} diff --git a/shell/qml/bottom.qml b/shell/qml/bottom.qml new file mode 100644 index 0000000..088539a --- /dev/null +++ b/shell/qml/bottom.qml @@ -0,0 +1,13 @@ +import QtQuick 2.2 +import QtQuick.Window 2.11 +import QtQuick.Layouts 1.1 + +Window { + visible: true + flags: Qt.FramelessWindowHint + width: Screen.width + height: 216 + title: 'HomeScreen bottom' + + color: 'green' +} diff --git a/shell/qml/left.qml b/shell/qml/left.qml new file mode 100644 index 0000000..9d1a0c9 --- /dev/null +++ b/shell/qml/left.qml @@ -0,0 +1,13 @@ +import QtQuick 2.2 +import QtQuick.Window 2.11 +import QtQuick.Layouts 1.1 + +Window { + visible: true + flags: Qt.FramelessWindowHint + width: Screen.width * (240.0 / 768.0) + height: Screen.height + title: 'HomeScreen left' + + color: 'yellow' +} diff --git a/shell/qml/main.qml b/shell/qml/main.qml new file mode 100644 index 0000000..f0178a0 --- /dev/null +++ b/shell/qml/main.qml @@ -0,0 +1,12 @@ +import QtQuick 2.2 +import QtQuick.Window 2.11 +import QtQuick.Layouts 1.1 + +Window { + visible: true + flags: Qt.FramelessWindowHint + width: Screen.width + height: Screen.height + title: 'HomeScreen' + color: '#ff00ff00' +} diff --git a/shell/qml/qml.qrc b/shell/qml/qml.qrc new file mode 100644 index 0000000..3804b1b --- /dev/null +++ b/shell/qml/qml.qrc @@ -0,0 +1,9 @@ + + + bg.qml + top.qml + bottom.qml + left.qml + right.qml + + diff --git a/shell/qml/right.qml b/shell/qml/right.qml new file mode 100644 index 0000000..1202837 --- /dev/null +++ b/shell/qml/right.qml @@ -0,0 +1,13 @@ +import QtQuick 2.2 +import QtQuick.Window 2.11 +import QtQuick.Layouts 1.1 + +Window { + visible: true + flags: Qt.FramelessWindowHint + width: Screen.width * (240.0 / 768.0) + height: Screen.height + title: 'HomeScreen right' + + color: 'purple' +} diff --git a/shell/qml/top.qml b/shell/qml/top.qml new file mode 100644 index 0000000..22abcfb --- /dev/null +++ b/shell/qml/top.qml @@ -0,0 +1,13 @@ +import QtQuick 2.2 +import QtQuick.Window 2.11 +import QtQuick.Layouts 1.1 + +Window { + visible: true + flags: Qt.FramelessWindowHint + width: Screen.width + height: 216 + title: 'HomeScreen top' + + color: 'blue' +} diff --git a/shell/shell.pro b/shell/shell.pro new file mode 100644 index 0000000..ed22ce0 --- /dev/null +++ b/shell/shell.pro @@ -0,0 +1,22 @@ +TEMPLATE = app +TARGET = homescreen-demo-ci + +QT = qml quick dbus websockets gui-private +CONFIG += c++11 link_pkgconfig wayland-scanner +#DESTDIR = . +DESTDIR = $${OUT_PWD}/../package/root/bin +PKGCONFIG += wayland-client json-c + +CONFIG(release, debug|release) { + QMAKE_POST_LINK = $(STRIP) --strip-unneeded $(TARGET) +} + +SOURCES += src/main.cpp \ + src/shell.cpp + +HEADERS += src/shell.h + +RESOURCES += qml/qml.qrc images/images.qrc + +WAYLANDCLIENTSOURCES += \ + protocol/agl-shell.xml diff --git a/shell/src/main.cpp b/shell/src/main.cpp new file mode 100644 index 0000000..75cb6ec --- /dev/null +++ b/shell/src/main.cpp @@ -0,0 +1,191 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "wayland-agl-shell-client-protocol.h" +#include "shell.h" + +// QGuiApplication::platformNativeInterface + +static void global_add(void *data, struct wl_registry *reg, uint32_t name, + const char *interface, uint32_t) +{ + struct agl_shell **shell = static_cast(data); + + if (strcmp(interface, agl_shell_interface.name) == 0) { + *shell = static_cast( + wl_registry_bind(reg, name, &agl_shell_interface, 1) + ); + } +} + +static void global_remove(void *data, struct wl_registry *reg, uint32_t id) +{ + // Don't care + (void) data; + (void) reg; + (void) id; +} + +static const struct wl_registry_listener registry_listener = { + global_add, + global_remove, +}; + +wl_surface * +getWlSurface(QWindow *window) +{ + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + + //void *surf = QGuiApplication::platformNativeInterface()->nativeResourceForWindow("surface", window); + void *surf = native->nativeResourceForWindow("surface", window); + return static_cast(surf); +} + +struct wl_display * +getWlDisplay(void) +{ + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + + //void *display = QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("display"); + void *display = native->nativeResourceForIntegration("display"); + return static_cast(display); +} + +struct wl_compositor * +getWlCompositor(QWindow *window) +{ + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + + //void *compositor = QGuiApplication::platformNativeInterface()->nativeResourceForWindow("compositor", window); + void *compositor = native->nativeResourceForWindow("compositor", window); + return static_cast(compositor); +} + +struct wl_output * +getWlOutput(QWindow *window) +{ + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + + //void *output = QGuiApplication::platformNativeInterface()->nativeResourceForScreen("output", window->screen()); + void *output = native->nativeResourceForScreen("output", window->screen()); + return static_cast(output); +} + +struct wl_output * +getWlOutput(QScreen *screen) +{ + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + + //void *output = QGuiApplication::platformNativeInterface()->nativeResourceForScreen("output", window->screen()); + void *output = native->nativeResourceForScreen("output", screen); + return static_cast(output); +} + +static struct wl_surface * +create_component(QQmlComponent *comp, QScreen *screen) +{ + QObject *obj = comp->create(); + obj->setParent(screen); + + QWindow *win = qobject_cast(obj); + return getWlSurface(win); +} + + +int main(int argc, char *argv[]) +{ + setenv("QT_QPA_PLATFORM", "wayland", 1); + QGuiApplication app(argc, argv); + app.setDesktopFileName("homescreen-demo-ci"); + + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + struct agl_shell *agl_shell = nullptr; + + struct wl_display *wl; + struct wl_registry *registry; + + char *xdgdir = getenv("XDG_RUNTIME_DIR"); + if (xdgdir) { + qInfo() << "xdg runtime dir " << xdgdir; + } + + wl = static_cast(native->nativeResourceForIntegration("display")); + registry = wl_display_get_registry(wl); + + wl_registry_add_listener(registry, ®istry_listener, &agl_shell); + // Roundtrip to get all globals advertised by the compositor + wl_display_roundtrip(wl); + wl_registry_destroy(registry); + + // check if binding to agl shell worked + std::shared_ptr shell{agl_shell, agl_shell_destroy}; + + QQmlApplicationEngine engine; + QQmlContext *context = engine.rootContext(); + + context->setContextProperty("shell", new Shell(shell, &app)); + + QQmlComponent bg_comp(&engine, QUrl("qrc:/bg.qml")); + qInfo() << bg_comp.errors(); + + QQmlComponent top_comp(&engine, QUrl("qrc:/top.qml")); + qInfo() << top_comp.errors(); + + QQmlComponent bot_comp(&engine, QUrl("qrc:/bottom.qml")); + qInfo() << bot_comp.errors(); + + QQmlComponent left_comp(&engine, QUrl("qrc:/left.qml")); + qInfo() << left_comp.errors(); + + QQmlComponent right_comp(&engine, QUrl("qrc:/right.qml")); + qInfo() << right_comp.errors(); + + struct wl_surface *bg, *top, *bot; + struct wl_output *output; + + QScreen *screen = app.primaryScreen(); + qDebug() << "primary screen is " << screen->name(); + + if (qApp->screens().length() > 1) { + for (auto &ss: qApp->screens()) { + bg = create_component(&bg_comp, ss); + output = getWlOutput(ss); + qDebug() << "Seting background to screen " << ss->name(); + agl_shell_set_background(agl_shell, bg, output); + } + } else { + bg = create_component(&bg_comp, screen); + output = getWlOutput(screen); + qDebug() << "Seting background to screen " << screen->name(); + agl_shell_set_background(agl_shell, bg, output); + } + + top = create_component(&top_comp, screen); + bot = create_component(&bot_comp, screen); + + agl_shell_set_panel(agl_shell, bot, output, AGL_SHELL_EDGE_BOTTOM); + agl_shell_set_panel(agl_shell, top, output, AGL_SHELL_EDGE_TOP); + + /* need to wait a bit in order for qtwayland to start dispatching */ + QTimer::singleShot(500, [agl_shell](){ + agl_shell_ready(agl_shell); + }); + + return app.exec(); +} diff --git a/shell/src/shell.cpp b/shell/src/shell.cpp new file mode 100644 index 0000000..15e16c4 --- /dev/null +++ b/shell/src/shell.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019 Collabora Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "shell.h" +#include +#include + +void Shell::activate_app(QWindow *win, const QString &app_id) +{ + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + QScreen *screen = win->screen(); + struct wl_output *output; + + output = static_cast(native->nativeResourceForScreen( + "output", const_cast(screen) + )); + + agl_shell_activate_app(this->shell.get(), + app_id.toStdString().c_str(), output); +} diff --git a/shell/src/shell.h b/shell/src/shell.h new file mode 100644 index 0000000..34dc539 --- /dev/null +++ b/shell/src/shell.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019 Collabora Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SHELLHANDLER_H +#define SHELLHANDLER_H + +#include +#include +#include +#include +#include +#include "wayland-agl-shell-client-protocol.h" + +/* + * Basic type to wrap the agl_shell wayland object into a QObject, so that it + * can be used in callbacks from QML. + */ + +class Shell : public QObject +{ +Q_OBJECT + std::shared_ptr shell; + +public: + Shell(std::shared_ptr shell, QObject *parent = nullptr) : + QObject(parent), shell(shell) + {} +public slots: + void activate_app(QWindow *win, const QString &app_id); +}; + +#endif // SHELLHANDLER_H -- cgit 1.2.3-korg