Fix painting of moved on-all-desktop windows.

svn path=/branches/work/kwin_composite/; revision=656444
This commit is contained in:
Luboš Luňák 2007-04-21 12:29:43 +00:00
parent a23a2fafa5
commit b849a760ef
2 changed files with 19 additions and 10 deletions

View file

@ -101,7 +101,7 @@ void DesktopGridEffect::prePaintWindow( EffectWindow* w, int* mask, QRegion* pai
if( w == window_move ) if( w == window_move )
{ {
*mask |= PAINT_WINDOW_TRANSFORMED; *mask |= PAINT_WINDOW_TRANSFORMED;
if( w->isOnAllDesktops() && painting_desktop != effects->currentDesktop()) if( w->isOnAllDesktops() && painting_desktop != posToDesktop( window_move_pos - window_move_diff ))
w->disablePainting( EffectWindow::PAINT_DISABLED_BY_DESKTOP ); w->disablePainting( EffectWindow::PAINT_DISABLED_BY_DESKTOP );
} }
} }
@ -122,7 +122,8 @@ void DesktopGridEffect::paintScreen( int mask, QRegion region, ScreenPaintData&
} }
int desktop_with_move = -1; int desktop_with_move = -1;
if( window_move != NULL ) if( window_move != NULL )
desktop_with_move = window_move->isOnAllDesktops() ? effects->currentDesktop() : window_move->desktop(); desktop_with_move = window_move->isOnAllDesktops()
? posToDesktop( window_move_pos - window_move_diff ) : window_move->desktop();
for( int desktop = 1; for( int desktop = 1;
desktop <= effects->numberOfDesktops(); desktop <= effects->numberOfDesktops();
++desktop ) ++desktop )
@ -239,8 +240,7 @@ void DesktopGridEffect::paintWindow( EffectWindow* w, int mask, QRegion region,
int x, y; int x, y;
Qt::Orientation orientation; Qt::Orientation orientation;
effects->calcDesktopLayout( &x, &y, &orientation ); effects->calcDesktopLayout( &x, &y, &orientation );
QRect desktop = desktopRect( w->isOnCurrentDesktop() QRect desktop = desktopRect( painting_desktop, false );
? effects->currentDesktop() : w->desktop(), false );
data.xTranslate += window_move_pos.x() * x - ( desktop.x() + w->x()); data.xTranslate += window_move_pos.x() * x - ( desktop.x() + w->x());
data.yTranslate += window_move_pos.y() * y - ( desktop.y() + w->y()); data.yTranslate += window_move_pos.y() * y - ( desktop.y() + w->y());
} }
@ -308,10 +308,14 @@ QRect DesktopGridEffect::windowRect( EffectWindow* w ) const
w->width() / x, w->height() / y ); w->width() / x, w->height() / y );
} }
EffectWindow* DesktopGridEffect::windowAt( const QPoint& pos ) const EffectWindow* DesktopGridEffect::windowAt( const QPoint& pos, QRect* rect ) const
{ {
if( window_move != NULL && windowRect( window_move ).contains( pos )) if( window_move != NULL && windowRect( window_move ).contains( pos ))
{
if( rect != NULL )
*rect = windowRect( window_move );
return window_move; // has special position and is on top return window_move; // has special position and is on top
}
EffectWindowList windows = effects->stackingOrder(); EffectWindowList windows = effects->stackingOrder();
// qReverse() // qReverse()
EffectWindowList::Iterator begin = windows.begin(); EffectWindowList::Iterator begin = windows.begin();
@ -327,11 +331,15 @@ EffectWindow* DesktopGridEffect::windowAt( const QPoint& pos ) const
// don't use windowRect(), take special care of on-all-desktop windows // don't use windowRect(), take special care of on-all-desktop windows
QRect desktop = desktopRect( w->isOnAllDesktops() QRect desktop = desktopRect( w->isOnAllDesktops()
? posToDesktop( pos ) : w->desktop(), true ); ? posToDesktop( pos ) : w->desktop(), true );
QRect rect( desktop.x() + w->x() / x, desktop.y() + w->y() / y, QRect r( desktop.x() + w->x() / x, desktop.y() + w->y() / y,
w->width() / x, w->height() / y ); w->width() / x, w->height() / y );
if( rect.contains( pos )) if( r.contains( pos ))
{
if( rect != NULL )
*rect = r;
return w; return w;
} }
}
return NULL; return NULL;
} }
@ -463,10 +471,11 @@ void DesktopGridEffect::windowInputMouseEvent( Window, QEvent* e )
{ {
if( me->buttons() == Qt::LeftButton ) if( me->buttons() == Qt::LeftButton )
{ {
EffectWindow* w = windowAt( me->pos()); QRect rect;
EffectWindow* w = windowAt( me->pos(), &rect );
if( w->isMovable()) if( w->isMovable())
{ // prepare it for moving { // prepare it for moving
window_move_pos = windowRect( w ).topLeft(); window_move_pos = rect.topLeft();
window_move_diff = window_move_pos - me->pos(); window_move_diff = window_move_pos - me->pos();
window_move = w; window_move = w;
} }

View file

@ -38,7 +38,7 @@ class DesktopGridEffect
QRect desktopRect( int desktop, bool scaled ) const; QRect desktopRect( int desktop, bool scaled ) const;
int posToDesktop( const QPoint& pos ) const; int posToDesktop( const QPoint& pos ) const;
QRect windowRect( EffectWindow* w ) const; // returns always scaled QRect windowRect( EffectWindow* w ) const; // returns always scaled
EffectWindow* windowAt( const QPoint& pos ) const; EffectWindow* windowAt( const QPoint& pos, QRect* rect = NULL ) const;
void setActive( bool active ); void setActive( bool active );
void setup(); void setup();
void finish(); void finish();