X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=homescreen%2Fsrc%2Fmain.cpp;fp=homescreen%2Fsrc%2Fmain.cpp;h=5d7e36d66a83f61e9974bbb315d2769e181c4d94;hb=444b2a68a503caaf0d58729d8297ef179215e3c1;hp=674ef5dd4732029453f9d3387f3ff794c9b5c751;hpb=4c7852e6ff7fde510f4f11c21bec817583397951;p=apps%2Fhomescreen.git diff --git a/homescreen/src/main.cpp b/homescreen/src/main.cpp index 674ef5d..5d7e36d 100644 --- a/homescreen/src/main.cpp +++ b/homescreen/src/main.cpp @@ -210,112 +210,107 @@ find_screen(const char *screen_name) } 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(QPlatformNativeInterface *native, QQmlApplicationEngine *engine, + struct agl_shell *agl_shell, QScreen *screen) { - struct wl_surface *bg, *top, *bottom; + struct wl_surface *bg; struct wl_output *output; - QObject *qobj_bg, *qobj_top, *qobj_bottom; - QScreen *screen = nullptr; + int32_t x, y; + int32_t width, height; + QObject *qobj_bg; + QSize size = screen->size(); - if (is_demo && !embedded_panels) { - QQmlComponent bg_comp(engine, QUrl("qrc:/background_demo.qml")); - qInfo() << bg_comp.errors(); + // 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(); - QQmlComponent top_comp(engine, QUrl("qrc:/toppanel_demo.qml")); - qInfo() << top_comp.errors(); + bg = create_component(native, &bg_comp, screen, &qobj_bg); - QQmlComponent bot_comp(engine, QUrl("qrc:/bottompanel_demo.qml")); - qInfo() << bot_comp.errors(); + output = getWlOutput(native, screen); - 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() << "Normal mode - with single surface"; + qDebug() << "Setting homescreen to screen " << screen->name(); + agl_shell_set_background(agl_shell, bg, output); - /* engine.rootObjects() works only if we had a load() */ - StatusBarModel *statusBar = qobj_top->findChild("statusBar"); - if (statusBar) { - qDebug() << "got statusBar objectname, doing init()"; - statusBar->init(engine->rootContext()); - } + // 216 is the width size of the panel + x = 0; + y = 216; - qDebug() << "init debug mode"; - } else if (!embedded_panels) { - QQmlComponent bg_comp(engine, QUrl("qrc:/background.qml")); - qInfo() << bg_comp.errors(); + width = size.width(); + height = size.height() - (2 * y); - QQmlComponent top_comp(engine, QUrl("qrc:/toppanel.qml")); - qInfo() << top_comp.errors(); + qDebug() << "Using custom rectangle " << width << "x" << height + << "+" << x << "x" << y << " for activation"; + qDebug() << "Panels should be embedded the background surface"; - QQmlComponent bot_comp(engine, QUrl("qrc:/bottompanel.qml")); - qInfo() << bot_comp.errors(); +#ifdef AGL_SHELL_SET_ACTIVATE_REGION_SINCE_VERSION + agl_shell_set_activate_region(agl_shell, output, + x, y, width, height); +#endif +} - 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); +static void +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; - /* engine.rootObjects() works only if we had a load() */ - StatusBarModel *statusBar = qobj_top->findChild("statusBar"); - if (statusBar) { - qDebug() << "got statusBar objectname, doing init()"; - statusBar->init(engine->rootContext()); - } + QQmlComponent bg_comp(engine, QUrl("qrc:/background_demo.qml")); + qInfo() << bg_comp.errors(); - 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"; - } + QQmlComponent top_comp(engine, QUrl("qrc:/toppanel_demo.qml")); + qInfo() << top_comp.errors(); - if (!screen_name) - screen = qApp->primaryScreen(); - else - screen = find_screen(screen_name); + QQmlComponent bot_comp(engine, QUrl("qrc:/bottompanel_demo.qml")); + qInfo() << bot_comp.errors(); - if (!screen) { - qDebug() << "No outputs present in the system."; - return; + 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("statusBar"); + if (statusBar) { + qDebug() << "got statusBar objectname, doing init()"; + statusBar->init(engine->rootContext()); } - 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(); + 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); - x = 0; - y = 216; + qDebug() << "CI mode - with multiple surfaces"; +} - width = size.width(); - height = size.height() - (2 * y); +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; - qDebug() << "Using custom rectangle " << width << "x" << height - << "+" << x << "x" << y << " for activation"; - qDebug() << "Panels should be embedded the background surface"; + if (!screen_name) + screen = qApp->primaryScreen(); + else + screen = find_screen(screen_name); -#ifdef AGL_SHELL_SET_ACTIVATE_REGION_SINCE_VERSION - agl_shell_set_activate_region(agl_shell, output, - x, y, width, height); -#endif + if (!screen) { + qDebug() << "No outputs present in the system."; + return; + } + 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 @@ -404,10 +399,8 @@ int main(int argc, char *argv[]) // 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(); }