const & in foreach

svn path=/trunk/KDE/kdebase/workspace/; revision=801427
This commit is contained in:
Albert Astals Cid 2008-04-26 16:03:02 +00:00
parent 84664f2ba6
commit 3b9121ec3f
9 changed files with 45 additions and 45 deletions

View file

@ -59,9 +59,9 @@ EffectsHandlerImpl::~EffectsHandlerImpl()
{ {
if( keyboard_grab_effect != NULL ) if( keyboard_grab_effect != NULL )
ungrabKeyboard(); ungrabKeyboard();
foreach( EffectPair ep, loaded_effects ) foreach( const EffectPair &ep, loaded_effects )
unloadEffect( ep.first ); unloadEffect( ep.first );
foreach( InputWindowPair pos, input_windows ) foreach( const InputWindowPair &pos, input_windows )
XDestroyWindow( display(), pos.second ); XDestroyWindow( display(), pos.second );
} }
@ -73,7 +73,7 @@ void EffectsHandlerImpl::reconfigure()
KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect"); KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect");
QStringList effectsToBeLoaded; QStringList effectsToBeLoaded;
// First unload necessary effects // First unload necessary effects
foreach( KService::Ptr service, offers ) foreach( const KService::Ptr &service, offers )
{ {
KPluginInfo plugininfo( service ); KPluginInfo plugininfo( service );
plugininfo.load( conf ); plugininfo.load( conf );
@ -86,7 +86,7 @@ void EffectsHandlerImpl::reconfigure()
effectsToBeLoaded.append( plugininfo.pluginName() ); effectsToBeLoaded.append( plugininfo.pluginName() );
} }
// Then load those that should be loaded // Then load those that should be loaded
foreach( QString effectName, effectsToBeLoaded ) foreach( const QString &effectName, effectsToBeLoaded )
{ {
if( !isEffectLoaded( effectName )) if( !isEffectLoaded( effectName ))
{ {
@ -180,7 +180,7 @@ void EffectsHandlerImpl::startPaint()
void EffectsHandlerImpl::windowUserMovedResized( EffectWindow* c, bool first, bool last ) void EffectsHandlerImpl::windowUserMovedResized( EffectWindow* c, bool first, bool last )
{ {
foreach( EffectPair ep, loaded_effects ) foreach( const EffectPair &ep, loaded_effects )
ep.second->windowUserMovedResized( c, first, last ); ep.second->windowUserMovedResized( c, first, last );
} }
@ -188,50 +188,50 @@ void EffectsHandlerImpl::windowOpacityChanged( EffectWindow* c, double old_opaci
{ {
if( static_cast<EffectWindowImpl*>(c)->window()->opacity() == old_opacity ) if( static_cast<EffectWindowImpl*>(c)->window()->opacity() == old_opacity )
return; return;
foreach( EffectPair ep, loaded_effects ) foreach( const EffectPair &ep, loaded_effects )
ep.second->windowOpacityChanged( c, old_opacity ); ep.second->windowOpacityChanged( c, old_opacity );
} }
void EffectsHandlerImpl::windowAdded( EffectWindow* c ) void EffectsHandlerImpl::windowAdded( EffectWindow* c )
{ {
foreach( EffectPair ep, loaded_effects ) foreach( const EffectPair &ep, loaded_effects )
ep.second->windowAdded( c ); ep.second->windowAdded( c );
} }
void EffectsHandlerImpl::windowDeleted( EffectWindow* c ) void EffectsHandlerImpl::windowDeleted( EffectWindow* c )
{ {
foreach( EffectPair ep, loaded_effects ) foreach( const EffectPair &ep, loaded_effects )
ep.second->windowDeleted( c ); ep.second->windowDeleted( c );
elevated_windows.removeAll( c ); elevated_windows.removeAll( c );
} }
void EffectsHandlerImpl::windowClosed( EffectWindow* c ) void EffectsHandlerImpl::windowClosed( EffectWindow* c )
{ {
foreach( EffectPair ep, loaded_effects ) foreach( const EffectPair &ep, loaded_effects )
ep.second->windowClosed( c ); ep.second->windowClosed( c );
} }
void EffectsHandlerImpl::windowActivated( EffectWindow* c ) void EffectsHandlerImpl::windowActivated( EffectWindow* c )
{ {
foreach( EffectPair ep, loaded_effects ) foreach( const EffectPair &ep, loaded_effects )
ep.second->windowActivated( c ); ep.second->windowActivated( c );
} }
void EffectsHandlerImpl::windowMinimized( EffectWindow* c ) void EffectsHandlerImpl::windowMinimized( EffectWindow* c )
{ {
foreach( EffectPair ep, loaded_effects ) foreach( const EffectPair &ep, loaded_effects )
ep.second->windowMinimized( c ); ep.second->windowMinimized( c );
} }
void EffectsHandlerImpl::windowUnminimized( EffectWindow* c ) void EffectsHandlerImpl::windowUnminimized( EffectWindow* c )
{ {
foreach( EffectPair ep, loaded_effects ) foreach( const EffectPair &ep, loaded_effects )
ep.second->windowUnminimized( c ); ep.second->windowUnminimized( c );
} }
void EffectsHandlerImpl::desktopChanged( int old ) void EffectsHandlerImpl::desktopChanged( int old )
{ {
foreach( EffectPair ep, loaded_effects ) foreach( const EffectPair &ep, loaded_effects )
ep.second->desktopChanged( old ); ep.second->desktopChanged( old );
} }
@ -239,7 +239,7 @@ void EffectsHandlerImpl::windowDamaged( EffectWindow* w, const QRect& r )
{ {
if( w == NULL ) if( w == NULL )
return; return;
foreach( EffectPair ep, loaded_effects ) foreach( const EffectPair &ep, loaded_effects )
ep.second->windowDamaged( w, r ); ep.second->windowDamaged( w, r );
} }
@ -247,25 +247,25 @@ void EffectsHandlerImpl::windowGeometryShapeChanged( EffectWindow* w, const QRec
{ {
if( w == NULL ) // during late cleanup effectWindow() may be already NULL if( w == NULL ) // during late cleanup effectWindow() may be already NULL
return; // in some functions that may still call this return; // in some functions that may still call this
foreach( EffectPair ep, loaded_effects ) foreach( const EffectPair &ep, loaded_effects )
ep.second->windowGeometryShapeChanged( w, old ); ep.second->windowGeometryShapeChanged( w, old );
} }
void EffectsHandlerImpl::tabBoxAdded( int mode ) void EffectsHandlerImpl::tabBoxAdded( int mode )
{ {
foreach( EffectPair ep, loaded_effects ) foreach( const EffectPair &ep, loaded_effects )
ep.second->tabBoxAdded( mode ); ep.second->tabBoxAdded( mode );
} }
void EffectsHandlerImpl::tabBoxClosed() void EffectsHandlerImpl::tabBoxClosed()
{ {
foreach( EffectPair ep, loaded_effects ) foreach( const EffectPair &ep, loaded_effects )
ep.second->tabBoxClosed(); ep.second->tabBoxClosed();
} }
void EffectsHandlerImpl::tabBoxUpdated() void EffectsHandlerImpl::tabBoxUpdated()
{ {
foreach( EffectPair ep, loaded_effects ) foreach( const EffectPair &ep, loaded_effects )
ep.second->tabBoxUpdated(); ep.second->tabBoxUpdated();
} }
@ -282,7 +282,7 @@ Effect* EffectsHandlerImpl::activeFullScreenEffect() const
bool EffectsHandlerImpl::borderActivated( ElectricBorder border ) bool EffectsHandlerImpl::borderActivated( ElectricBorder border )
{ {
bool ret = false; bool ret = false;
foreach( EffectPair ep, loaded_effects ) foreach( const EffectPair &ep, loaded_effects )
if( ep.second->borderActivated( border )) if( ep.second->borderActivated( border ))
ret = true; // bail out or tell all? ret = true; // bail out or tell all?
return ret; return ret;
@ -292,7 +292,7 @@ void EffectsHandlerImpl::mouseChanged( const QPoint& pos, const QPoint& oldpos,
Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons,
Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers ) Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers )
{ {
foreach( EffectPair ep, loaded_effects ) foreach( const EffectPair &ep, loaded_effects )
ep.second->mouseChanged( pos, oldpos, buttons, oldbuttons, modifiers, oldmodifiers ); ep.second->mouseChanged( pos, oldpos, buttons, oldbuttons, modifiers, oldmodifiers );
} }
@ -329,7 +329,7 @@ void EffectsHandlerImpl::propertyNotify( EffectWindow* c, long atom )
{ {
if( !registered_atoms.contains( atom )) if( !registered_atoms.contains( atom ))
return; return;
foreach( EffectPair ep, loaded_effects ) foreach( const EffectPair &ep, loaded_effects )
ep.second->propertyNotify( c, atom ); ep.second->propertyNotify( c, atom );
} }
@ -583,7 +583,7 @@ Window EffectsHandlerImpl::createInputWindow( Effect* e, int x, int y, int w, in
void EffectsHandlerImpl::destroyInputWindow( Window w ) void EffectsHandlerImpl::destroyInputWindow( Window w )
{ {
foreach( InputWindowPair pos, input_windows ) foreach( const InputWindowPair &pos, input_windows )
{ {
if( pos.second == w ) if( pos.second == w )
{ {
@ -599,7 +599,7 @@ bool EffectsHandlerImpl::checkInputWindowEvent( XEvent* e )
{ {
if( e->type != ButtonPress && e->type != ButtonRelease && e->type != MotionNotify ) if( e->type != ButtonPress && e->type != ButtonRelease && e->type != MotionNotify )
return false; return false;
foreach( InputWindowPair pos, input_windows ) foreach( const InputWindowPair &pos, input_windows )
{ {
if( pos.second == e->xany.window ) if( pos.second == e->xany.window )
{ {
@ -648,7 +648,7 @@ void EffectsHandlerImpl::checkInputWindowStacking()
return; return;
Window* wins = new Window[ input_windows.count() ]; Window* wins = new Window[ input_windows.count() ];
int pos = 0; int pos = 0;
foreach( InputWindowPair it, input_windows ) foreach( const InputWindowPair &it, input_windows )
wins[ pos++ ] = it.second; wins[ pos++ ] = it.second;
XRaiseWindow( display(), wins[ 0 ] ); XRaiseWindow( display(), wins[ 0 ] );
XRestackWindows( display(), wins, pos ); XRestackWindows( display(), wins, pos );
@ -797,7 +797,7 @@ bool EffectsHandlerImpl::loadEffect( const QString& name )
// TODO: detect circular deps // TODO: detect circular deps
KPluginInfo plugininfo( service ); KPluginInfo plugininfo( service );
QStringList dependencies = plugininfo.dependencies(); QStringList dependencies = plugininfo.dependencies();
foreach( QString depName, dependencies ) foreach( const QString &depName, dependencies )
{ {
if( !loadEffect(depName)) if( !loadEffect(depName))
{ {
@ -866,7 +866,7 @@ void EffectsHandlerImpl::effectsChanged()
{ {
loaded_effects.clear(); loaded_effects.clear();
// kDebug(1212) << "Recreating effects' list:"; // kDebug(1212) << "Recreating effects' list:";
foreach( EffectPair effect, effect_order ) foreach( const EffectPair &effect, effect_order )
{ {
// kDebug(1212) << effect.first; // kDebug(1212) << effect.first;
loaded_effects.append( effect ); loaded_effects.append( effect );

View file

@ -303,7 +303,7 @@ void BlurEffect::updateBlurTexture(const QRegion& region)
QRect bounding = region.boundingRect(); QRect bounding = region.boundingRect();
QVector<QRect> rects = region.rects(); QVector<QRect> rects = region.rects();
int totalarea = 0; int totalarea = 0;
foreach( QRect r, rects ) foreach( const QRect &r, rects )
totalarea += r.width() * r.height(); totalarea += r.width() * r.height();
if( (int)(totalarea * 1.33 + 100 ) < bounding.width() * bounding.height() ) if( (int)(totalarea * 1.33 + 100 ) < bounding.width() * bounding.height() )
{ {
@ -329,7 +329,7 @@ void BlurEffect::updateBlurTexture(const QVector<QRect>& rects)
mSceneTexture->bind(); mSceneTexture->bind();
foreach( QRect r, rects ) foreach( const QRect &r, rects )
{ {
// We change x coordinates here because horizontal blur pass (which // We change x coordinates here because horizontal blur pass (which
// comes after this one) also uses pixels that are horizontally edging // comes after this one) also uses pixels that are horizontally edging
@ -354,7 +354,7 @@ void BlurEffect::updateBlurTexture(const QVector<QRect>& rects)
mTmpTexture->bind(); mTmpTexture->bind();
foreach( QRect r, rects ) foreach( const QRect &r, rects )
{ {
glBegin(GL_QUADS); glBegin(GL_QUADS);
glVertex2f( r.x() , r.y() + r.height() ); glVertex2f( r.x() , r.y() + r.height() );

View file

@ -112,7 +112,7 @@ void ShadowEffect::drawWindow( EffectWindow* w, int mask, QRegion region, Window
if( !shadowDatas.isEmpty()) if( !shadowDatas.isEmpty())
d.clip |= shadowDatas.last().clip; d.clip |= shadowDatas.last().clip;
d.mask = mask; d.mask = mask;
foreach(QRect r, region.rects()) foreach(const QRect &r, region.rects())
d.region |= shadowRectangle(r); d.region |= shadowRectangle(r);
d.region &= region; d.region &= region;
shadowDatas.append(d); shadowDatas.append(d);

View file

@ -67,7 +67,7 @@ void TaskbarThumbnailEffect::paintWindow( EffectWindow* w, int mask, QRegion reg
effects->paintWindow( w, mask, region, data ); // paint window first effects->paintWindow( w, mask, region, data ); // paint window first
if( thumbnails.contains( w )) if( thumbnails.contains( w ))
{ // paint thumbnails on it { // paint thumbnails on it
foreach( const Data thumb, thumbnails.values( w )) foreach( const Data &thumb, thumbnails.values( w ))
{ {
EffectWindow* thumbw = effects->findWindow( thumb.window ); EffectWindow* thumbw = effects->findWindow( thumb.window );
if( thumbw == NULL ) if( thumbw == NULL )

View file

@ -51,7 +51,7 @@ void FlameEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Window
{ {
WindowQuadList new_quads; WindowQuadList new_quads;
double ylimit = windows[ w ] * w->height(); // parts above this are already away double ylimit = windows[ w ] * w->height(); // parts above this are already away
foreach( WindowQuad quad, data.quads ) foreach( const WindowQuad &quad, data.quads )
{ {
if( quad.bottom() <= ylimit ) if( quad.bottom() <= ylimit )
continue; continue;

View file

@ -92,7 +92,7 @@ void VideoRecordEffect::postPaintScreen()
if( CapturyProcessRegionStart( client ) == CAPTURY_SUCCESS ) if( CapturyProcessRegionStart( client ) == CAPTURY_SUCCESS )
{ {
capture_region &= QRect( 0, 0, displayWidth(), displayHeight()); // limit to screen capture_region &= QRect( 0, 0, displayWidth(), displayHeight()); // limit to screen
foreach( QRect r, capture_region.rects()) foreach( const QRect &r, capture_region.rects())
{ {
int gly = displayHeight() - r.y() - r.height(); // opengl coords int gly = displayHeight() - r.y() - r.height(); // opengl coords
CapturyProcessRegion( client, r.x(), gly, r.width(), r.height()); CapturyProcessRegion( client, r.x(), gly, r.width(), r.height());

View file

@ -191,7 +191,7 @@ void Scene::paintGenericScreen( int orig_mask, ScreenPaintData )
// preparation step // preparation step
effects->prePaintWindow( effectWindow( w ), data, time_diff ); effects->prePaintWindow( effectWindow( w ), data, time_diff );
#ifndef NDEBUG #ifndef NDEBUG
foreach( WindowQuad q, data.quads ) foreach( const WindowQuad &q, data.quads )
if( q.isTransformed()) if( q.isTransformed())
kFatal( 1212 ) << "Pre-paint calls are not allowed to transform quads!" ; kFatal( 1212 ) << "Pre-paint calls are not allowed to transform quads!" ;
#endif #endif
@ -200,7 +200,7 @@ void Scene::paintGenericScreen( int orig_mask, ScreenPaintData )
phase2.append( Phase2Data( w, infiniteRegion(), data.clip, data.mask, data.quads )); phase2.append( Phase2Data( w, infiniteRegion(), data.clip, data.mask, data.quads ));
} }
foreach( Phase2Data d, phase2 ) foreach( const Phase2Data &d, phase2 )
paintWindow( d.window, d.mask, d.region, d.quads ); paintWindow( d.window, d.mask, d.region, d.quads );
} }
@ -230,7 +230,7 @@ void Scene::paintSimpleScreen( int orig_mask, QRegion region )
// preparation step // preparation step
effects->prePaintWindow( effectWindow( w ), data, time_diff ); effects->prePaintWindow( effectWindow( w ), data, time_diff );
#ifndef NDEBUG #ifndef NDEBUG
foreach( WindowQuad q, data.quads ) foreach( const WindowQuad &q, data.quads )
if( q.isTransformed()) if( q.isTransformed())
kFatal( 1212 ) << "Pre-paint calls are not allowed to transform quads!" ; kFatal( 1212 ) << "Pre-paint calls are not allowed to transform quads!" ;
#endif #endif
@ -438,7 +438,7 @@ WindowQuadList Scene::Window::buildQuads() const
WindowQuadList Scene::Window::makeQuads( WindowQuadType type, const QRegion& reg ) const WindowQuadList Scene::Window::makeQuads( WindowQuadType type, const QRegion& reg ) const
{ {
WindowQuadList ret; WindowQuadList ret;
foreach( QRect r, reg.rects()) foreach( const QRect &r, reg.rects())
{ {
WindowQuad quad( type ); WindowQuad quad( type );
// TODO asi mam spatne pravy dolni roh - bud tady, nebo v jinych castech // TODO asi mam spatne pravy dolni roh - bud tady, nebo v jinych castech

View file

@ -645,7 +645,7 @@ void SceneOpenGL::flushBuffer( int mask, QRegion damage )
waitSync(); waitSync();
if( glXCopySubBuffer ) if( glXCopySubBuffer )
{ {
foreach( QRect r, damage.rects()) foreach( const QRect &r, damage.rects())
{ {
// convert to OpenGL coordinates // convert to OpenGL coordinates
int y = displayHeight() - r.y() - r.height(); int y = displayHeight() - r.y() - r.height();
@ -658,7 +658,7 @@ void SceneOpenGL::flushBuffer( int mask, QRegion damage )
glDrawBuffer( GL_FRONT ); glDrawBuffer( GL_FRONT );
int xpos = 0; int xpos = 0;
int ypos = 0; int ypos = 0;
foreach( QRect r, damage.rects()) foreach( const QRect &r, damage.rects())
{ {
// convert to OpenGL coordinates // convert to OpenGL coordinates
int y = displayHeight() - r.y() - r.height(); int y = displayHeight() - r.y() - r.height();
@ -691,7 +691,7 @@ void SceneOpenGL::flushBuffer( int mask, QRegion damage )
glXWaitGL(); glXWaitGL();
waitSync(); waitSync();
if( mask & PAINT_SCREEN_REGION ) if( mask & PAINT_SCREEN_REGION )
foreach( QRect r, damage.rects()) foreach( const QRect &r, damage.rects())
XCopyArea( display(), buffer, rootWindow(), gcroot, r.x(), r.y(), r.width(), r.height(), r.x(), r.y()); XCopyArea( display(), buffer, rootWindow(), gcroot, r.x(), r.y(), r.width(), r.height(), r.x(), r.y());
else else
XCopyArea( display(), buffer, rootWindow(), gcroot, 0, 0, displayWidth(), displayHeight(), 0, 0 ); XCopyArea( display(), buffer, rootWindow(), gcroot, 0, 0, displayWidth(), displayHeight(), 0, 0 );
@ -877,7 +877,7 @@ QRegion SceneOpenGL::Texture::optimizeBindDamage( const QRegion& reg, int limit
// between all the areas and the bounding rectangle is small, simply use // between all the areas and the bounding rectangle is small, simply use
// only the bounding rectangle // only the bounding rectangle
int size = 0; int size = 0;
foreach( QRect r, reg.rects()) foreach( const QRect &r, reg.rects())
size += r.width() * r.height(); size += r.width() * r.height();
if( reg.boundingRect().width() * reg.boundingRect().height() - size < limit ) if( reg.boundingRect().width() * reg.boundingRect().height() - size < limit )
return reg.boundingRect(); return reg.boundingRect();
@ -983,7 +983,7 @@ bool SceneOpenGL::Texture::load( const Pixmap& pix, const QSize& size,
mSize.width(), mSize.height(), depth ); mSize.width(), mSize.height(), depth );
QRegion damage = optimizeBindDamage( region, 100 * 100 ); QRegion damage = optimizeBindDamage( region, 100 * 100 );
glPixelStorei( GL_UNPACK_ROW_LENGTH, mSize.width()); glPixelStorei( GL_UNPACK_ROW_LENGTH, mSize.width());
foreach( QRect r, damage.rects()) foreach( const QRect &r, damage.rects())
{ // TODO for small areas it might be faster to not use SHM to avoid the XSync() { // TODO for small areas it might be faster to not use SHM to avoid the XSync()
XCopyArea( display(), pix, p, gc, r.x(), r.y(), r.width(), r.height(), 0, 0 ); XCopyArea( display(), pix, p, gc, r.x(), r.y(), r.width(), r.height(), 0, 0 );
glXWaitX(); glXWaitX();
@ -1030,7 +1030,7 @@ bool SceneOpenGL::Texture::load( const Pixmap& pix, const QSize& size,
{ {
glBindTexture( mTarget, mTexture ); glBindTexture( mTarget, mTexture );
QRegion damage = optimizeBindDamage( region, 30 * 30 ); QRegion damage = optimizeBindDamage( region, 30 * 30 );
foreach( QRect r, damage.rects()) foreach( const QRect &r, damage.rects())
{ {
// convert to OpenGL coordinates (this is mapping // convert to OpenGL coordinates (this is mapping
// the pixmap to a texture, this is not affected // the pixmap to a texture, this is not affected

View file

@ -222,7 +222,7 @@ void SceneXrender::paintTransformedScreen( int orig_mask )
// preparation step // preparation step
effects->prePaintWindow( effectWindow( w ), data, time_diff ); effects->prePaintWindow( effectWindow( w ), data, time_diff );
#ifndef NDEBUG #ifndef NDEBUG
foreach( WindowQuad q, data.quads ) foreach( const WindowQuad &q, data.quads )
if( q.isTransformed()) if( q.isTransformed())
kFatal( 1212 ) << "Pre-paint calls are not allowed to transform quads!" ; kFatal( 1212 ) << "Pre-paint calls are not allowed to transform quads!" ;
#endif #endif
@ -254,7 +254,7 @@ void SceneXrender::paintTransformedScreen( int orig_mask )
// That we draw bottom to top is important now since we're drawing translucent objects // That we draw bottom to top is important now since we're drawing translucent objects
// and also are clipping only by opaque windows. // and also are clipping only by opaque windows.
QRegion add_paint; QRegion add_paint;
foreach( Phase2Data d, phase2 ) foreach( const Phase2Data &d, phase2 )
{ {
Scene::Window* w = d.window; Scene::Window* w = d.window;
paintWindow( w, d.mask, d.region | add_paint, d.quads ); paintWindow( w, d.mask, d.region | add_paint, d.quads );