diff options
author | Marius Vlad <marius.vlad@collabora.com> | 2020-04-29 01:21:44 +0300 |
---|---|---|
committer | Marius Vlad <marius.vlad@collabora.com> | 2020-06-24 17:05:31 +0300 |
commit | 259c66b9ebde64e857f36d8d1d7050bec2e8f41d (patch) | |
tree | 5f4a7b28528785e077046487efcb8315093aae2c /launcher/src/shell-desktop.h | |
parent | aae3ab7da4a7f580f5840509646d5ce3f6f56a6a (diff) |
agl-compositor: New adaptation to using the agl-shell-desktop proto
Bug-AGL: SPEC-3447
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Change-Id: I3fc7375a7a8716cc1352658cfc194645bf7f638c
Diffstat (limited to 'launcher/src/shell-desktop.h')
-rw-r--r-- | launcher/src/shell-desktop.h | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/launcher/src/shell-desktop.h b/launcher/src/shell-desktop.h new file mode 100644 index 0000000..a8f3326 --- /dev/null +++ b/launcher/src/shell-desktop.h @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2020 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 SHELLDESKTOP_H +#define SHELLDESKTOP_H + +#include <QObject> +#include <QString> +#include <QScreen> +#include <QWindow> +#include <QDebug> +#include <memory> + + +#include "wayland-agl-shell-desktop-client-protocol.h" + +static void +application_id_event(void *data, struct agl_shell_desktop *agl_shell_desktop, + const char *app_id); +static void +application_state_event(void *data, struct agl_shell_desktop *agl_shell_desktop, + const char *app_id, const char *app_data, + uint32_t app_state, uint32_t app_role); + +static const struct agl_shell_desktop_listener agl_shell_desktop_listener = { + application_id_event, + application_state_event, +}; + +class Shell : public QObject +{ +Q_OBJECT + +public: + std::shared_ptr<struct agl_shell_desktop> shell; + Shell(std::shared_ptr<struct agl_shell_desktop> shell, QObject *parent = nullptr) : + QObject(parent), shell(shell) + { + struct agl_shell_desktop *agl_shell_desktop = shell.get(); + agl_shell_desktop_add_listener(agl_shell_desktop, + &agl_shell_desktop_listener, this); + } + +public slots: // calls out of qml into CPP + void activate_app(QWindow *win, const QString &app_id, const QString &app_data); + void deactivate_app(const QString &app_id); + void set_window_props(QWindow *win, const QString &app_id, + uint32_t props, int x, int y); +}; + +static void +application_id_event(void *data, struct agl_shell_desktop *agl_shell_desktop, + const char *app_id) +{ + Shell *aglShell = static_cast<Shell *>(data); + (void) agl_shell_desktop; + + qInfo() << "app_id: " << app_id; + + // this ain't necessary in case the default policy API will activate + // applications by default (when they are started) but if that is not + // the case we can use this event handler to activate the application + // as this event is sent when the application is created (when the + // app surface is created that is) + QString qstr_app_id = QString::fromUtf8(app_id, -1); + aglShell->activate_app(nullptr, qstr_app_id, nullptr); +} + +static void +application_state_event(void *data, struct agl_shell_desktop *agl_shell_desktop, + const char *app_id, const char *app_data, + uint32_t app_state, uint32_t app_role) +{ + (void) data; + (void) agl_shell_desktop; + (void) app_id; + (void) app_data; + (void) app_state; + (void) app_role; +} + +#endif // SHELLDESKTOP_H |