2 * Copyright (c) 2020 Collabora Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef SHELLDESKTOP_H
18 #define SHELLDESKTOP_H
28 #include "wayland-agl-shell-desktop-client-protocol.h"
31 application_id_event(void *data, struct agl_shell_desktop *agl_shell_desktop,
34 application_state_event(void *data, struct agl_shell_desktop *agl_shell_desktop,
35 const char *app_id, const char *app_data,
36 uint32_t app_state, uint32_t app_role);
38 static const struct agl_shell_desktop_listener agl_shell_desktop_listener = {
40 application_state_event,
43 class Shell : public QObject
48 std::shared_ptr<struct agl_shell_desktop> shell;
49 Shell(std::shared_ptr<struct agl_shell_desktop> shell, QObject *parent = nullptr) :
50 QObject(parent), shell(shell)
52 struct agl_shell_desktop *agl_shell_desktop = shell.get();
53 agl_shell_desktop_add_listener(agl_shell_desktop,
54 &agl_shell_desktop_listener, this);
57 public slots: // calls out of qml into CPP
58 void activate_app(QWindow *win, const QString &app_id, const QString &app_data);
59 void deactivate_app(const QString &app_id);
60 void set_window_props(QWindow *win, const QString &app_id,
61 uint32_t props, int x, int y);
65 application_id_event(void *data, struct agl_shell_desktop *agl_shell_desktop,
68 Shell *aglShell = static_cast<Shell *>(data);
69 (void) agl_shell_desktop;
71 qInfo() << "app_id: " << app_id;
73 // this ain't necessary in case the default policy API will activate
74 // applications by default (when they are started) but if that is not
75 // the case we can use this event handler to activate the application
76 // as this event is sent when the application is created (when the
77 // app surface is created that is)
78 QString qstr_app_id = QString::fromUtf8(app_id, -1);
79 aglShell->activate_app(nullptr, qstr_app_id, nullptr);
83 application_state_event(void *data, struct agl_shell_desktop *agl_shell_desktop,
84 const char *app_id, const char *app_data,
85 uint32_t app_state, uint32_t app_role)
88 (void) agl_shell_desktop;
95 #endif // SHELLDESKTOP_H