aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Berres <armin.berres@basyskom.de>2010-12-07 16:49:09 +0100
committerArmin Berres <armin.berres@basyskom.de>2010-12-09 17:31:06 +0100
commit8d1739f0eb365b3bd5ef7ef898a9128c96e6810d (patch)
treefa1b10bb99bb602e3f487953e3b5138e52f22fe9
parent51d394d2f25a83db648dc1d1c3abe1cea7442958 (diff)
Changes: allow nothing, pixmap or color as default background filling at app startup
RevBy: Peter Penz, Stanislav Ionascu Details: So far when running with the meego graphicssystem we fill all windows with a pixmap specified via the theming system. If no pixmap is found the window will be initialized with black. With this patch we do not fill with black but with the actual color set via the style. If an application does not want the background filling it can disable it with a CSS snippet like this: /---- MWindowStyle { x11-startup-pixmap: ; startup-fill-color: ; } MWindowStyle.Landscape { x11-startup-pixmap: ; startup-fill-color: ; } \---- This is interesting e.g. for all applications starting during boot to keep the framebuffer intact.
-rw-r--r--src/corelib/core/mgraphicssystemhelper.cpp4
-rw-r--r--src/corelib/style/mwindowstyle.h17
-rw-r--r--src/corelib/widgets/mwindow.cpp41
-rw-r--r--src/corelib/widgets/mwindow_p.h2
4 files changed, 34 insertions, 30 deletions
diff --git a/src/corelib/core/mgraphicssystemhelper.cpp b/src/corelib/core/mgraphicssystemhelper.cpp
index 5f29e9dc..6a1da182 100644
--- a/src/corelib/core/mgraphicssystemhelper.cpp
+++ b/src/corelib/core/mgraphicssystemhelper.cpp
@@ -128,8 +128,8 @@ void MGraphicsSystemHelper::switchToHardwareRendering(MWindow *window, QGLContex
{
#ifdef HAVE_MEEGOGRAPHICSSYSTEM
if (QMeeGoGraphicsSystemHelper::runningGraphicsSystemName() != QLatin1String("native")) {
- mDebug("MGraphicsSystemHelper") << "hardware rendering with meego enabled";
if (!QMeeGoGraphicsSystemHelper::isRunningMeeGo()) {
+ mDebug("MGraphicsSystemHelper") << "Switching to hardware rendering with meego graphicssystem";
QMeeGoGraphicsSystemHelper::switchToMeeGo();
}
*glContext = const_cast<QGLContext*>(QGLContext::currentContext());
@@ -257,7 +257,7 @@ bool MGraphicsSystemHelper::isRunningMeeGoCompatibleGraphicsSystem() {
bool MGraphicsSystemHelper::isRunningMeeGoGraphicsSystem() {
#ifdef HAVE_MEEGOGRAPHICSSYSTEM
- if (QMeeGoGraphicsSystemHelper::isRunningMeeGo()) {
+ if (QMeeGoGraphicsSystemHelper::runningGraphicsSystemName() == QLatin1String("meego")) {
return true;
}
#endif
diff --git a/src/corelib/style/mwindowstyle.h b/src/corelib/style/mwindowstyle.h
index 55d1d693..0f69fb03 100644
--- a/src/corelib/style/mwindowstyle.h
+++ b/src/corelib/style/mwindowstyle.h
@@ -23,6 +23,8 @@
#include <mstyle.h>
#include <QColor>
+class QPixmap;
+
//! \internal
/** \brief Defines a style for a MWindow class.
@@ -33,14 +35,19 @@ class MWindowStyle : public MStyle
M_STYLE_INTERNAL(MWindowStyle)
/*!
- \brief Sets the default background color when opening a window.
- */
- M_STYLE_ATTRIBUTE(QColor, backgroundColor, BackgroundColor)
+ Sets the default background color when opening a window. If
+ x11StartupPixmap is defined the color will be ignored.
+ */
+ M_STYLE_ATTRIBUTE(QColor, startupFillColor, StartupFillColor)
/*!
- \brief Sets the default background image when opening a window.
+ The pixmap used to initially fill the window before it is shown.
+ The pixmap needs to be an X11 pixmap, to ensure this make sure it has
+ forcex11 in its filename.
*/
- M_STYLE_ATTRIBUTE(QString, backgroundImage, BackgroundImage)
+ M_STYLE_PTR_ATTRIBUTE(QPixmap *, x11StartupPixmap, X11StartupPixmap)
+
+
};
class MWindowStyleContainer : public MStyleContainer
diff --git a/src/corelib/widgets/mwindow.cpp b/src/corelib/widgets/mwindow.cpp
index 9cf4f91b..6873e9ac 100644
--- a/src/corelib/widgets/mwindow.cpp
+++ b/src/corelib/widgets/mwindow.cpp
@@ -183,6 +183,10 @@ void MWindowPrivate::init()
q->setTranslucentBackground(false);
if (MApplication::fullScreen())
q->showFullScreen();
+
+ if (MApplication::softwareRendering() || MGraphicsSystemHelper::isRunningMeeGoCompatibleGraphicsSystem()) {
+ applyStartupWindowBackground();
+ }
}
void MWindowPrivate::initSoftwareViewport()
@@ -214,11 +218,6 @@ void MWindowPrivate::initGLViewport()
bool translucent = q->testAttribute(Qt::WA_TranslucentBackground);
MGraphicsSystemHelper::switchToHardwareRendering(q, &glContext);
-#ifdef HAVE_MEEGOGRAPHICSSYSTEM
- if (beforeFirstPaintEvent && !translucent) {
- applyWindowBackground();
- }
-#endif
if (translucent) {
QPalette palette;
@@ -363,11 +362,10 @@ void MWindowPrivate::appendVisibilityChangeMask()
XChangeWindowAttributes(QX11Info::display(), robustEffectiveWinId(), CWEventMask, &newAttributes);
}
-void MWindowPrivate::applyWindowBackground()
+void MWindowPrivate::applyStartupWindowBackground()
{
- Q_Q(const MWindow);
+ Q_Q(MWindow);
- const WId windowId = robustEffectiveWinId();
const MWindowStyle *style =
static_cast<const MWindowStyle *>(MTheme::style("MWindowStyle",
QString(), QString(), QString(),
@@ -377,21 +375,18 @@ void MWindowPrivate::applyWindowBackground()
return;
}
- const QString backgroundId = style->backgroundImage();
- if (backgroundId.isEmpty()) {
- // TODO: Mapping an arbitrary RGB-color to X11 requires some effort. Currently
- // black is used until it is decided whether using a color as background should
- // be supported.
- XSetWindowBackground(QX11Info::display(), windowId, BlackPixel(QX11Info::display(), QX11Info::appScreen()));
+ WId windowId = robustEffectiveWinId();
+ const QPixmap *startupPixmap = style->x11StartupPixmap();
+ const QColor startupFillColor = style->startupFillColor();
+ if (startupPixmap) {
+ XSetWindowBackgroundPixmap(QX11Info::display(), windowId, startupPixmap->handle());
+ } else if (startupFillColor.isValid()) {
+ XSetWindowBackground(QX11Info::display(), windowId,
+ QColormap::instance().pixel(startupFillColor));
} else {
- const QPixmap *background = MTheme::pixmap(backgroundId);
- if (background) {
- XSetWindowBackgroundPixmap(QX11Info::display(), windowId, background->handle());
- } else {
- mWarning("MWindow") << "No valid MWindowStyle::backgroundImage found";
- }
+ disableAutomaticBackgroundRepainting();
}
- XClearWindow(QX11Info::display(), windowId);
+
MTheme::releaseStyle(style);
}
#endif
@@ -792,6 +787,9 @@ void MWindow::setTranslucentBackground(bool enable)
// not in scratchbox and supposingly its a candidate for
// filing bug against Qt when confirmed
d->appendVisibilityChangeMask();
+ if (MApplication::softwareRendering() || MGraphicsSystemHelper::isRunningMeeGoCompatibleGraphicsSystem()) {
+ d->disableAutomaticBackgroundRepainting();
+ }
#endif
}
@@ -1387,7 +1385,6 @@ void MWindow::setVisible(bool visible)
Q_D(MWindow);
if (visible) {
-
// This effectively overrides call to show() when in
// prestarted state.
if (MApplication::isPrestarted()) {
diff --git a/src/corelib/widgets/mwindow_p.h b/src/corelib/widgets/mwindow_p.h
index fd567270..c785d2be 100644
--- a/src/corelib/widgets/mwindow_p.h
+++ b/src/corelib/widgets/mwindow_p.h
@@ -58,7 +58,7 @@ public:
#ifdef Q_WS_X11
void appendVisibilityChangeMask();
- void applyWindowBackground();
+ void applyStartupWindowBackground();
void setX11Property(const char *propertyName, qreal value);
qreal getX11Property(const char *propertyName) const;
void setX11PrestartProperty(bool set);