#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
+QScreen *
+find_screen(const char *screen_name)
+{
+ QList<QScreen *> screens = qApp->screens();
+ QScreen *found = nullptr;
+ QString qstr_name = QString::fromUtf8(screen_name, -1);
+
+ for (QScreen *xscreen : screens) {
+ if (qstr_name == xscreen->name()) {
+ found = xscreen;
+ break;
+ }
+ }
+
+ return found;
+}
+
struct shell_data {
struct agl_shell *shell;
HomescreenHandler *homescreenHandler;
}
}
+static void
+agl_shell_app_on_output(void *data, struct agl_shell *agl_shell,
+ const char *app_id, const char *output_name)
+{
+ struct shell_data *shell_data = static_cast<struct shell_data *>(data);
+ HomescreenHandler *homescreenHandler = shell_data->homescreenHandler;
+
+ if (!homescreenHandler)
+ return;
+
+ std::pair new_pending_app = std::pair(QString(app_id),
+ QString(output_name));
+ homescreenHandler->pending_app_list.push_back(new_pending_app);
+}
+
#ifdef AGL_SHELL_BOUND_OK_SINCE_VERSION
static const struct agl_shell_listener shell_listener = {
agl_shell_bound_ok,
agl_shell_bound_fail,
agl_shell_app_state,
+ agl_shell_app_on_output,
};
#endif
if (ver >= 2) {
shell_data->shell =
static_cast<struct agl_shell *>(
- wl_registry_bind(reg, name, &agl_shell_interface, MIN(4, ver)));
+ wl_registry_bind(reg, name, &agl_shell_interface, MIN(8, ver)));
#ifdef AGL_SHELL_BOUND_OK_SINCE_VERSION
agl_shell_add_listener(shell_data->shell, &shell_listener, data);
#endif
return getWlSurface(native, win);
}
-static QScreen *
-find_screen(const char *screen_name)
+
+static void
+load_agl_shell(QPlatformNativeInterface *native, QQmlApplicationEngine *engine,
+ struct agl_shell *agl_shell, QScreen *screen)
{
- QList<QScreen *> screens = qApp->screens();
- QScreen *found = nullptr;
- QString qstr_name = QString::fromUtf8(screen_name, -1);
+ struct wl_surface *bg;
+ struct wl_output *output;
+ int32_t x, y;
+ int32_t width, height;
+ QObject *qobj_bg;
+ QSize size = screen->size();
- for (QScreen *xscreen : screens) {
- if (qstr_name == xscreen->name()) {
- found = xscreen;
- break;
- }
- }
+ // this incorporates the panels directly, but in doing so, it
+ // would also need to specify an activation area the same area
+ // in order to void overlapping any new activation window
+ QQmlComponent bg_comp(engine, QUrl("qrc:/background_with_panels.qml"));
+ qInfo() << bg_comp.errors();
- return found;
+ bg = create_component(native, &bg_comp, screen, &qobj_bg);
+
+ output = getWlOutput(native, screen);
+
+ qDebug() << "Normal mode - with single surface";
+ qDebug() << "Setting homescreen to screen " << screen->name();
+ agl_shell_set_background(agl_shell, bg, output);
+
+ // 216 is the width size of the panel
+ x = 0;
+ y = 216;
+
+ width = size.width();
+ height = size.height() - (2 * y);
+
+ qDebug() << "Using custom rectangle " << width << "x" << height
+ << "+" << x << "x" << y << " for activation";
+ qDebug() << "Panels should be embedded the background surface";
+
+#ifdef AGL_SHELL_SET_ACTIVATE_REGION_SINCE_VERSION
+ agl_shell_set_activate_region(agl_shell, output,
+ x, y, width, height);
+#endif
}
static void
-load_agl_shell_app(QPlatformNativeInterface *native,
- QQmlApplicationEngine *engine,
- struct agl_shell *agl_shell,
- const char *screen_name, bool is_demo, bool embedded_panels)
+load_agl_shell_for_ci(QPlatformNativeInterface *native,
+ QQmlApplicationEngine *engine,
+ struct agl_shell *agl_shell, QScreen *screen)
{
struct wl_surface *bg, *top, *bottom;
struct wl_output *output;
QObject *qobj_bg, *qobj_top, *qobj_bottom;
- QScreen *screen = nullptr;
- if (is_demo && !embedded_panels) {
- QQmlComponent bg_comp(engine, QUrl("qrc:/background_demo.qml"));
- qInfo() << bg_comp.errors();
+ QQmlComponent bg_comp(engine, QUrl("qrc:/background_demo.qml"));
+ qInfo() << bg_comp.errors();
- QQmlComponent top_comp(engine, QUrl("qrc:/toppanel_demo.qml"));
- qInfo() << top_comp.errors();
+ QQmlComponent top_comp(engine, QUrl("qrc:/toppanel_demo.qml"));
+ qInfo() << top_comp.errors();
- QQmlComponent bot_comp(engine, QUrl("qrc:/bottompanel_demo.qml"));
- qInfo() << bot_comp.errors();
+ QQmlComponent bot_comp(engine, QUrl("qrc:/bottompanel_demo.qml"));
+ qInfo() << bot_comp.errors();
- top = create_component(native, &top_comp, screen, &qobj_top);
- bottom = create_component(native, &bot_comp, screen, &qobj_bottom);
- bg = create_component(native, &bg_comp, screen, &qobj_bg);
-
- /* engine.rootObjects() works only if we had a load() */
- StatusBarModel *statusBar = qobj_top->findChild<StatusBarModel *>("statusBar");
- if (statusBar) {
- qDebug() << "got statusBar objectname, doing init()";
- statusBar->init(engine->rootContext());
- }
+ top = create_component(native, &top_comp, screen, &qobj_top);
+ bottom = create_component(native, &bot_comp, screen, &qobj_bottom);
+ bg = create_component(native, &bg_comp, screen, &qobj_bg);
- qDebug() << "init debug mode";
- } else if (!embedded_panels) {
- QQmlComponent bg_comp(engine, QUrl("qrc:/background.qml"));
- qInfo() << bg_comp.errors();
+ /* engine.rootObjects() works only if we had a load() */
+ StatusBarModel *statusBar = qobj_top->findChild<StatusBarModel *>("statusBar");
+ if (statusBar) {
+ qDebug() << "got statusBar objectname, doing init()";
+ statusBar->init(engine->rootContext());
+ }
- QQmlComponent top_comp(engine, QUrl("qrc:/toppanel.qml"));
- qInfo() << top_comp.errors();
+ output = getWlOutput(native, screen);
- QQmlComponent bot_comp(engine, QUrl("qrc:/bottompanel.qml"));
- qInfo() << bot_comp.errors();
+ qDebug() << "Setting homescreen to screen " << screen->name();
- top = create_component(native, &top_comp, screen, &qobj_top);
- bottom = create_component(native, &bot_comp, screen, &qobj_bottom);
- bg = create_component(native, &bg_comp, screen, &qobj_bg);
+ agl_shell_set_background(agl_shell, bg, output);
+ agl_shell_set_panel(agl_shell, top, output, AGL_SHELL_EDGE_TOP);
+ agl_shell_set_panel(agl_shell, bottom, output, AGL_SHELL_EDGE_BOTTOM);
- /* engine.rootObjects() works only if we had a load() */
- StatusBarModel *statusBar = qobj_top->findChild<StatusBarModel *>("statusBar");
- if (statusBar) {
- qDebug() << "got statusBar objectname, doing init()";
- statusBar->init(engine->rootContext());
- }
+ qDebug() << "CI mode - with multiple surfaces";
+}
- qDebug() << "init normal mode";
- } else {
- // this incorporates the panels directly, but in doing so, it
- // would also need to specify an activation area the same area
- // in order to void overlapping any new activation window
- QQmlComponent bg_comp(engine, QUrl("qrc:/background_with_panels.qml"));
- qInfo() << bg_comp.errors();
-
- bg = create_component(native, &bg_comp, screen, &qobj_bg);
- qDebug() << "init embedded panels mode";
- }
+static void
+load_agl_shell_app(QPlatformNativeInterface *native, QQmlApplicationEngine *engine,
+ struct agl_shell *agl_shell, const char *screen_name, bool is_demo)
+{
+ QScreen *screen = nullptr;
if (!screen_name)
screen = qApp->primaryScreen();
return;
}
- qDebug() << "found primary screen " << qApp->primaryScreen()->name() <<
- "first screen " << qApp->screens().first()->name();
- output = getWlOutput(native, screen);
-
- qDebug() << "Setting homescreen to screen " << screen->name();
- agl_shell_set_background(agl_shell, bg, output);
-
- if (embedded_panels) {
- int32_t x, y;
- int32_t width, height;
- QSize size = screen->size();
-
- x = 0;
- y = 216;
-
- width = size.width();
- height = size.height() - (2 * y);
-
- qDebug() << "Using custom rectangle " << width << "x" << height
- << "+" << x << "x" << y << " for activation";
- qDebug() << "Panels should be embedded the background surface";
-
-#ifdef AGL_SHELL_SET_ACTIVATE_REGION_SINCE_VERSION
- agl_shell_set_activate_region(agl_shell, output,
- x, y, width, height);
-#endif
-
+ if (is_demo) {
+ load_agl_shell_for_ci(native, engine, agl_shell, screen);
} else {
- agl_shell_set_panel(agl_shell, top, output, AGL_SHELL_EDGE_TOP);
- agl_shell_set_panel(agl_shell, bottom, output, AGL_SHELL_EDGE_BOTTOM);
- qDebug() << "Setting regular panels";
+ load_agl_shell(native, engine, agl_shell, screen);
}
/* Delay the ready signal until after Qt has done all of its own setup
// We add it here even if we don't use it
context->setContextProperty("shell", aglShell);
- // Instead of loading main.qml we load one-by-one each of the QMLs,
- // divided now between several surfaces: panels, background.
load_agl_shell_app(native, &engine, shell_data.shell,
- screen_name, is_demo_val, is_embedded_panels);
+ screen_name, is_demo_val);
return app.exec();
}