Fix and re-enable optimized cursorPos().
svn path=/branches/work/kwin_composite/; revision=653895
This commit is contained in:
parent
6cae287d2a
commit
15c8a4220e
9 changed files with 43 additions and 34 deletions
11
effects.cpp
11
effects.cpp
|
@ -272,11 +272,6 @@ int EffectsHandlerImpl::displayHeight() const
|
|||
return KWin::displayWidth();
|
||||
}
|
||||
|
||||
QPoint EffectsHandlerImpl::cursorPos() const
|
||||
{
|
||||
return KWin::cursorPos();
|
||||
}
|
||||
|
||||
EffectWindowList EffectsHandlerImpl::stackingOrder() const
|
||||
{
|
||||
ClientList list = Workspace::self()->stackingOrder();
|
||||
|
@ -421,6 +416,7 @@ bool EffectsHandlerImpl::checkInputWindowEvent( XEvent* e )
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void EffectsHandlerImpl::checkInputWindowStacking()
|
||||
{
|
||||
if( input_windows.count() == 0 )
|
||||
|
@ -434,6 +430,11 @@ void EffectsHandlerImpl::checkInputWindowStacking()
|
|||
delete[] wins;
|
||||
}
|
||||
|
||||
QPoint EffectsHandlerImpl::cursorPos() const
|
||||
{
|
||||
return Workspace::self()->cursorPos();
|
||||
}
|
||||
|
||||
void EffectsHandlerImpl::checkElectricBorder(const QPoint &pos, Time time)
|
||||
{
|
||||
Workspace::self()->checkElectricBorder( pos, time );
|
||||
|
|
|
@ -182,7 +182,7 @@ int Effect::displayHeight()
|
|||
|
||||
QPoint Effect::cursorPos()
|
||||
{
|
||||
return KWin::cursorPos();
|
||||
return effects->cursorPos();
|
||||
}
|
||||
|
||||
//****************************************
|
||||
|
|
|
@ -170,6 +170,7 @@ class KWIN_EXPORT EffectsHandler
|
|||
virtual Window createInputWindow( Effect* e, const QRect& r, const QCursor& cursor );
|
||||
virtual Window createFullScreenInputWindow( Effect* e, const QCursor& cursor );
|
||||
virtual void destroyInputWindow( Window w ) = 0;
|
||||
virtual QPoint cursorPos() const = 0;
|
||||
|
||||
virtual void checkElectricBorder(const QPoint &pos, Time time) = 0;
|
||||
virtual void reserveElectricBorder( ElectricBorder border ) = 0;
|
||||
|
|
|
@ -10,34 +10,8 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
|
||||
#include "kwinglobals.h"
|
||||
|
||||
#include <QCursor>
|
||||
|
||||
#include "kdebug.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
|
||||
// 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 Time last_cursor_timestamp = CurrentTime;
|
||||
|
||||
QPoint cursorPos()
|
||||
{
|
||||
last_cursor_timestamp = CurrentTime;
|
||||
if( last_cursor_timestamp == CurrentTime
|
||||
|| last_cursor_timestamp != QX11Info::appTime())
|
||||
{
|
||||
last_cursor_timestamp = QX11Info::appTime();
|
||||
last_cursor_pos = QCursor::pos();
|
||||
}
|
||||
return last_cursor_pos;
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -131,8 +131,6 @@ KWIN_EXPORT int displayHeight()
|
|||
return XDisplayHeight( display(), DefaultScreen( display()));
|
||||
}
|
||||
|
||||
KWIN_EXPORT QPoint cursorPos();
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
|
|
@ -36,6 +36,7 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
|
||||
#include "atoms.h"
|
||||
#include "notifications.h"
|
||||
#include "workspace.h"
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -353,6 +354,11 @@ bool grabbedXServer()
|
|||
return server_grab_count > 0;
|
||||
}
|
||||
|
||||
QPoint cursorPos()
|
||||
{
|
||||
return Workspace::self()->cursorPos();
|
||||
}
|
||||
|
||||
// converting between X11 mouse/keyboard state mask and Qt button/keyboard states
|
||||
|
||||
int qtToX11Button( Qt::MouseButton button )
|
||||
|
|
2
utils.h
2
utils.h
|
@ -308,6 +308,8 @@ Time timestampDiff( Time time1, Time time2 ) // returns time2 - time1
|
|||
|
||||
bool isLocalMachine( const QByteArray& host );
|
||||
|
||||
QPoint cursorPos();
|
||||
|
||||
// converting between X11 mouse/keyboard state mask and Qt button/keyboard states
|
||||
int qtToX11Button( Qt::MouseButton button );
|
||||
Qt::MouseButton x11ToQtMouseButton( int button );
|
||||
|
|
|
@ -2576,6 +2576,31 @@ void Workspace::slotBlockShortcuts( int data )
|
|||
(*it)->updateMouseGrab();
|
||||
}
|
||||
|
||||
// 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 Time last_cursor_timestamp = CurrentTime;
|
||||
|
||||
QPoint Workspace::cursorPos()
|
||||
{
|
||||
if( last_cursor_timestamp == CurrentTime
|
||||
|| last_cursor_timestamp != QX11Info::appTime())
|
||||
{
|
||||
last_cursor_timestamp = QX11Info::appTime();
|
||||
last_cursor_pos = QCursor::pos();
|
||||
QTimer::singleShot( 0, this, SLOT( resetCursorPosTime()));
|
||||
}
|
||||
return last_cursor_pos;
|
||||
}
|
||||
|
||||
// Because of QTimer's and the impossibility to get events for all mouse
|
||||
// movements (at least I haven't figured out how) the position needs
|
||||
// to be also refetched after each return to the event loop.
|
||||
void Workspace::resetCursorPosTime()
|
||||
{
|
||||
last_cursor_timestamp = CurrentTime;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "workspace.moc"
|
||||
|
|
|
@ -279,6 +279,7 @@ class Workspace : public QObject, public KDecorationDefines
|
|||
bool globalShortcutsDisabled() const;
|
||||
void disableGlobalShortcuts( bool disable );
|
||||
void disableGlobalShortcutsForClient( bool disable );
|
||||
QPoint cursorPos();
|
||||
|
||||
void sessionSaveStarted();
|
||||
void sessionSaveDone();
|
||||
|
@ -449,6 +450,7 @@ class Workspace : public QObject, public KDecorationDefines
|
|||
void performCompositing();
|
||||
void lostCMSelection();
|
||||
void updateElectricBorders();
|
||||
void resetCursorPosTime();
|
||||
|
||||
protected:
|
||||
bool keyPressMouseEmulation( XKeyEvent& ev );
|
||||
|
|
Loading…
Reference in a new issue