Add beginnings of kwincompositing config module, meant to replace kwintranslucency one

svn path=/trunk/KDE/kdebase/workspace/; revision=689947
This commit is contained in:
Rivo Laks 2007-07-19 16:20:05 +00:00
parent 56eeb84acc
commit 824f005f58
12 changed files with 387 additions and 15 deletions

View file

@ -65,7 +65,7 @@ namespace KWin
void Workspace::setupCompositing() void Workspace::setupCompositing()
{ {
#if defined( HAVE_XCOMPOSITE ) && defined( HAVE_XDAMAGE ) #if defined( HAVE_XCOMPOSITE ) && defined( HAVE_XDAMAGE )
if( !options->useTranslucency ) if( !options->useCompositing )
{ {
kDebug( 1212 ) << "Compositing is turned off in options" << endl; kDebug( 1212 ) << "Compositing is turned off in options" << endl;
return; return;
@ -87,17 +87,33 @@ void Workspace::setupCompositing()
cm_selection = new KSelectionOwner( selection_name ); cm_selection = new KSelectionOwner( selection_name );
connect( cm_selection, SIGNAL( lostOwnership()), SLOT( lostCMSelection())); connect( cm_selection, SIGNAL( lostOwnership()), SLOT( lostCMSelection()));
cm_selection->claim( true ); // force claiming cm_selection->claim( true ); // force claiming
char type = 'O';
CompositingType type = options->compositingMode;
if( getenv( "KWIN_COMPOSE" )) if( getenv( "KWIN_COMPOSE" ))
type = getenv( "KWIN_COMPOSE" )[ 0 ]; {
char c = getenv( "KWIN_COMPOSE" )[ 0 ];
switch( c )
{
case 'O':
type = OpenGLCompositing;
break;
case 'X':
type = XRenderCompositing;
break;
default:
kDebug( 1212 ) << "No compositing" << endl;
return;
}
}
switch( type ) switch( type )
{ {
case 'B': /*case 'B':
kDebug( 1212 ) << "X compositing" << endl; kDebug( 1212 ) << "X compositing" << endl;
scene = new SceneBasic( this ); scene = new SceneBasic( this );
break; // don't fall through (this is a testing one) break; // don't fall through (this is a testing one) */
#ifdef HAVE_OPENGL #ifdef HAVE_OPENGL
case 'O': case OpenGLCompositing:
kDebug( 1212 ) << "OpenGL compositing" << endl; kDebug( 1212 ) << "OpenGL compositing" << endl;
scene = new SceneOpenGL( this ); scene = new SceneOpenGL( this );
if( !scene->initFailed()) if( !scene->initFailed())
@ -107,7 +123,7 @@ void Workspace::setupCompositing()
// fall through, try XRender // fall through, try XRender
#endif #endif
#if defined(HAVE_XRENDER) && defined(HAVE_XFIXES) #if defined(HAVE_XRENDER) && defined(HAVE_XFIXES)
case 'X': case XRenderCompositing:
kDebug( 1212 ) << "XRender compositing" << endl; kDebug( 1212 ) << "XRender compositing" << endl;
scene = new SceneXrender( this ); scene = new SceneXrender( this );
break; break;

View file

@ -3,4 +3,5 @@ add_subdirectory( kwinoptions )
add_subdirectory( kwindecoration ) add_subdirectory( kwindecoration )
add_subdirectory( kwinrules ) add_subdirectory( kwinrules )
add_subdirectory( kwineffects ) add_subdirectory( kwineffects )
add_subdirectory( kwincompositing )

View file

@ -0,0 +1,14 @@
########### next target ###############
set(kcm_kwincompositing_PART_SRCS main.cpp )
kde4_add_ui_files(kcm_kwincompositing_PART_SRCS main.ui)
kde4_add_plugin(kcm_kwincompositing ${kcm_kwincompositing_PART_SRCS})
target_link_libraries(kcm_kwincompositing ${KDE4_KUTILS_LIBS})
install(TARGETS kcm_kwincompositing DESTINATION ${PLUGIN_INSTALL_DIR} )
########### install files ###############
install( FILES kwincompositing.desktop DESTINATION ${SERVICES_INSTALL_DIR} )

View file

@ -0,0 +1,2 @@
#! /usr/bin/env bash
$XGETTEXT *.cpp -o $podir/kcmkwincompositing.pot

View file

@ -0,0 +1,17 @@
[Desktop Entry]
Encoding=UTF-8
Exec=kcmshell kwincompositing
Icon=kcmcompositing
Type=Service
ServiceTypes=KCModule
DocPath=kcontrol/kwincompositing/index.html
X-KDE-Library=kcm_kwincompositing
X-KDE-FactoryName=kcm_kwincompositing
X-KDE-ParentApp=kcontrol
Name=Compositing
Comment=Configure window compositing
Keywords=kwin,window,manager,compositing,effect

View file

@ -0,0 +1,115 @@
/*****************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
You can Freely distribute this program under the GNU General Public
License. See the file "COPYING" for the exact licensing terms.
******************************************************************/
#include "main.h"
#include <kgenericfactory.h>
#include <kaboutdata.h>
#include <kconfig.h>
#include <kconfiggroup.h>
#include <kdebug.h>
#include <ksettings/dispatcher.h>
#include <QtDBus/QtDBus>
typedef KGenericFactory<KWin::KWinCompositingConfig> KWinCompositingConfigFactory;
K_EXPORT_COMPONENT_FACTORY( kcm_kwincompositing, KWinCompositingConfigFactory("kcmkwincompositing"))
namespace KWin
{
KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QStringList &)
: KCModule( KWinCompositingConfigFactory::componentData(), parent),
mKWinConfig(KSharedConfig::openConfig("kwinrc"))
{
ui.setupUi(this);
ui.compositingType->insertItem(0, i18n("OpenGL"));
ui.compositingType->insertItem(1, i18n("XRender"));
connect(ui.useCompositing, SIGNAL(toggled(bool)), ui.compositingOptionsContainer, SLOT(setEnabled(bool)));
connect(ui.useCompositing, SIGNAL(toggled(bool)), this, SLOT(changed()));
connect(ui.compositingType, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
// Load config
load();
KAboutData *about = new KAboutData(I18N_NOOP("kcmkwincompositing"), 0,
ki18n("KWin Compositing Configuration Module"),
0, KLocalizedString(), KAboutData::License_GPL, ki18n("(c) 2007 Rivo Laks"));
about->addAuthor(ki18n("Rivo Laks"), KLocalizedString(), "rivolaks@hot.ee");
setAboutData(about);
}
KWinCompositingConfig::~KWinCompositingConfig()
{
}
void KWinCompositingConfig::reparseConfiguration(const QByteArray&conf)
{
KSettings::Dispatcher::reparseConfiguration(conf);
}
void KWinCompositingConfig::load()
{
kDebug() << k_funcinfo << endl;
mKWinConfig->reparseConfiguration();
KConfigGroup config(mKWinConfig, "Compositing");
ui.useCompositing->setChecked(config.readEntry("Enabled", false));
QString backend = config.readEntry("Backend", "OpenGL");
ui.compositingType->setCurrentIndex((backend == "XRender") ? 1 : 0);
emit changed( false );
}
void KWinCompositingConfig::save()
{
kDebug() << k_funcinfo << endl;
KConfigGroup config(mKWinConfig, "Compositing");
config.writeEntry("Enabled", ui.useCompositing->isChecked());
config.writeEntry("Backend", (ui.compositingType->currentIndex() == 0) ? "OpenGL" : "XRender");
// TODO: save effects
emit changed( false );
// Send signal to kwin
mKWinConfig->sync();
// Send signal to all kwin instances
QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
QDBusConnection::sessionBus().send(message);
}
void KWinCompositingConfig::defaults()
{
kDebug() << k_funcinfo << endl;
ui.useCompositing->setChecked(false);
ui.compositingType->setCurrentIndex(0);
}
QString KWinCompositingConfig::quickHelp() const
{
kDebug() << k_funcinfo << endl;
return i18n("<h1>Compositing</h1>");
}
} // namespace
#include "main.moc"

View file

@ -0,0 +1,48 @@
/*****************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
You can Freely distribute this program under the GNU General Public
License. See the file "COPYING" for the exact licensing terms.
******************************************************************/
#ifndef __MAIN_H__
#define __MAIN_H__
#include <kcmodule.h>
#include <ksharedconfig.h>
#include "ui_main.h"
class KPluginSelector;
namespace KWin
{
class KWinCompositingConfig : public KCModule
{
Q_OBJECT
public:
KWinCompositingConfig(QWidget *parent, const QStringList &args);
virtual ~KWinCompositingConfig();
virtual QString quickHelp() const;
public slots:
virtual void load();
virtual void save();
virtual void defaults();
void reparseConfiguration(const QByteArray&conf);
private:
KSharedConfigPtr mKWinConfig;
Ui::KWinCompositingConfig ui;
};
} // namespace
#endif

View file

@ -0,0 +1,152 @@
<ui version="4.0" >
<class>KWinCompositingConfig</class>
<widget class="QWidget" name="KWinCompositingConfig" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>515</width>
<height>334</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QVBoxLayout" >
<item>
<widget class="QCheckBox" name="useCompositing" >
<property name="text" >
<string>Use compositing</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QWidget" native="1" name="compositingOptionsContainer" >
<layout class="QVBoxLayout" >
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Compositing type:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="compositingType" />
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string>Common effects</string>
</property>
<layout class="QVBoxLayout" >
<item>
<widget class="QCheckBox" name="effectShadows" >
<property name="text" >
<string>Shadows</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="effectPresentWindows" >
<property name="text" >
<string>PresentWindows</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="effectBoxSwitch" >
<property name="text" >
<string>Improved window switcher</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="effectDesktopGrid" >
<property name="text" >
<string>Improved desktop switcher</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label" >
<property name="text" >
<string>You can find more effects in the Effects config module</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>21</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>useCompositing</sender>
<signal>toggled(bool)</signal>
<receiver>compositingType</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>110</x>
<y>21</y>
</hint>
<hint type="destinationlabel" >
<x>324</x>
<y>50</y>
</hint>
</hints>
</connection>
<connection>
<sender>useCompositing</sender>
<signal>toggled(bool)</signal>
<receiver>groupBox</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>78</x>
<y>20</y>
</hint>
<hint type="destinationlabel" >
<x>90</x>
<y>86</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -177,9 +177,15 @@ unsigned long Options::updateSettings()
CmdAll3 = mouseCommand(config.readEntry("CommandAll3","Resize"), false ); CmdAll3 = mouseCommand(config.readEntry("CommandAll3","Resize"), false );
CmdAllWheel = mouseWheelCommand(config.readEntry("CommandAllWheel","Nothing")); CmdAllWheel = mouseWheelCommand(config.readEntry("CommandAllWheel","Nothing"));
//translucency settings - TODO // Compositing settings
config.changeGroup("Compositing");
useCompositing = config.readEntry("Enabled", true);
QString compositingBackend = config.readEntry("Backend", "OpenGL");
if( compositingBackend == "XRender" )
compositingMode = XRenderCompositing;
else
compositingMode = OpenGLCompositing;
config.changeGroup("Translucency"); config.changeGroup("Translucency");
useTranslucency = config.readEntry("UseTranslucency", false);
refreshRate = config.readEntry( "RefreshRate", 0 ); refreshRate = config.readEntry( "RefreshRate", 0 );
smoothScale = qBound( -1, config.readEntry( "SmoothScale", -1 ), 2 ); smoothScale = qBound( -1, config.readEntry( "SmoothScale", -1 ), 2 );

View file

@ -289,8 +289,9 @@ class Options : public KDecorationOptions
// Whether to hide utility windows for inactive applications. // Whether to hide utility windows for inactive applications.
bool hideUtilityWindowsForInactive; bool hideUtilityWindowsForInactive;
//translucency settings // Compositing settings
bool useTranslucency; bool useCompositing;
CompositingType compositingMode;
HiddenPreviews hiddenPreviews; HiddenPreviews hiddenPreviews;
uint refreshRate; uint refreshRate;

View file

@ -109,7 +109,7 @@ QMenu* Workspace::clientPopup()
action = popup->addMenu( advanced_popup ); action = popup->addMenu( advanced_popup );
action->setText( i18n("Ad&vanced") ); action->setText( i18n("Ad&vanced") );
if (options->useTranslucency){ if (options->useCompositing){
trans_popup = new QMenu( popup ); trans_popup = new QMenu( popup );
trans_popup->setFont(KGlobalSettings::menuFont()); trans_popup->setFont(KGlobalSettings::menuFont());
connect( trans_popup, SIGNAL( triggered(QAction*) ), this, SLOT( setPopupClientOpacity(QAction*))); connect( trans_popup, SIGNAL( triggered(QAction*) ), this, SLOT( setPopupClientOpacity(QAction*)));
@ -222,7 +222,7 @@ void Workspace::clientPopupAboutToShow()
mNoBorderOpAction->setChecked( active_popup_client->noBorder() ); mNoBorderOpAction->setChecked( active_popup_client->noBorder() );
mMinimizeOpAction->setEnabled( active_popup_client->isMinimizable() ); mMinimizeOpAction->setEnabled( active_popup_client->isMinimizable() );
mCloseOpAction->setEnabled( active_popup_client->isCloseable() ); mCloseOpAction->setEnabled( active_popup_client->isCloseable() );
if (options->useTranslucency) if (options->useCompositing)
{ {
foreach( QAction* action, trans_popup->actions()) foreach( QAction* action, trans_popup->actions())
{ {

View file

@ -1040,7 +1040,7 @@ void Workspace::slotReconfigure()
updateCurrentTopMenu(); updateCurrentTopMenu();
} }
if( options->useTranslucency ) if( options->useCompositing )
{ {
setupCompositing(); setupCompositing();
if( effects ) // setupCompositing() may fail if( effects ) // setupCompositing() may fail
@ -1130,7 +1130,7 @@ QStringList Workspace::configModules(bool controlCenter)
if (controlCenter) if (controlCenter)
args << "kde-kwinoptions.desktop"; args << "kde-kwinoptions.desktop";
else if (KAuthorized::authorizeControlModule("kde-kwinoptions.desktop")) else if (KAuthorized::authorizeControlModule("kde-kwinoptions.desktop"))
args << "kwinactions" << "kwinfocus" << "kwinmoving" << "kwinadvanced" << "kwinrules" << "kwintranslucency" << "kwineffects"; args << "kwinactions" << "kwinfocus" << "kwinmoving" << "kwinadvanced" << "kwinrules" << "kwincompositing" << "kwineffects";
return args; return args;
} }