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 #include <QGuiApplication>
19 #include "shell-desktop.h"
20 #include <qpa/qplatformnativeinterface.h>
23 static struct wl_output *
24 getWlOutput(QScreen *screen)
26 QPlatformNativeInterface *native = qApp->platformNativeInterface();
27 void *output = native->nativeResourceForScreen("output", screen);
28 return static_cast<struct ::wl_output*>(output);
32 Shell::activate_app(QWindow *win, const QString &app_id,
33 const QString &app_data)
35 QScreen *screen = nullptr;
36 struct wl_output *output;
38 if (!win || !win->screen()) {
39 screen = qApp->screens().first();
41 screen = win->screen();
47 output = getWlOutput(screen);
48 qDebug() << "will activate app: " << app_id;
49 agl_shell_desktop_activate_app(this->shell.get(),
50 app_id.toStdString().c_str(),
51 app_data.toStdString().c_str(), output);
55 Shell::deactivate_app(const QString &app_id)
57 agl_shell_desktop_deactivate_app(this->shell.get(),
58 app_id.toStdString().c_str());
62 Shell::set_window_props(QWindow *win, const QString &app_id,
63 uint32_t props, int x, int y)
65 QScreen *screen = nullptr;
66 struct wl_output *output;
68 if (!win || !win->screen()) {
69 screen = qApp->screens().first();
71 screen = win->screen();
78 output = getWlOutput(screen);
79 agl_shell_desktop_set_app_property(this->shell.get(),
80 app_id.toStdString().c_str(),