make Theme react to compositing changes
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=771968
This commit is contained in:
parent
ce3e58d2b4
commit
2a051a9315
35
theme.cpp
35
theme.cpp
@ -21,11 +21,13 @@
|
|||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QX11Info>
|
||||||
|
|
||||||
#include <KWindowSystem>
|
#include <KWindowSystem>
|
||||||
#include <KColorScheme>
|
#include <KColorScheme>
|
||||||
#include <KConfigGroup>
|
#include <KConfigGroup>
|
||||||
#include <KDebug>
|
#include <KDebug>
|
||||||
|
#include <KSelectionWatcher>
|
||||||
#include <KSharedConfig>
|
#include <KSharedConfig>
|
||||||
#include <KStandardDirs>
|
#include <KStandardDirs>
|
||||||
|
|
||||||
@ -55,6 +57,10 @@ public:
|
|||||||
QString app;
|
QString app;
|
||||||
KSharedConfigPtr colors;
|
KSharedConfigPtr colors;
|
||||||
QFont generalFont;
|
QFont generalFont;
|
||||||
|
bool compositingActive;
|
||||||
|
#ifdef Q_WS_X11
|
||||||
|
KSelectionWatcher *compositeWatch;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
class ThemeSingleton
|
class ThemeSingleton
|
||||||
@ -75,6 +81,15 @@ Theme::Theme(QObject* parent)
|
|||||||
d(new Private)
|
d(new Private)
|
||||||
{
|
{
|
||||||
settingsChanged();
|
settingsChanged();
|
||||||
|
d->compositingActive = KWindowSystem::compositingActive();
|
||||||
|
|
||||||
|
#ifdef Q_WS_X11
|
||||||
|
char net_wm_cm_name[100];
|
||||||
|
sprintf(net_wm_cm_name, "_NET_WM_CM_S%d", DefaultScreen(QX11Info::display()));
|
||||||
|
d->compositeWatch = new KSelectionWatcher(net_wm_cm_name, -1, this);
|
||||||
|
connect(d->compositeWatch, SIGNAL(newOwner(Window)), this, SLOT(compositingChanged()));
|
||||||
|
connect(d->compositeWatch, SIGNAL(lostOwner()), this, SLOT(compositingChanged()));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Theme::~Theme()
|
Theme::~Theme()
|
||||||
@ -96,6 +111,18 @@ void Theme::settingsChanged()
|
|||||||
setThemeName(d->config().readEntry("name", "default"));
|
setThemeName(d->config().readEntry("name", "default"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Theme::compositingChanged()
|
||||||
|
{
|
||||||
|
#ifdef Q_WS_X11
|
||||||
|
bool compositingActive = d->compositeWatch->owner() != None;
|
||||||
|
|
||||||
|
if (d->compositingActive != compositingActive) {
|
||||||
|
d->compositingActive = compositingActive;
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void Theme::setThemeName(const QString &themeName)
|
void Theme::setThemeName(const QString &themeName)
|
||||||
{
|
{
|
||||||
QString theme = themeName;
|
QString theme = themeName;
|
||||||
@ -142,13 +169,9 @@ QString Theme::themeName() const
|
|||||||
|
|
||||||
QString Theme::image( const QString& name ) const
|
QString Theme::image( const QString& name ) const
|
||||||
{
|
{
|
||||||
//TODO: performance ... should we try and cache the results of KStandardDirs::locate?
|
|
||||||
// should we just use whatever theme path was returned and not care about cascades?
|
|
||||||
// (probably "no" on the last question)
|
|
||||||
QString search;
|
QString search;
|
||||||
QString path;
|
QString path;
|
||||||
bool compositingActive = KWindowSystem::compositingActive();
|
if (!d->compositingActive) {
|
||||||
if (!compositingActive) {
|
|
||||||
search = "desktoptheme/" + d->themeName + "/opaque/" + name + ".svg";
|
search = "desktoptheme/" + d->themeName + "/opaque/" + name + ".svg";
|
||||||
path = KStandardDirs::locate( "data", search );
|
path = KStandardDirs::locate( "data", search );
|
||||||
}
|
}
|
||||||
@ -160,7 +183,7 @@ QString Theme::image( const QString& name ) const
|
|||||||
|
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
if (d->themeName != "default") {
|
if (d->themeName != "default") {
|
||||||
if (!compositingActive) {
|
if (!d->compositingActive) {
|
||||||
search = "desktoptheme/default/opaque/" + name + ".svg";
|
search = "desktoptheme/default/opaque/" + name + ".svg";
|
||||||
path = KStandardDirs::locate("data", search);
|
path = KStandardDirs::locate("data", search);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user