Work properly even with idle paint passes (react on mouse events).
svn path=/branches/work/kwin_composite/; revision=653927
This commit is contained in:
parent
10bfb82e8c
commit
672c95e435
9 changed files with 67 additions and 28 deletions
|
@ -220,6 +220,7 @@ void Workspace::performCompositing()
|
|||
// is started.
|
||||
if( lastCompositePaint.elapsed() < 5 )
|
||||
return;
|
||||
checkCursorPos();
|
||||
if( repaints_region.isEmpty() && !windowRepaintsPending()) // no damage
|
||||
{
|
||||
scene->idle();
|
||||
|
|
|
@ -101,5 +101,13 @@ QRect TaskbarThumbnailEffect::getThumbnailPosition( EffectWindow* c, int* space
|
|||
return thumb;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
void TaskbarThumbnailEffect::cursorMoved( const QPoint& pos, Qt::MouseButtons )
|
||||
{
|
||||
// this should check if the mouse position change actually means something
|
||||
// (just like it should be done in prePaintScreen()), but since this effect
|
||||
// will be replaced in the future, just trigger a repaint
|
||||
if( pos != mLastCursorPos )
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -34,7 +34,7 @@ class TaskbarThumbnailEffect
|
|||
virtual void prePaintScreen( int* mask, QRegion* region, int time );
|
||||
virtual void prePaintWindow( EffectWindow* w, int* mask, QRegion* paint, QRegion* clip, int time );
|
||||
virtual void postPaintScreen();
|
||||
|
||||
void cursorMoved( const QPoint& pos, Qt::MouseButtons buttons );
|
||||
|
||||
protected:
|
||||
QRect getThumbnailPosition( EffectWindow* c, int* space ) const;
|
||||
|
|
|
@ -25,6 +25,8 @@ namespace KWin
|
|||
|
||||
KWIN_EFFECT( Magnifier, MagnifierEffect )
|
||||
|
||||
const int FRAME_WIDTH = 5;
|
||||
|
||||
MagnifierEffect::MagnifierEffect()
|
||||
: zoom( 1 )
|
||||
, target_zoom( 1 )
|
||||
|
@ -51,6 +53,7 @@ void MagnifierEffect::prePaintScreen( int* mask, QRegion* region, int time )
|
|||
zoom = qMax( zoom * qMin( 1 - diff, 0.8 ), target_zoom );
|
||||
}
|
||||
effects->prePaintScreen( mask, region, time );
|
||||
*region |= magnifierArea().adjusted( -FRAME_WIDTH, -FRAME_WIDTH, FRAME_WIDTH, FRAME_WIDTH );
|
||||
}
|
||||
|
||||
void MagnifierEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
|
||||
|
@ -77,22 +80,22 @@ void MagnifierEffect::paintScreen( int mask, QRegion region, ScreenPaintData& da
|
|||
glPushAttrib( GL_CURRENT_BIT );
|
||||
glColor4f( 0, 0, 0, 1 ); // black
|
||||
glBegin( GL_QUADS );
|
||||
glVertex2i( area.left() - 5, area.top() - 5 ); // top frame
|
||||
glVertex2i( area.right() + 5, area.top() - 5 );
|
||||
glVertex2i( area.right() + 5, area.top() - 1 );
|
||||
glVertex2i( area.left() - 5, area.top() - 1 );
|
||||
glVertex2i( area.left() - 5, area.top() - 5 ); // left frame
|
||||
glVertex2i( area.left() - 1, area.top() - 5 );
|
||||
glVertex2i( area.left() - 1, area.bottom() + 5 );
|
||||
glVertex2i( area.left() - 5, area.bottom() + 5 );
|
||||
glVertex2i( area.right() + 1, area.top() - 5 ); // right frame
|
||||
glVertex2i( area.right() + 5, area.top() - 5 );
|
||||
glVertex2i( area.right() + 5, area.bottom() + 5 );
|
||||
glVertex2i( area.right() + 1, area.bottom() + 5 );
|
||||
glVertex2i( area.left() - 5, area.bottom() + 1 ); // bottom frame
|
||||
glVertex2i( area.right() + 5, area.bottom() + 1 );
|
||||
glVertex2i( area.right() + 5, area.bottom() + 5 );
|
||||
glVertex2i( area.left() - 5, area.bottom() + 5 );
|
||||
glVertex2i( area.left() - FRAME_WIDTH, area.top() - FRAME_WIDTH ); // top frame
|
||||
glVertex2i( area.right() + FRAME_WIDTH, area.top() - FRAME_WIDTH );
|
||||
glVertex2i( area.right() + FRAME_WIDTH, area.top() - 1 );
|
||||
glVertex2i( area.left() - FRAME_WIDTH, area.top() - 1 );
|
||||
glVertex2i( area.left() - FRAME_WIDTH, area.top() - FRAME_WIDTH ); // left frame
|
||||
glVertex2i( area.left() - 1, area.top() - FRAME_WIDTH );
|
||||
glVertex2i( area.left() - 1, area.bottom() + FRAME_WIDTH );
|
||||
glVertex2i( area.left() - FRAME_WIDTH, area.bottom() + FRAME_WIDTH );
|
||||
glVertex2i( area.right() + 1, area.top() - FRAME_WIDTH ); // right frame
|
||||
glVertex2i( area.right() + FRAME_WIDTH, area.top() - FRAME_WIDTH );
|
||||
glVertex2i( area.right() + FRAME_WIDTH, area.bottom() + FRAME_WIDTH );
|
||||
glVertex2i( area.right() + 1, area.bottom() + FRAME_WIDTH );
|
||||
glVertex2i( area.left() - FRAME_WIDTH, area.bottom() + 1 ); // bottom frame
|
||||
glVertex2i( area.right() + FRAME_WIDTH, area.bottom() + 1 );
|
||||
glVertex2i( area.right() + FRAME_WIDTH, area.bottom() + FRAME_WIDTH );
|
||||
glVertex2i( area.left() - FRAME_WIDTH, area.bottom() + FRAME_WIDTH );
|
||||
glEnd();
|
||||
glPopAttrib();
|
||||
}
|
||||
|
@ -101,12 +104,7 @@ void MagnifierEffect::paintScreen( int mask, QRegion region, ScreenPaintData& da
|
|||
void MagnifierEffect::postPaintScreen()
|
||||
{
|
||||
if( zoom != target_zoom )
|
||||
effects->addRepaintFull();
|
||||
if( zoom != 1.0 )
|
||||
{ // TODO repaint only what's need and when needed
|
||||
// effects->addRepaint( magnifierArea());
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
effects->addRepaint( magnifierArea());
|
||||
effects->postPaintScreen();
|
||||
}
|
||||
|
||||
|
@ -120,7 +118,7 @@ QRect MagnifierEffect::magnifierArea() const
|
|||
void MagnifierEffect::zoomIn()
|
||||
{
|
||||
target_zoom *= 1.2;
|
||||
effects->addRepaintFull();
|
||||
effects->addRepaint( magnifierArea());
|
||||
}
|
||||
|
||||
void MagnifierEffect::zoomOut()
|
||||
|
@ -128,7 +126,7 @@ void MagnifierEffect::zoomOut()
|
|||
target_zoom /= 1.2;
|
||||
if( target_zoom < 1 )
|
||||
target_zoom = 1;
|
||||
effects->addRepaintFull();
|
||||
effects->addRepaint( magnifierArea());
|
||||
}
|
||||
|
||||
void MagnifierEffect::toggle()
|
||||
|
@ -137,7 +135,13 @@ void MagnifierEffect::toggle()
|
|||
target_zoom = 2;
|
||||
else
|
||||
target_zoom = 1;
|
||||
effects->addRepaintFull();
|
||||
effects->addRepaint( magnifierArea());
|
||||
}
|
||||
|
||||
void MagnifierEffect::cursorMoved( const QPoint&, Qt::MouseButtons )
|
||||
{
|
||||
if( zoom != 1 )
|
||||
effects->addRepaint( magnifierArea());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -25,6 +25,7 @@ class MagnifierEffect
|
|||
virtual void prePaintScreen( int* mask, QRegion* region, int time );
|
||||
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
|
||||
virtual void postPaintScreen();
|
||||
void cursorMoved( const QPoint& pos, Qt::MouseButtons buttons );
|
||||
private slots:
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
|
|
|
@ -89,6 +89,12 @@ void ZoomEffect::actualSize()
|
|||
effects->addRepaintFull();
|
||||
}
|
||||
|
||||
void ZoomEffect::cursorMoved( const QPoint&, Qt::MouseButtons )
|
||||
{
|
||||
if( zoom != 1 )
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "zoom.moc"
|
||||
|
|
|
@ -25,6 +25,7 @@ class ZoomEffect
|
|||
virtual void prePaintScreen( int* mask, QRegion* region, int time );
|
||||
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
|
||||
virtual void postPaintScreen();
|
||||
void cursorMoved( const QPoint& pos, Qt::MouseButtons buttons );
|
||||
private slots:
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
|
|
|
@ -2579,6 +2579,7 @@ void Workspace::slotBlockShortcuts( int data )
|
|||
// Optimized version of QCursor::pos() that tries to avoid X roundtrips
|
||||
// by updating the value only when the X timestamp changes.
|
||||
static QPoint last_cursor_pos;
|
||||
static int last_buttons = 0;
|
||||
static Time last_cursor_timestamp = CurrentTime;
|
||||
|
||||
QPoint Workspace::cursorPos()
|
||||
|
@ -2587,7 +2588,14 @@ QPoint Workspace::cursorPos()
|
|||
|| last_cursor_timestamp != QX11Info::appTime())
|
||||
{
|
||||
last_cursor_timestamp = QX11Info::appTime();
|
||||
last_cursor_pos = QCursor::pos();
|
||||
Window root;
|
||||
Window child;
|
||||
int root_x, root_y, win_x, win_y;
|
||||
uint state;
|
||||
XQueryPointer( display(), rootWindow(), &root, &child,
|
||||
&root_x, &root_y, &win_x, &win_y, &state );
|
||||
last_cursor_pos = QPoint( root_x, root_y );
|
||||
last_buttons = state;
|
||||
QTimer::singleShot( 0, this, SLOT( resetCursorPosTime()));
|
||||
}
|
||||
return last_cursor_pos;
|
||||
|
@ -2601,6 +2609,15 @@ void Workspace::resetCursorPosTime()
|
|||
last_cursor_timestamp = CurrentTime;
|
||||
}
|
||||
|
||||
void Workspace::checkCursorPos()
|
||||
{
|
||||
QPoint last = last_cursor_pos;
|
||||
int lastb = last_buttons;
|
||||
cursorPos(); // update if needed
|
||||
if( last != last_cursor_pos || lastb != last_buttons )
|
||||
static_cast< EffectsHandlerImpl* >( effects )->cursorMoved( cursorPos(), x11ToQtMouseButtons( last_buttons ));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "workspace.moc"
|
||||
|
|
|
@ -462,6 +462,7 @@ class Workspace : public QObject, public KDecorationDefines
|
|||
void readShortcuts();
|
||||
void initDesktopPopup();
|
||||
void setupWindowShortcut( Client* c );
|
||||
void checkCursorPos();
|
||||
|
||||
bool startKDEWalkThroughWindows();
|
||||
bool startWalkThroughDesktops( TabBoxMode mode ); // TabBoxDesktopMode | TabBoxDesktopListMode
|
||||
|
|
Loading…
Reference in a new issue