diff --git a/lib/kwineffects.cpp b/lib/kwineffects.cpp index 204c4044c..a4a3de4a3 100644 --- a/lib/kwineffects.cpp +++ b/lib/kwineffects.cpp @@ -1,656 +1,656 @@ /***************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2006 Lubos Lunak You can Freely distribute this program under the GNU General Public License. See the file "COPYING" for the exact licensing terms. ******************************************************************/ #include "kwineffects.h" #include "kwinglutils.h" #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_XRENDER #include #endif namespace KWin { void WindowPrePaintData::setTranslucent() { mask |= Effect::PAINT_WINDOW_TRANSLUCENT; mask &= ~Effect::PAINT_WINDOW_OPAQUE; clip = QRegion(); // cannot clip, will be transparent } void WindowPrePaintData::setTransformed() { mask |= Effect::PAINT_WINDOW_TRANSFORMED; } WindowPaintData::WindowPaintData( EffectWindow* w ) : opacity( w->opacity()) , contents_opacity( 1.0 ) , decoration_opacity( 1.0 ) , xScale( 1 ) , yScale( 1 ) , xTranslate( 0 ) , yTranslate( 0 ) , saturation( 1 ) , brightness( 1 ) , shader( NULL ) { quads = w->buildQuads(); } ScreenPaintData::ScreenPaintData() : xScale( 1 ) , yScale( 1 ) , xTranslate( 0 ) , yTranslate( 0 ) { } //**************************************** // Effect //**************************************** Effect::Effect() { } Effect::~Effect() { } void Effect::windowUserMovedResized( EffectWindow* , bool, bool ) { } void Effect::windowOpacityChanged( EffectWindow*, double ) { } void Effect::windowAdded( EffectWindow* ) { } void Effect::windowClosed( EffectWindow* ) { } void Effect::windowDeleted( EffectWindow* ) { } void Effect::windowActivated( EffectWindow* ) { } void Effect::windowMinimized( EffectWindow* ) { } void Effect::windowUnminimized( EffectWindow* ) { } void Effect::windowInputMouseEvent( Window, QEvent* ) { } void Effect::grabbedKeyboardEvent( QKeyEvent* ) { } void Effect::desktopChanged( int ) { } void Effect::windowDamaged( EffectWindow*, const QRect& ) { } void Effect::windowGeometryShapeChanged( EffectWindow*, const QRect& ) { } void Effect::tabBoxAdded( int ) { } void Effect::tabBoxClosed() { } void Effect::tabBoxUpdated() { } bool Effect::borderActivated( ElectricBorder ) { return false; } void Effect::mouseChanged( const QPoint&, const QPoint&, Qt::MouseButtons, Qt::KeyboardModifiers ) { } void Effect::prePaintScreen( ScreenPrePaintData& data, int time ) { effects->prePaintScreen( data, time ); } void Effect::paintScreen( int mask, QRegion region, ScreenPaintData& data ) { effects->paintScreen( mask, region, data ); } void Effect::postPaintScreen() { effects->postPaintScreen(); } void Effect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ) { effects->prePaintWindow( w, data, time ); } void Effect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) { effects->paintWindow( w, mask, region, data ); } void Effect::postPaintWindow( EffectWindow* w ) { effects->postPaintWindow( w ); } void Effect::drawWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) { effects->drawWindow( w, mask, region, data ); } QRect Effect::transformWindowDamage( EffectWindow* w, const QRect& r ) { return effects->transformWindowDamage( w, r ); } void Effect::setPositionTransformations( WindowPaintData& data, QRect& region, EffectWindow* w, const QRect& r, Qt::AspectRatioMode aspect ) { QSize size = w->size(); size.scale( r.size(), aspect ); data.xScale = size.width() / double( w->width()); data.yScale = size.height() / double( w->height()); int width = int( w->width() * data.xScale ); int height = int( w->height() * data.yScale ); int x = r.x() + ( r.width() - width ) / 2; int y = r.y() + ( r.height() - height ) / 2; region = QRect( x, y, width, height ); data.xTranslate = x - w->x(); data.yTranslate = y - w->y(); } int Effect::displayWidth() { return KWin::displayWidth(); } int Effect::displayHeight() { return KWin::displayHeight(); } QPoint Effect::cursorPos() { return effects->cursorPos(); } //**************************************** // EffectsHandler //**************************************** EffectsHandler::EffectsHandler(CompositingType type) : current_paint_screen( 0 ) , current_paint_window( 0 ) , current_draw_window( 0 ) , current_transform( 0 ) , compositing_type( type ) { if( compositing_type == NoCompositing ) return; KWin::effects = this; } EffectsHandler::~EffectsHandler() { // All effects should already be unloaded by Impl dtor assert( loaded_effects.count() == 0 ); } QRect EffectsHandler::transformWindowDamage( EffectWindow* w, const QRect& r ) { if( current_transform < loaded_effects.size()) { QRect rr = loaded_effects[current_transform++].second->transformWindowDamage( w, r ); --current_transform; return rr; } else return r; } Window EffectsHandler::createInputWindow( Effect* e, const QRect& r, const QCursor& cursor ) { return createInputWindow( e, r.x(), r.y(), r.width(), r.height(), cursor ); } Window EffectsHandler::createFullScreenInputWindow( Effect* e, const QCursor& cursor ) { return createInputWindow( e, 0, 0, displayWidth(), displayHeight(), cursor ); } CompositingType EffectsHandler::compositingType() const { return compositing_type; } void EffectsHandler::sendReloadMessage( const QString& effectname ) { QDBusMessage message = QDBusMessage::createMethodCall("org.kde.kwin", "/KWin", "org.kde.KWin", "reloadEffect"); message << QString("kwin4_effect_" + effectname); QDBusConnection::sessionBus().send(message); } KConfigGroup EffectsHandler::effectConfig( const QString& effectname ) { - KSharedConfig::Ptr kwinconfig = KSharedConfig::openConfig( "kwinrc", KConfig::CascadeConfig ); + KSharedConfig::Ptr kwinconfig = KSharedConfig::openConfig( "kwinrc", KConfig::NoGlobals ); return kwinconfig->group( "Effect-" + effectname ); } bool EffectsHandler::paintText( const QString& text, const QPoint& center, int maxwidth, const QColor& color, const QFont& font ) { QPainter p; // Calculate size of the text QFontMetrics fm( font ); QString painttext = fm.elidedText( text, Qt::ElideRight, maxwidth ); QRect textrect = fm.boundingRect( painttext ); // Create temporary QPixmap where the text will be drawn onto QPixmap textPixmap( textrect.width(), textrect.height()); textPixmap.fill( Qt::transparent ); // Draw the text p.begin( &textPixmap ); p.setFont( font ); p.setRenderHint( QPainter::TextAntialiasing ); p.setPen( color ); p.drawText( -textrect.topLeft(), painttext ); p.end(); // Area covered by text QRect area( center.x() - textrect.width() / 2, center.y() - textrect.height() / 2, textrect.width(), textrect.height() ); #ifdef HAVE_OPENGL if( effects->compositingType() == OpenGLCompositing ) { GLTexture textTexture( textPixmap, GL_TEXTURE_RECTANGLE_ARB ); glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT | GL_TEXTURE_BIT ); glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); textTexture.bind(); const float verts[ 4 * 2 ] = { area.x(), area.y(), area.x(), area.y() + area.height(), area.x() + area.width(), area.y() + area.height(), area.x() + area.width(), area.y() }; const float texcoords[ 4 * 2 ] = { 0, textPixmap.height(), 0, 0, textPixmap.width(), 0, textPixmap.width(), textPixmap.height() }; renderGLGeometry( 4, verts, texcoords ); textTexture.unbind(); glPopAttrib(); return true; } #endif #ifdef HAVE_XRENDER if( effects->compositingType() == XRenderCompositing ) { static XRenderPictFormat* alphaFormat = 0; if( !alphaFormat) alphaFormat = XRenderFindStandardFormat( display(), PictStandardARGB32 ); Picture textPicture; textPicture = XRenderCreatePicture( display(), textPixmap.handle(), alphaFormat, 0, NULL ); XRenderComposite( display(), textPixmap.depth() == 32 ? PictOpOver : PictOpSrc, textPicture, None, effects->xrenderBufferPicture(), 0, 0, 0, 0, area.x(), area.y(), area.width(), area.height()); XRenderFreePicture( display(), textPicture ); return true; } #endif return false; } bool EffectsHandler::paintTextWithBackground( const QString& text, const QPoint& center, int maxwidth, const QColor& color, const QColor& bgcolor, const QFont& font ) { // Calculate size of the text QFontMetrics fm( font ); QString painttext = fm.elidedText( text, Qt::ElideRight, maxwidth ); QRect textrect = fm.boundingRect( painttext ); // Area covered by text QRect area( center.x() - textrect.width() / 2, center.y() - textrect.height() / 2, textrect.width(), textrect.height() ); #ifdef HAVE_OPENGL if( effects->compositingType() == OpenGLCompositing ) { glColor4f( bgcolor.redF(), bgcolor.greenF(), bgcolor.blueF(), bgcolor.alphaF() ); renderRoundBox( area.adjusted( -8, -3, 8, 3 ), 5 ); return paintText( text, center, maxwidth, color, font ); } #endif // TODO: render at least a simple background rect in XRender mode return false; } EffectsHandler* effects = 0; //**************************************** // EffectWindow //**************************************** EffectWindow::EffectWindow() { } EffectWindow::~EffectWindow() { } bool EffectWindow::isOnCurrentDesktop() const { return isOnDesktop( effects->currentDesktop()); } bool EffectWindow::isOnDesktop( int d ) const { return desktop() == d || isOnAllDesktops(); } bool EffectWindow::hasDecoration() const { return contentsRect() != QRect( 0, 0, width(), height()); } //**************************************** // EffectWindowGroup //**************************************** EffectWindowGroup::~EffectWindowGroup() { } /*************************************************************** WindowQuad ***************************************************************/ WindowQuad WindowQuad::makeSubQuad( double x1, double y1, double x2, double y2 ) const { assert( x1 < x2 && y1 < y2 && x1 >= left() && x2 <= right() && y1 >= top() && y2 <= bottom()); #ifndef NDEBUG if( isTransformed()) kFatal( 1212 ) << "Splitting quads is allowed only in pre-paint calls!" ; #endif WindowQuad ret( *this ); // vertices are clockwise starting from topleft ret.verts[ 0 ].px = x1; ret.verts[ 3 ].px = x1; ret.verts[ 1 ].px = x2; ret.verts[ 2 ].px = x2; ret.verts[ 0 ].py = y1; ret.verts[ 1 ].py = y1; ret.verts[ 2 ].py = y2; ret.verts[ 3 ].py = y2; // original x/y are supposed to be the same, no transforming is done here ret.verts[ 0 ].ox = x1; ret.verts[ 3 ].ox = x1; ret.verts[ 1 ].ox = x2; ret.verts[ 2 ].ox = x2; ret.verts[ 0 ].oy = y1; ret.verts[ 1 ].oy = y1; ret.verts[ 2 ].oy = y2; ret.verts[ 3 ].oy = y2; double my_tleft = verts[ 0 ].tx; double my_tright = verts[ 2 ].tx; double my_ttop = verts[ 0 ].ty; double my_tbottom = verts[ 2 ].ty; double tleft = ( x1 - left()) / ( right() - left()) * ( my_tright - my_tleft ) + my_tleft; double tright = ( x2 - left()) / ( right() - left()) * ( my_tright - my_tleft ) + my_tleft; double ttop = ( y1 - top()) / ( bottom() - top()) * ( my_tbottom - my_ttop ) + my_ttop; double tbottom = ( y2 - top()) / ( bottom() - top()) * ( my_tbottom - my_ttop ) + my_ttop; ret.verts[ 0 ].tx = tleft; ret.verts[ 3 ].tx = tleft; ret.verts[ 1 ].tx = tright; ret.verts[ 2 ].tx = tright; ret.verts[ 0 ].ty = ttop; ret.verts[ 1 ].ty = ttop; ret.verts[ 2 ].ty = tbottom; ret.verts[ 3 ].ty = tbottom; return ret; } bool WindowQuad::smoothNeeded() const { // smoothing is needed if the width or height of the quad does not match the original size double width = verts[ 1 ].ox - verts[ 0 ].ox; double height = verts[ 2 ].oy - verts[ 1 ].oy; return( verts[ 1 ].px - verts[ 0 ].px != width || verts[ 2 ].px - verts[ 3 ].px != width || verts[ 2 ].py - verts[ 1 ].py != height || verts[ 3 ].py - verts[ 0 ].py != height ); } /*************************************************************** WindowQuadList ***************************************************************/ WindowQuadList WindowQuadList::splitAtX( double x ) const { WindowQuadList ret; foreach( WindowQuad quad, *this ) { #ifndef NDEBUG if( quad.isTransformed()) kFatal( 1212 ) << "Splitting quads is allowed only in pre-paint calls!" ; #endif bool wholeleft = true; bool wholeright = true; for( int i = 0; i < 4; ++i ) { if( quad[ i ].x() < x ) wholeright = false; if( quad[ i ].x() >= x ) wholeleft = false; } if( wholeleft || wholeright ) // is whole in one split part { ret.append( quad ); continue; } ret.append( quad.makeSubQuad( quad.left(), quad.top(), x, quad.bottom())); ret.append( quad.makeSubQuad( x, quad.top(), quad.right(), quad.bottom())); } return ret; } WindowQuadList WindowQuadList::splitAtY( double y ) const { WindowQuadList ret; foreach( WindowQuad quad, *this ) { #ifndef NDEBUG if( quad.isTransformed()) kFatal( 1212 ) << "Splitting quads is allowed only in pre-paint calls!" ; #endif bool wholetop = true; bool wholebottom = true; for( int i = 0; i < 4; ++i ) { if( quad[ i ].y() < y ) wholebottom = false; if( quad[ i ].y() >= y ) wholetop = false; } if( wholetop || wholebottom ) // is whole in one split part { ret.append( quad ); continue; } ret.append( quad.makeSubQuad( quad.left(), quad.top(), quad.right(), y )); ret.append( quad.makeSubQuad( quad.left(), y, quad.right(), quad.bottom())); } return ret; } WindowQuadList WindowQuadList::makeGrid( int maxquadsize ) const { if( empty()) return *this; // find the bounding rectangle double left = first().left(); double right = first().right(); double top = first().top(); double bottom = first().bottom(); foreach( WindowQuad quad, *this ) { #ifndef NDEBUG if( quad.isTransformed()) kFatal( 1212 ) << "Splitting quads is allowed only in pre-paint calls!" ; #endif left = qMin( left, quad.left()); right = qMax( right, quad.right()); top = qMin( top, quad.top()); bottom = qMax( bottom, quad.bottom()); } WindowQuadList ret; for( double x = left; x < right; x += maxquadsize ) { for( double y = top; y < bottom; y += maxquadsize ) { foreach( WindowQuad quad, *this ) { if( QRectF( QPointF( quad.left(), quad.top()), QPointF( quad.right(), quad.bottom())) .intersects( QRectF( x, y, maxquadsize, maxquadsize ))) { ret.append( quad.makeSubQuad( qMax( x, quad.left()), qMax( y, quad.top()), qMin( quad.right(), x + maxquadsize ), qMin( quad.bottom(), y + maxquadsize ))); } } } } return ret; } void WindowQuadList::makeArrays( float** vertices, float** texcoords ) const { *vertices = new float[ count() * 4 * 2 ]; *texcoords = new float[ count() * 4 * 2 ]; float* vpos = *vertices; float* tpos = *texcoords; for( int i = 0; i < count(); ++i ) for( int j = 0; j < 4; ++j ) { *vpos++ = at( i )[ j ].x(); *vpos++ = at( i )[ j ].y(); *tpos++ = at( i )[ j ].tx; *tpos++ = at( i )[ j ].ty; } } WindowQuadList WindowQuadList::select( WindowQuadType type ) const { foreach( WindowQuad q, *this ) { if( q.type != type ) // something else than ones to select, make a copy and filter { WindowQuadList ret; foreach( WindowQuad q, *this ) { if( q.type == type ) ret.append( q ); } return ret; } } return *this; // nothing to filter out } WindowQuadList WindowQuadList::filterOut( WindowQuadType type ) const { foreach( WindowQuad q, *this ) { if( q.type == type ) // something to filter out, make a copy and filter { WindowQuadList ret; foreach( WindowQuad q, *this ) { if( q.type != type ) ret.append( q ); } return ret; } } return *this; // nothing to filter out } bool WindowQuadList::smoothNeeded() const { foreach( WindowQuad q, *this ) if( q.smoothNeeded()) return true; return false; } } // namespace diff --git a/options.cpp b/options.cpp index 37658ffab..30da5325a 100644 --- a/options.cpp +++ b/options.cpp @@ -1,356 +1,356 @@ /***************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 1999, 2000 Matthias Ettrich Copyright (C) 2003 Lubos Lunak You can Freely distribute this program under the GNU General Public License. See the file "COPYING" for the exact licensing terms. ******************************************************************/ #include "options.h" #ifndef KCMRULES #include #include #include #include #include #include #include #include "client.h" #include "compositingprefs.h" #endif namespace KWin { #ifndef KCMRULES Options::Options() : electric_borders( 0 ), electric_border_delay(0) { d = new KDecorationOptionsPrivate; d->defaultKWinSettings(); updateSettings(); } Options::~Options() { delete d; } unsigned long Options::updateSettings() { KSharedConfig::Ptr _config = KGlobal::config(); unsigned long changed = 0; changed |= d->updateKWinSettings( _config.data() ); // read decoration settings KConfigGroup config(_config, "Windows"); moveMode = stringToMoveResizeMode( config.readEntry("MoveMode", "Opaque" )); resizeMode = stringToMoveResizeMode( config.readEntry("ResizeMode", "Opaque" )); show_geometry_tip = config.readEntry("GeometryTip", false); QString val; val = config.readEntry ("FocusPolicy", "ClickToFocus"); focusPolicy = ClickToFocus; // what a default :-) if ( val == "FocusFollowsMouse" ) focusPolicy = FocusFollowsMouse; else if ( val == "FocusUnderMouse" ) focusPolicy = FocusUnderMouse; else if ( val == "FocusStrictlyUnderMouse" ) focusPolicy = FocusStrictlyUnderMouse; val = config.readEntry ("AltTabStyle", "KDE"); altTabStyle = KDE; // what a default :-) if ( val == "CDE" ) altTabStyle = CDE; separateScreenFocus = config.readEntry( "SeparateScreenFocus", true ); activeMouseScreen = config.readEntry( "ActiveMouseScreen", focusPolicy != ClickToFocus ); rollOverDesktops = config.readEntry("RollOverDesktops", true); // focusStealingPreventionLevel = config.readEntry( "FocusStealingPreventionLevel", 2 ); // TODO use low level for now focusStealingPreventionLevel = config.readEntry( "FocusStealingPreventionLevel", 1 ); focusStealingPreventionLevel = qMax( 0, qMin( 4, focusStealingPreventionLevel )); if( !focusPolicyIsReasonable()) // #48786, comments #7 and later focusStealingPreventionLevel = 0; - KConfig *gc = new KConfig("kdeglobals", KConfig::CascadeConfig); + KConfig *gc = new KConfig("kdeglobals", KConfig::NoGlobals); bool isVirtual = KApplication::desktop()->isVirtualDesktop(); KConfigGroup gWindowsConfig(gc, "Windows"); xineramaEnabled = gWindowsConfig.readEntry ("XineramaEnabled", isVirtual) && isVirtual; if (xineramaEnabled) { xineramaPlacementEnabled = gWindowsConfig.readEntry ("XineramaPlacementEnabled", true); xineramaMovementEnabled = gWindowsConfig.readEntry ("XineramaMovementEnabled", true); xineramaMaximizeEnabled = gWindowsConfig.readEntry ("XineramaMaximizeEnabled", true); xineramaFullscreenEnabled = gWindowsConfig.readEntry ("XineramaFullscreenEnabled", true); } else { xineramaPlacementEnabled = xineramaMovementEnabled = xineramaMaximizeEnabled = xineramaFullscreenEnabled = false; } delete gc; placement = Placement::policyFromString( config.readEntry("Placement"), true ); xineramaPlacementScreen = qBound( -1, config.readEntry( "XineramaPlacementScreen", -1 ), qApp->desktop()->numScreens() - 1 ); animateShade = config.readEntry("AnimateShade", true); animateMinimize = config.readEntry("AnimateMinimize", true); animateMinimizeSpeed = config.readEntry("AnimateMinimizeSpeed", 5 ); if( focusPolicy == ClickToFocus ) { autoRaise = false; autoRaiseInterval = 0; delayFocus = false; delayFocusInterval = 0; } else { autoRaise = config.readEntry("AutoRaise", false); autoRaiseInterval = config.readEntry("AutoRaiseInterval", 0 ); delayFocus = config.readEntry("DelayFocus", false); delayFocusInterval = config.readEntry("DelayFocusInterval", 0 ); } shadeHover = config.readEntry("ShadeHover", false); shadeHoverInterval = config.readEntry("ShadeHoverInterval", 250 ); // important: autoRaise implies ClickRaise clickRaise = autoRaise || config.readEntry("ClickRaise", true); borderSnapZone = config.readEntry("BorderSnapZone", 10); windowSnapZone = config.readEntry("WindowSnapZone", 10); snapOnlyWhenOverlapping = config.readEntry("SnapOnlyWhenOverlapping", false); electric_borders = config.readEntry("ElectricBorders", 0); electric_border_delay = config.readEntry("ElectricBorderDelay", 150); OpTitlebarDblClick = windowOperation( config.readEntry("TitlebarDoubleClickCommand", "Shade"), true ); d->OpMaxButtonLeftClick = windowOperation( config.readEntry("MaximizeButtonLeftClickCommand", "Maximize"), true ); d->OpMaxButtonMiddleClick = windowOperation( config.readEntry("MaximizeButtonMiddleClickCommand", "Maximize (vertical only)"), true ); d->OpMaxButtonRightClick = windowOperation( config.readEntry("MaximizeButtonRightClickCommand", "Maximize (horizontal only)"), true ); ignorePositionClasses = config.readEntry("IgnorePositionClasses",QStringList()); ignoreFocusStealingClasses = config.readEntry("IgnoreFocusStealingClasses",QStringList()); // Qt3.2 and older had resource class all lowercase, but Qt3.3 has it capitalized // therefore Client::resourceClass() forces lowercase, force here lowercase as well for( QStringList::Iterator it = ignorePositionClasses.begin(); it != ignorePositionClasses.end(); ++it ) (*it) = (*it).toLower(); for( QStringList::Iterator it = ignoreFocusStealingClasses.begin(); it != ignoreFocusStealingClasses.end(); ++it ) (*it) = (*it).toLower(); killPingTimeout = config.readEntry( "KillPingTimeout", 5000 ); hideUtilityWindowsForInactive = config.readEntry( "HideUtilityWindowsForInactive", true); showDesktopIsMinimizeAll = config.readEntry( "ShowDesktopIsMinimizeAll", false ); // Mouse bindings config = KConfigGroup(_config,"MouseBindings"); CmdActiveTitlebar1 = mouseCommand(config.readEntry("CommandActiveTitlebar1","Raise"), true ); CmdActiveTitlebar2 = mouseCommand(config.readEntry("CommandActiveTitlebar2","Lower"), true ); CmdActiveTitlebar3 = mouseCommand(config.readEntry("CommandActiveTitlebar3","Operations menu"), true ); CmdInactiveTitlebar1 = mouseCommand(config.readEntry("CommandInactiveTitlebar1","Activate and raise"), true ); CmdInactiveTitlebar2 = mouseCommand(config.readEntry("CommandInactiveTitlebar2","Activate and lower"), true ); CmdInactiveTitlebar3 = mouseCommand(config.readEntry("CommandInactiveTitlebar3","Operations menu"), true ); CmdTitlebarWheel = mouseWheelCommand(config.readEntry("CommandTitlebarWheel","Nothing")); CmdWindow1 = mouseCommand(config.readEntry("CommandWindow1","Activate, raise and pass click"), false ); CmdWindow2 = mouseCommand(config.readEntry("CommandWindow2","Activate and pass click"), false ); CmdWindow3 = mouseCommand(config.readEntry("CommandWindow3","Activate and pass click"), false ); CmdAllModKey = (config.readEntry("CommandAllKey","Alt") == "Meta") ? Qt::Key_Meta : Qt::Key_Alt; CmdAll1 = mouseCommand(config.readEntry("CommandAll1","Move"), false ); CmdAll2 = mouseCommand(config.readEntry("CommandAll2","Toggle raise and lower"), false ); CmdAll3 = mouseCommand(config.readEntry("CommandAll3","Resize"), false ); CmdAllWheel = mouseWheelCommand(config.readEntry("CommandAllWheel","Nothing")); config=KConfigGroup(_config,"Compositing"); refreshRate = config.readEntry( "RefreshRate", 0 ); const HiddenPreviews hps[] = { HiddenPreviewsNever, HiddenPreviewsKeep, HiddenPreviewUpdate, HiddenPreviewsActive }; hiddenPreviews = hps[ qBound( 0, config.readEntry( "HiddenPreviews", 0 ), 3 ) ]; // Read button tooltip animation effect from kdeglobals // Since we want to allow users to enable window decoration tooltips // and not kstyle tooltips and vise-versa, we don't read the // "EffectNoTooltip" setting from kdeglobals. KConfig _globalConfig( "kdeglobals" ); KConfigGroup globalConfig(&_globalConfig, "KDE"); topmenus = globalConfig.readEntry( "macStyle", false); KConfig _kdesktopcfg( "kdesktoprc" ); KConfigGroup kdesktopcfg(&_kdesktopcfg, "Menubar" ); desktop_topmenu = kdesktopcfg.readEntry( "ShowMenubar", false); if( desktop_topmenu ) topmenus = true; // QToolTip::setGloballyEnabled( d->show_tooltips ); // KDE4 this probably needs to be done manually in clients // Driver-specific config detection CompositingPrefs prefs; prefs.detect(); reloadCompositingSettings( prefs ); return changed; } void Options::reloadCompositingSettings(const CompositingPrefs& prefs) { KSharedConfig::Ptr _config = KGlobal::config(); KConfigGroup config(_config, "Compositing"); // Compositing settings useCompositing = config.readEntry("Enabled", prefs.enableCompositing()); QString compositingBackend = config.readEntry("Backend", "OpenGL"); if( compositingBackend == "XRender" ) compositingMode = XRenderCompositing; else compositingMode = OpenGLCompositing; QString glmode = config.readEntry("GLMode", "TFP" ).toUpper(); if( glmode == "TFP" ) glMode = GLTFP; else if( glmode == "SHM" ) glMode = GLSHM; else glMode = GLFallback; glDirect = config.readEntry("GLDirect", prefs.enableDirectRendering() ); glVSync = config.readEntry("GLVSync", prefs.enableVSync() ); smoothScale = qBound( -1, config.readEntry( "GLTextureFilter", -1 ), 2 ); glStrictBinding = config.readEntry( "GLStrictBinding", prefs.strictBinding()); xrenderSmoothScale = config.readEntry("XRenderSmoothScale", false ); } // restricted should be true for operations that the user may not be able to repeat // if the window is moved out of the workspace (e.g. if the user moves a window // by the titlebar, and moves it too high beneath Kicker at the top edge, they // may not be able to move it back, unless they know about Alt+LMB) Options::WindowOperation Options::windowOperation(const QString &name, bool restricted ) { if (name == "Move") return restricted ? MoveOp : UnrestrictedMoveOp; else if (name == "Resize") return restricted ? ResizeOp : UnrestrictedResizeOp; else if (name == "Maximize") return MaximizeOp; else if (name == "Minimize") return MinimizeOp; else if (name == "Close") return CloseOp; else if (name == "OnAllDesktops") return OnAllDesktopsOp; else if (name == "Shade") return ShadeOp; else if (name == "Operations") return OperationsOp; else if (name == "Maximize (vertical only)") return VMaximizeOp; else if (name == "Maximize (horizontal only)") return HMaximizeOp; else if (name == "Lower") return LowerOp; return NoOp; } Options::MouseCommand Options::mouseCommand(const QString &name, bool restricted ) { QString lowerName = name.toLower(); if (lowerName == "raise") return MouseRaise; if (lowerName == "lower") return MouseLower; if (lowerName == "operations menu") return MouseOperationsMenu; if (lowerName == "toggle raise and lower") return MouseToggleRaiseAndLower; if (lowerName == "activate and raise") return MouseActivateAndRaise; if (lowerName == "activate and lower") return MouseActivateAndLower; if (lowerName == "activate") return MouseActivate; if (lowerName == "activate, raise and pass click") return MouseActivateRaiseAndPassClick; if (lowerName == "activate and pass click") return MouseActivateAndPassClick; if (lowerName == "activate, raise and move") return restricted ? MouseActivateRaiseAndMove : MouseActivateRaiseAndUnrestrictedMove; if (lowerName == "move") return restricted ? MouseMove : MouseUnrestrictedMove; if (lowerName == "resize") return restricted ? MouseResize : MouseUnrestrictedResize; if (lowerName == "shade") return MouseShade; if (lowerName == "minimize") return MouseMinimize; if (lowerName == "nothing") return MouseNothing; return MouseNothing; } Options::MouseWheelCommand Options::mouseWheelCommand(const QString &name) { QString lowerName = name.toLower(); if (lowerName == "raise/lower") return MouseWheelRaiseLower; if (lowerName == "shade/unshade") return MouseWheelShadeUnshade; if (lowerName == "maximize/restore") return MouseWheelMaximizeRestore; if (lowerName == "above/below") return MouseWheelAboveBelow; if (lowerName == "previous/next desktop") return MouseWheelPreviousNextDesktop; if (lowerName == "change opacity") return MouseWheelChangeOpacity; return MouseWheelNothing; } bool Options::showGeometryTip() { return show_geometry_tip; } int Options::electricBorders() { return electric_borders; } int Options::electricBorderDelay() { return electric_border_delay; } bool Options::checkIgnoreFocusStealing( const Client* c ) { return ignoreFocusStealingClasses.contains(QString::fromLatin1(c->resourceClass())); } Options::MouseCommand Options::wheelToMouseCommand( MouseWheelCommand com, int delta ) { switch( com ) { case MouseWheelRaiseLower: return delta > 0 ? MouseRaise : MouseLower; case MouseWheelShadeUnshade: return delta > 0 ? MouseSetShade : MouseUnsetShade; case MouseWheelMaximizeRestore: return delta > 0 ? MouseMaximize : MouseRestore; case MouseWheelAboveBelow: return delta > 0 ? MouseAbove : MouseBelow; case MouseWheelPreviousNextDesktop: return delta > 0 ? MousePreviousDesktop : MouseNextDesktop; case MouseWheelChangeOpacity: return delta > 0 ? MouseOpacityMore : MouseOpacityLess; default: return MouseNothing; } } #endif Options::MoveResizeMode Options::stringToMoveResizeMode( const QString& s ) { return s == "Opaque" ? Opaque : Transparent; } const char* Options::moveResizeModeToString( MoveResizeMode mode ) { return mode == Opaque ? "Opaque" : "Transparent"; } } // namespace