Proper support for active xinerama screen in effects.

BUG: 152552 


svn path=/trunk/KDE/kdebase/workspace/; revision=739248
This commit is contained in:
Luboš Luňák 2007-11-20 18:58:30 +00:00
parent 7dae3e8067
commit c1ed1edb52
7 changed files with 35 additions and 8 deletions

View file

@ -504,6 +504,25 @@ void EffectsHandlerImpl::addRepaint( int x, int y, int w, int h )
Workspace::self()->addRepaint( x, y, w, h );
}
int EffectsHandlerImpl::activeScreen() const
{
return Workspace::self()->activeScreen();
}
QRect EffectsHandlerImpl::clientArea( clientAreaOption opt, int screen, int desktop ) const
{
return Workspace::self()->clientArea( opt, screen, desktop );
}
QRect EffectsHandlerImpl::clientArea( clientAreaOption opt, const EffectWindow* c ) const
{
const Toplevel* t = static_cast< const EffectWindowImpl* >(c)->window();
if( const Client* cl = dynamic_cast< const Client* >( t ))
return Workspace::self()->clientArea( opt, cl );
else
return Workspace::self()->clientArea( opt, t->geometry().center(), Workspace::self()->currentDesktop());
}
QRect EffectsHandlerImpl::clientArea( clientAreaOption opt, const QPoint& p, int desktop ) const
{
return Workspace::self()->clientArea( opt, p, desktop );

View file

@ -75,7 +75,10 @@ class EffectsHandlerImpl : public EffectsHandler
virtual void addRepaintFull();
virtual void addRepaint( const QRect& r );
virtual void addRepaint( int x, int y, int w, int h );
virtual QRect clientArea( clientAreaOption opt, const QPoint& p, int desktop ) const;
virtual int activeScreen() const;
virtual QRect clientArea( clientAreaOption, int screen, int desktop ) const;
virtual QRect clientArea( clientAreaOption, const EffectWindow* c ) const;
virtual QRect clientArea( clientAreaOption, const QPoint& p, int desktop ) const;
virtual void calcDesktopLayout(int* x, int* y, Qt::Orientation* orientation) const;
virtual bool optionRollOverDesktops() const;
virtual int desktopToLeft( int desktop, bool wrap ) const;

View file

@ -413,7 +413,7 @@ void PresentWindowsEffect::calculateWindowTransformationsDumb(EffectWindowList w
int rows = windowlist.count() / 4 + 1;
int cols = windowlist.count() / rows + windowlist.count() % rows;
// Get rect which we can use on current desktop. This excludes e.g. panels
QRect placementRect = effects->clientArea( PlacementArea, QPoint( 0, 0 ), 0 );
QRect placementRect = effects->clientArea( PlacementArea, effects->activeScreen(), effects->currentDesktop());
// Size of one cell
int cellwidth = placementRect.width() / cols;
int cellheight = placementRect.height() / rows;
@ -459,7 +459,7 @@ int PresentWindowsEffect::windowHeightForWidth(EffectWindow* c, int w)
void PresentWindowsEffect::calculateWindowTransformationsKompose(EffectWindowList windowlist)
{
// Get rect which we can use on current desktop. This excludes e.g. panels
QRect availRect = effects->clientArea( PlacementArea, QPoint( 0, 0 ), effects->currentDesktop());
QRect availRect = effects->clientArea( PlacementArea, effects->activeScreen(), effects->currentDesktop());
// Following code is taken from Kompose 0.5.4, src/komposelayout.cpp
@ -597,7 +597,7 @@ void PresentWindowsEffect::calculateWindowTransformationsKompose(EffectWindowLis
void PresentWindowsEffect::calculateWindowTransformationsClosest(EffectWindowList windowlist)
{
QRect area = effects->clientArea( PlacementArea, QPoint( 0, 0 ), effects->currentDesktop());
QRect area = effects->clientArea( PlacementArea, effects->activeScreen(), effects->currentDesktop());
int columns = int( ceil( sqrt( windowlist.count())));
int rows = int( ceil( windowlist.count() / double( columns )));
foreach( EffectWindow* w, windowlist )
@ -726,7 +726,7 @@ void PresentWindowsEffect::getBestAssignments()
bool PresentWindowsEffect::canRearrangeClosest(EffectWindowList windowlist)
{
QRect area = effects->clientArea( PlacementArea, QPoint( 0, 0 ), effects->currentDesktop());
QRect area = effects->clientArea( PlacementArea, effects->activeScreen(), effects->currentDesktop());
int columns = int( ceil( sqrt( windowlist.count())));
int rows = int( ceil( windowlist.count() / double( columns )));
int old_columns = int( ceil( sqrt( mWindowData.count())));
@ -817,7 +817,7 @@ void PresentWindowsEffect::updateFilterTexture()
QRect rect;
QString translatedString = i18n( "Filter:\n%1", windowFilter );
rect.setSize( fm.size( 0, translatedString ));
QRect area = effects->clientArea( PlacementArea, QPoint( 0, 0 ), effects->currentDesktop());
QRect area = effects->clientArea( PlacementArea, effects->activeScreen(), effects->currentDesktop());
// Create image
QImage im( rect.width(), rect.height(), QImage::Format_ARGB32 );
im.fill( Qt::transparent );

View file

@ -55,7 +55,7 @@ void ShowPictureEffect::loadPicture()
if( file.isEmpty())
return;
QImage im( file );
QRect area = effects->clientArea( PlacementArea, QPoint( 0, 0 ), effects->currentDesktop());
QRect area = effects->clientArea( PlacementArea, effects->activeScreen(), effects->currentDesktop());
picture = new GLTexture( im );
pictureRect = QRect( area.x() + ( area.width() - im.width()) / 2,
area.y() + ( area.height() - im.height()) / 2, im.width(), im.height());

View file

@ -34,6 +34,7 @@ ThumbnailAsideEffect::ThumbnailAsideEffect()
maxwidth = conf.readEntry("MaxWidth", 200);
spacing = conf.readEntry("Spacing", 10);
opacity = conf.readEntry("Opacity", 50) / 100.0;
screen = conf.readEntry("Screen",-1); // Xinerama screen TODO add gui option
}
void ThumbnailAsideEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
@ -131,7 +132,7 @@ void ThumbnailAsideEffect::arrange()
mwidth = qMax( mwidth, d.window->width());
pos[ d.index ] = d.window->height();
}
QRect area = effects->clientArea( WorkArea, QPoint(), effects->currentDesktop());
QRect area = effects->clientArea( WorkArea, screen, effects->currentDesktop());
double scale = area.height() / double( height );
scale = qMin( scale, maxwidth / double( mwidth )); // don't be wider than maxwidth pixels
int add = 0;

View file

@ -53,6 +53,7 @@ class ThumbnailAsideEffect
int maxwidth;
int spacing;
double opacity;
int screen;
};
} // namespace

View file

@ -345,6 +345,9 @@ class KWIN_EXPORT EffectsHandler
virtual int numberOfDesktops() const = 0;
virtual void setCurrentDesktop( int desktop ) = 0;
virtual QString desktopName( int desktop ) const = 0;
virtual int activeScreen() const = 0; // Xinerama
virtual QRect clientArea( clientAreaOption, int screen, int desktop ) const = 0;
virtual QRect clientArea( clientAreaOption, const EffectWindow* c ) const = 0;
virtual QRect clientArea( clientAreaOption, const QPoint& p, int desktop ) const = 0;
virtual void calcDesktopLayout(int* x, int* y, Qt::Orientation* orientation) const = 0;
virtual bool optionRollOverDesktops() const = 0;