[kwin] Drop handling for mouse motion event compression

Not needed as Qt does it for us in the xcb plugin - see
QXcbConnection::processXcbEvents().
This commit is contained in:
Martin Gräßlin 2014-02-01 09:34:40 +01:00
parent 73e6d9162d
commit 7c7f137832
3 changed files with 14 additions and 71 deletions

View file

@ -177,7 +177,6 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e)
break;
}
case XCB_MOTION_NOTIFY: {
m_mouseMotionTimer->cancel();
auto *mouseEvent = reinterpret_cast<xcb_motion_notify_event_t*>(e);
const QPoint rootPos(mouseEvent->root_x, mouseEvent->root_y);
#ifdef KWIN_BUILD_TABBOX
@ -1301,30 +1300,21 @@ bool Client::motionNotifyEvent(xcb_window_t w, int state, int x, int y, int x_ro
x = this->x(); // translate from grab window to local coords
y = this->y();
}
// mouse motion event compression: the event queue might have multiple motion events
// in that case we are only interested in the last event to not cause too much overhead
// by useless move/resize operations.
// The compression is done using a singleshot QTimer of 0 msec to just move the processing
// to the end of the event queue. In case there is another motion event in the queue it will
// be processed before the timer fires and the processing of the newer motion event cancels
// the running timer. Eventually this code path will be reached again and the timer is
// started again
workspace()->scheduleMouseMotionCompression([this, x, y, x_root, y_root]() {
const QRect oldGeo = geometry();
handleMoveResize(x, y, x_root, y_root);
if (!isFullScreen() && isMove()) {
if (quick_tile_mode != QuickTileNone && oldGeo != geometry()) {
GeometryUpdatesBlocker blocker(this);
setQuickTileMode(QuickTileNone);
moveOffset = QPoint(double(moveOffset.x()) / double(oldGeo.width()) * double(geom_restore.width()),
double(moveOffset.y()) / double(oldGeo.height()) * double(geom_restore.height()));
moveResizeGeom = geom_restore;
handleMoveResize(x, y, x_root, y_root); // fix position
} else if (quick_tile_mode == QuickTileNone && isResizable()) {
checkQuickTilingMaximizationZones(x_root, y_root);
}
const QRect oldGeo = geometry();
handleMoveResize(x, y, x_root, y_root);
if (!isFullScreen() && isMove()) {
if (quick_tile_mode != QuickTileNone && oldGeo != geometry()) {
GeometryUpdatesBlocker blocker(this);
setQuickTileMode(QuickTileNone);
moveOffset = QPoint(double(moveOffset.x()) / double(oldGeo.width()) * double(geom_restore.width()),
double(moveOffset.y()) / double(oldGeo.height()) * double(geom_restore.height()));
moveResizeGeom = geom_restore;
handleMoveResize(x, y, x_root, y_root); // fix position
} else if (quick_tile_mode == QuickTileNone && isResizable()) {
checkQuickTilingMaximizationZones(x_root, y_root);
}
});
}
return true;
}

View file

@ -105,29 +105,6 @@ void ColorMapper::update()
}
}
MouseMotionCompressionTimer::MouseMotionCompressionTimer(QObject *parent)
: QTimer(parent)
{
setSingleShot(true);
setInterval(0);
}
MouseMotionCompressionTimer::~MouseMotionCompressionTimer()
{
}
void MouseMotionCompressionTimer::cancel()
{
disconnect(m_connection);
}
void MouseMotionCompressionTimer::schedule(const std::function< void () > &functor)
{
cancel();
m_connection = connect(this, &MouseMotionCompressionTimer::timeout, functor);
start();
}
Workspace* Workspace::_self = 0;
Workspace::Workspace(bool restore)
@ -158,7 +135,6 @@ Workspace::Workspace(bool restore)
, set_active_client_recursion(0)
, block_stacking_updates(0)
, forced_global_mouse_grab(false)
, m_mouseMotionTimer(new MouseMotionCompressionTimer(this))
{
// If KWin was already running it saved its configuration after loosing the selection -> Reread
QFuture<void> reparseConfigFuture = QtConcurrent::run(options, &Options::reparseConfiguration);

View file

@ -55,7 +55,6 @@ class KillWindow;
class ShortcutDialog;
class UserActionsMenu;
class Compositor;
class MouseMotionCompressionTimer;
class Workspace : public QObject, public KDecorationDefines
{
@ -70,7 +69,6 @@ public:
bool workspaceEvent(xcb_generic_event_t*);
bool workspaceEvent(QEvent*);
void scheduleMouseMotionCompression(const std::function<void ()> &functor);
bool hasClient(const Client*);
@ -532,9 +530,6 @@ private:
QScopedPointer<KillWindow> m_windowKiller;
// compression of mouse motion events
MouseMotionCompressionTimer *m_mouseMotionTimer;
private:
friend bool performTransiencyCheck();
friend Workspace *workspace();
@ -571,18 +566,6 @@ private:
xcb_colormap_t m_installed;
};
class MouseMotionCompressionTimer : public QTimer
{
Q_OBJECT
public:
explicit MouseMotionCompressionTimer(QObject *parent = 0);
virtual ~MouseMotionCompressionTimer();
void schedule(const std::function<void ()> &functor);
void cancel();
private:
QMetaObject::Connection m_connection;
};
//---------------------------------------------------------
// Unsorted
@ -736,12 +719,6 @@ inline bool Workspace::hasClient(const Client* c)
return findClient(ClientMatchPredicate(c));
}
inline
void Workspace::scheduleMouseMotionCompression(const std::function< void () > &functor)
{
m_mouseMotionTimer->schedule(functor);
}
inline Workspace *workspace()
{
return Workspace::_self;