diff --git a/effects.cpp b/effects.cpp index e8413de3e8..4b19a4d336 100644 --- a/effects.cpp +++ b/effects.cpp @@ -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 ); diff --git a/effects.h b/effects.h index 666447006b..dc1c7e1dbc 100644 --- a/effects.h +++ b/effects.h @@ -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; diff --git a/effects/presentwindows.cpp b/effects/presentwindows.cpp index 271a4ad6aa..69926836df 100644 --- a/effects/presentwindows.cpp +++ b/effects/presentwindows.cpp @@ -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 ); diff --git a/effects/test/demo_showpicture.cpp b/effects/test/demo_showpicture.cpp index d20e21d50d..c3c11e4e9a 100644 --- a/effects/test/demo_showpicture.cpp +++ b/effects/test/demo_showpicture.cpp @@ -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()); diff --git a/effects/thumbnailaside.cpp b/effects/thumbnailaside.cpp index 2e850de9d0..cb99fe3c9c 100644 --- a/effects/thumbnailaside.cpp +++ b/effects/thumbnailaside.cpp @@ -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; diff --git a/effects/thumbnailaside.h b/effects/thumbnailaside.h index 1b99ceaa42..4e37086138 100644 --- a/effects/thumbnailaside.h +++ b/effects/thumbnailaside.h @@ -53,6 +53,7 @@ class ThumbnailAsideEffect int maxwidth; int spacing; double opacity; + int screen; }; } // namespace diff --git a/lib/kwineffects.h b/lib/kwineffects.h index 7f1e46d821..8f935dd242 100644 --- a/lib/kwineffects.h +++ b/lib/kwineffects.h @@ -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;