Skip to content

Commit

Permalink
[lipstick] Send different kinds of home ready signals only when Lipst…
Browse files Browse the repository at this point in the history
…ick content is actually on screen
  • Loading branch information
Vesa Halttunen committed Oct 2, 2013
1 parent 1259cc9 commit bc5bd72
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 8 deletions.
1 change: 1 addition & 0 deletions rpm/lipstick-qt5.spec
Expand Up @@ -36,6 +36,7 @@ BuildRequires: pkgconfig(libresourceqt5)
BuildRequires: pkgconfig(ngf-qt5)
BuildRequires: pkgconfig(qmsystem2-qt5) >= 1.4.11
BuildRequires: pkgconfig(contextkit-statefs) >= 0.2.7
BuildRequires: pkgconfig(systemd)
BuildRequires: qt5-qttools-linguist
BuildRequires: qt5-qtwayland-wayland_egl-devel >= 5.1.0+git7
BuildRequires: doxygen
Expand Down
1 change: 1 addition & 0 deletions rpm/lipstick-qt5.yaml
Expand Up @@ -27,6 +27,7 @@ PkgConfigBR:
- ngf-qt5
- qmsystem2-qt5 >= 1.4.11
- contextkit-statefs >= 0.2.7
- systemd
PkgBR:
- qt5-qttools-linguist
- qt5-qtwayland-wayland_egl-devel >= 5.1.0+git7
Expand Down
3 changes: 2 additions & 1 deletion src/devicelock/devicelock.cpp
Expand Up @@ -13,6 +13,7 @@
**
****************************************************************************/

#include <QCoreApplication>
#include <QSettings>
#include <QProcess>
#include <QTimer>
Expand All @@ -35,7 +36,7 @@ DeviceLock::DeviceLock(QObject * parent) :
connect(qmLocks, SIGNAL(stateChanged(MeeGo::QmLocks::Lock,MeeGo::QmLocks::State)), this, SLOT(setStateAndSetupLockTimer()));
connect(qmDisplayState, SIGNAL(displayStateChanged(MeeGo::QmDisplayState::DisplayState)), this, SLOT(checkDisplayState(MeeGo::QmDisplayState::DisplayState)));

QTimer::singleShot(0, this, SLOT(init()));
connect(qApp, SIGNAL(homeReady()), this, SLOT(init()));
}

void DeviceLock::init()
Expand Down
30 changes: 24 additions & 6 deletions src/homeapplication.cpp
Expand Up @@ -22,6 +22,7 @@
#include <QDebug>
#include <QEvent>
#include <QtGui/qpa/qplatformnativeinterface.h>
#include <systemd/sd-daemon.h>

#include "notifications/notificationmanager.h"
#include "notifications/notificationpreviewpresenter.h"
Expand Down Expand Up @@ -64,6 +65,7 @@ HomeApplication::HomeApplication(int &argc, char **argv, const QString &qmlPath)
, originalSigIntHandler(signal(SIGINT, quitSignalHandler))
, originalSigTermHandler(signal(SIGTERM, quitSignalHandler))
, updatesEnabled(true)
, homeReadySent(false)
{
setApplicationName("Lipstick");
// TODO: autogenerate this from tags
Expand All @@ -76,9 +78,6 @@ HomeApplication::HomeApplication(int &argc, char **argv, const QString &qmlPath)
translator->load(QLocale(), "lipstick", "-", "/usr/share/translations");
installTranslator(translator);

// launch a timer for sending a dbus-signal upstart when basic construct is done
QTimer::singleShot(0, this, SLOT(sendStartupNotifications()));

// Initialize the QML engine
qmlEngine = new QQmlEngine(this);

Expand Down Expand Up @@ -132,6 +131,8 @@ HomeApplication::HomeApplication(int &argc, char **argv, const QString &qmlPath)
if (!sessionBus.registerObject(SCREENSHOT_DBUS_PATH, screenshotService)) {
qWarning("Unable to register screenshot object at path %s: %s", SCREENSHOT_DBUS_PATH, sessionBus.lastError().message().toUtf8().constData());
}

connect(this, SIGNAL(homeReady()), this, SLOT(sendStartupNotifications()));
}

HomeApplication::~HomeApplication()
Expand All @@ -153,6 +154,16 @@ void HomeApplication::restoreSignalHandlers()
signal(SIGTERM, originalSigTermHandler);
}

void HomeApplication::sendHomeReadySignalIfNotAlreadySent()
{
if (!homeReadySent) {
homeReadySent = true;
disconnect(LipstickCompositor::instance(), SIGNAL(frameSwapped()), this, SLOT(sendHomeReadySignalIfNotAlreadySent()));

emit homeReady();
}
}

void HomeApplication::sendStartupNotifications()
{
static QDBusConnection systemBus = QDBusConnection::systemBus();
Expand All @@ -162,9 +173,13 @@ void HomeApplication::sendStartupNotifications()
"ready");
systemBus.send(homeReadySignal);

// For device boot performance reasons initializing Home scene window must be done
// only after ready signal is sent.
mainWindowInstance()->showFullScreen();
/* Let systemd know that we are initialized */
if (arguments().indexOf("--systemd") >= 0) {
sd_notify(0, "READY=1");
}

/* Let timed know that the UI is up */
systemBus.call(QDBusMessage::createSignal("/com/nokia/startup/signal", "com.nokia.startup.signal", "desktop_visible"), QDBus::NoBlock);
}

bool HomeApplication::homeActive() const
Expand Down Expand Up @@ -197,6 +212,9 @@ void HomeApplication::setQmlPath(const QString &path)
if (_mainWindowInstance->hasErrors()) {
qWarning() << "HomeApplication: Errors while loading" << path;
qWarning() << _mainWindowInstance->errors();
} else {
_mainWindowInstance->showFullScreen();
connect(LipstickCompositor::instance(), SIGNAL(frameSwapped()), this, SLOT(sendHomeReadySignalIfNotAlreadySent()));
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/homeapplication.h
Expand Up @@ -108,10 +108,20 @@ class LIPSTICK_EXPORT HomeApplication : public QGuiApplication
*/
void homeActiveChanged();

/*!
* Emitted when the home screen has been drawn on screen for the first time.
*/
void homeReady();

protected:
virtual bool event(QEvent *);

private slots:
/*!
* Emits the homeReady() signal unless it has already been sent
*/
void sendHomeReadySignalIfNotAlreadySent();

/*!
* Sends a dbus-signal after UI is visible, stops the process if it has
* been started by upstart
Expand Down Expand Up @@ -153,6 +163,9 @@ private slots:

//! Whether user interface updates should be enabled or not
bool updatesEnabled;

//! Whether the home ready signal has been sent or not
bool homeReadySent;
};

#endif /* HOMEAPPLICATION_H_ */
2 changes: 1 addition & 1 deletion src/src.pro
Expand Up @@ -99,7 +99,7 @@ SOURCES += \

CONFIG += link_pkgconfig mobility qt warn_on depend_includepath qmake_cache target_qt
CONFIG -= link_prl
PKGCONFIG += mlite5 mce dbus-1 dbus-glib-1 libresourceqt5 ngf-qt5 qmsystem2-qt5 Qt5SystemInfo
PKGCONFIG += mlite5 mce dbus-1 dbus-glib-1 libresourceqt5 ngf-qt5 qmsystem2-qt5 Qt5SystemInfo libsystemd-daemon

packagesExist(contentaction5) {
message("Using contentaction to launch applications")
Expand Down

0 comments on commit bc5bd72

Please sign in to comment.