From 7c7f13783277a7255bf5a94c977d807cc421b4f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sat, 1 Feb 2014 09:34:40 +0100 Subject: [PATCH] [kwin] Drop handling for mouse motion event compression Not needed as Qt does it for us in the xcb plugin - see QXcbConnection::processXcbEvents(). --- events.cpp | 38 ++++++++++++++------------------------ workspace.cpp | 24 ------------------------ workspace.h | 23 ----------------------- 3 files changed, 14 insertions(+), 71 deletions(-) diff --git a/events.cpp b/events.cpp index a1f348ca8a..638078441a 100644 --- a/events.cpp +++ b/events.cpp @@ -177,7 +177,6 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e) break; } case XCB_MOTION_NOTIFY: { - m_mouseMotionTimer->cancel(); auto *mouseEvent = reinterpret_cast(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; } diff --git a/workspace.cpp b/workspace.cpp index 36e5dd911f..13830b99f1 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -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 reparseConfigFuture = QtConcurrent::run(options, &Options::reparseConfiguration); diff --git a/workspace.h b/workspace.h index 81e0a83210..759119b637 100644 --- a/workspace.h +++ b/workspace.h @@ -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 &functor); bool hasClient(const Client*); @@ -532,9 +530,6 @@ private: QScopedPointer 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 &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;