diff --git a/input.cpp b/input.cpp index 0f737fa9d6..c78c741203 100644 --- a/input.cpp +++ b/input.cpp @@ -481,6 +481,13 @@ public: class TabBoxInputFilter : public InputEventFilter { public: + bool pointerEvent(QMouseEvent *event, quint32 button) override { + Q_UNUSED(button) + if (!TabBox::TabBox::self() || !TabBox::TabBox::self()->isGrabbed()) { + return false; + } + return TabBox::TabBox::self()->handleMouseEvent(event); + } bool keyEvent(QKeyEvent *event) override { if (!TabBox::TabBox::self() || !TabBox::TabBox::self()->isGrabbed()) { return false; @@ -488,6 +495,12 @@ public: TabBox::TabBox::self()->keyPress(event->modifiers() | event->key()); return true; } + bool wheelEvent(QWheelEvent *event) override { + if (!TabBox::TabBox::self() || !TabBox::TabBox::self()->isGrabbed()) { + return false; + } + return TabBox::TabBox::self()->handleWheelEvent(event); + } }; #endif diff --git a/tabbox/tabbox.cpp b/tabbox/tabbox.cpp index db7c5cd0be..a930f3f2d3 100644 --- a/tabbox/tabbox.cpp +++ b/tabbox/tabbox.cpp @@ -901,6 +901,54 @@ bool TabBox::handleMouseEvent(xcb_motion_notify_event_t *e) return false; } +bool TabBox::handleMouseEvent(QMouseEvent *event) +{ + if (!m_isShown && isDisplayed()) { + // tabbox has been replaced, check effects + if (effects && static_cast(effects)->checkInputWindowEvent(event)) { + return true; + } + } + switch (event->type()) { + case QEvent::MouseMove: + if (!m_tabBox->containsPos(event->globalPos())) { + // filter out all events which are not on the TabBox window. + // We don't want windows to react on the mouse events + return true; + } + return false; + case QEvent::MouseButtonPress: + if ((!m_isShown && isDisplayed()) || !m_tabBox->containsPos(event->globalPos())) { + close(); // click outside closes tab + return true; + } + // fall through + case QEvent::MouseButtonRelease: + default: + // we do not filter it out, the intenal filter takes care + return false; + } + return false; +} + +bool TabBox::handleWheelEvent(QWheelEvent *event) +{ + if (!m_isShown && isDisplayed()) { + // tabbox has been replaced, check effects + if (effects && static_cast(effects)->checkInputWindowEvent(event)) { + return true; + } + } + if (event->angleDelta().y() == 0) { + return false; + } + const QModelIndex index = m_tabBox->nextPrev(event->angleDelta().y() > 0); + if (index.isValid()) { + setCurrentIndex(index); + } + return true; +} + void TabBox::grabbedKeyEvent(QKeyEvent* event) { emit tabBoxKeyEvent(event); diff --git a/tabbox/tabbox.h b/tabbox/tabbox.h index 3b6da64e49..a7bdce6a85 100644 --- a/tabbox/tabbox.h +++ b/tabbox/tabbox.h @@ -31,7 +31,9 @@ along with this program. If not, see . class KConfigGroup; class QAction; +class QMouseEvent; class QKeyEvent; +class QWheelEvent; struct xcb_button_press_event_t; struct xcb_motion_notify_event_t; @@ -162,6 +164,8 @@ public: bool handleMouseEvent(xcb_button_press_event_t *e); bool handleMouseEvent(xcb_motion_notify_event_t *e); + bool handleMouseEvent(QMouseEvent *event); + bool handleWheelEvent(QWheelEvent *event); void grabbedKeyEvent(QKeyEvent* event); bool isGrabbed() const {