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 activate_app_by_screen(const QString &screen_name,
60 const QString &app_id,
61 const QString &app_data);
62 void deactivate_app(const QString &app_id);
63 void set_window_props(QWindow *win, const QString &app_id,
64 uint32_t props, int x, int y, int bx, int by,
65 int bwidth, int bheight);
69 application_id_event(void *data, struct agl_shell_desktop *agl_shell_desktop,
72 Shell *aglShell = static_cast<Shell *>(data);
73 (void) agl_shell_desktop;
75 qInfo() << "app_id: " << app_id;
77 // this ain't necessary in case the default policy API will activate
78 // applications by default (when they are started) but if that is not
79 // the case we can use this event handler to activate the application
80 // as this event is sent when the application is created (when the
81 // app surface is created that is)
82 QString qstr_app_id = QString::fromUtf8(app_id, -1);
83 aglShell->activate_app(nullptr, qstr_app_id, nullptr);
87 application_state_event(void *data, struct agl_shell_desktop *agl_shell_desktop,
88 const char *app_id, const char *app_data,
89 uint32_t app_state, uint32_t app_role)
92 (void) agl_shell_desktop;
99 #endif // SHELLDESKTOP_H