From 705b9f1d37f96de491e616af3f9471e0881e11ba Mon Sep 17 00:00:00 2001 From: Alexey Shilov Date: Wed, 15 Jun 2011 14:19:59 +0300 Subject: [PATCH] Fixes: NB#263422 - Precached (QML) applications do not set WM_NAME window atom properly RevBy: Pertti Kellomaki --- debian/changelog | 1 + doc/limitations.dox | 53 +++++++++++++++++++ src/qdeclarativebooster/mdeclarativecache.cpp | 10 ++++ 3 files changed, 64 insertions(+) diff --git a/debian/changelog b/debian/changelog index f878c62..27dc2ce 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,7 @@ applauncherd (0.30.1) unstable; urgency=low * Changes: New functional tests added to check testability library is loaded by booster-m and booster-d * Changes: Deprecate MDeclarativeCache::applicationDirPath() and MDeclarativeCache::applicationFilePath(). * Changes: Modify test applications to use _exit(). + * Fixes: NB#263422 - Precached (QML) applications do not set WM_NAME window atom properly -- Pertti Kellomaki Wed, 8 Jun 2011 13:36:37 +0300 diff --git a/doc/limitations.dox b/doc/limitations.dox index 05dc026..e21f6ee 100644 --- a/doc/limitations.dox +++ b/doc/limitations.dox @@ -105,5 +105,58 @@ custom debug message handler and didn't uninstall it before exit. Splash screen functionality needs support from the \c mcompositor window manager. Versions after 0.9.6 include splash screen support. + +\section wm_class_value WM_CLASS value + +If application is started with m-booster but it creates its own MApplicationWindow based object +(e.g. MApplicationWindow derived class object or application has multiple windows), +current launcher implementation does not set correct value for WM_CLASS property of X window. +WM_CLASS property is used e.g. by Compositor as application name to notify user when application +gets stuck. + +Application should set correct WM_CLASS property by following way: + +\code +M_EXPORT int main(int argc, char **argv) +{ + MApplication *app = MComponentCache::mApplication(argc, argv); + + //don't use window from cache, create our own + MApplicationWindow *window = new myDerivedMApplicationWindow(); + +#ifdef Q_WS_X11 + // reinit WM_COMMAND X11 property + if (window) { + Display *display = QX11Info::display(); + if (display) { + XSetCommand(display, window->effectiveWinId(), argv, argc); + + // set correct WM_CLASS properties + QString appName = QFileInfo(argv[0]).fileName(); + QString appClass = appName.left(1).toUpper(); + if (appName.length() > 1) + appClass += appName.right(appName.length() - 1); + + // reserve memory for C strings + QByteArray arrName(appName.toLatin1()); + QByteArray arrClass(appClass.toLatin1()); + + XClassHint class_hint; + class_hint.res_name = arrName.data(); + class_hint.res_class = arrClass.data(); + + XSetClassHint(display, window->effectiveWinId(), &class_hint); + } + } +#endif + + // do application specific stuff + ... + + window->show(); + return app->exec(); +} +\endcode + */ diff --git a/src/qdeclarativebooster/mdeclarativecache.cpp b/src/qdeclarativebooster/mdeclarativecache.cpp index fcd2e6d..79d01b2 100644 --- a/src/qdeclarativebooster/mdeclarativecache.cpp +++ b/src/qdeclarativebooster/mdeclarativecache.cpp @@ -82,7 +82,17 @@ void MDeclarativeCachePrivate::populate() qApplicationInstance = new QApplication(initialArgc, initialArgv); } + bool default_widget_creation = QCoreApplication::testAttribute(Qt::AA_ImmediateWidgetCreation); + + if (!default_widget_creation) + { + QCoreApplication::setAttribute(Qt::AA_ImmediateWidgetCreation, true); + } + qDeclarativeViewInstance = new QDeclarativeView(); + + // restore default value + QCoreApplication::setAttribute(Qt::AA_ImmediateWidgetCreation, default_widget_creation); } QApplication* MDeclarativeCachePrivate::qApplication(int &argc, char **argv)