Changeset View
Changeset View
Standalone View
Standalone View
tabbox/tabboxhandler.cpp
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Line(s) | 58 | public: | |||
---|---|---|---|---|---|
87 | ClientModel* m_clientModel; | 87 | ClientModel* m_clientModel; | ||
88 | DesktopModel* m_desktopModel; | 88 | DesktopModel* m_desktopModel; | ||
89 | QModelIndex index; | 89 | QModelIndex index; | ||
90 | /** | 90 | /** | ||
91 | * Indicates if the tabbox is shown. | 91 | * Indicates if the tabbox is shown. | ||
92 | */ | 92 | */ | ||
93 | bool isShown; | 93 | bool isShown; | ||
94 | TabBoxClient *lastRaisedClient, *lastRaisedClientSucc; | 94 | TabBoxClient *lastRaisedClient, *lastRaisedClientSucc; | ||
95 | int wheelAngleDelta = 0; | ||||
95 | 96 | | |||
96 | private: | 97 | private: | ||
97 | QObject *createSwitcherItem(bool desktopMode); | 98 | QObject *createSwitcherItem(bool desktopMode); | ||
98 | }; | 99 | }; | ||
99 | 100 | | |||
100 | TabBoxHandlerPrivate::TabBoxHandlerPrivate(TabBoxHandler *q) | 101 | TabBoxHandlerPrivate::TabBoxHandlerPrivate(TabBoxHandler *q) | ||
101 | : m_qmlContext() | 102 | : m_qmlContext() | ||
102 | , m_qmlComponent() | 103 | , m_qmlComponent() | ||
▲ Show 20 Lines • Show All 228 Lines • ▼ Show 20 Line(s) | 326 | if (!item->model()) { | |||
331 | } | 332 | } | ||
332 | item->setModel(model); | 333 | item->setModel(model); | ||
333 | } | 334 | } | ||
334 | item->setAllDesktops(config.clientDesktopMode() == TabBoxConfig::AllDesktopsClients); | 335 | item->setAllDesktops(config.clientDesktopMode() == TabBoxConfig::AllDesktopsClients); | ||
335 | item->setCurrentIndex(index.row()); | 336 | item->setCurrentIndex(index.row()); | ||
336 | // everything is prepared, so let's make the whole thing visible | 337 | // everything is prepared, so let's make the whole thing visible | ||
337 | item->setVisible(true); | 338 | item->setVisible(true); | ||
338 | } | 339 | } | ||
340 | if (QWindow *w = window()) { | ||||
341 | wheelAngleDelta = 0; | ||||
342 | w->installEventFilter(q); | ||||
343 | } | ||||
339 | #endif | 344 | #endif | ||
340 | } | 345 | } | ||
341 | 346 | | |||
342 | /*********************************************** | 347 | /*********************************************** | ||
343 | * TabBoxHandler | 348 | * TabBoxHandler | ||
344 | ***********************************************/ | 349 | ***********************************************/ | ||
345 | 350 | | |||
346 | TabBoxHandler::TabBoxHandler(QObject *parent) | 351 | TabBoxHandler::TabBoxHandler(QObject *parent) | ||
▲ Show 20 Lines • Show All 255 Lines • ▼ Show 20 Line(s) | 606 | case TabBoxConfig::DesktopTabBox: | |||
602 | model = d->desktopModel(); | 607 | model = d->desktopModel(); | ||
603 | break; | 608 | break; | ||
604 | default: | 609 | default: | ||
605 | return QModelIndex(); | 610 | return QModelIndex(); | ||
606 | } | 611 | } | ||
607 | return model->index(0, 0); | 612 | return model->index(0, 0); | ||
608 | } | 613 | } | ||
609 | 614 | | |||
615 | bool TabBoxHandler::eventFilter(QObject *watched, QEvent *e) | ||||
616 | { | ||||
617 | if (e->type() == QEvent::Wheel && watched == d->window()) { | ||||
618 | QWheelEvent *event = static_cast<QWheelEvent*>(e); | ||||
luebking: test type first - you'll get many paint events etc. but the filter is installed to only one… | |||||
619 | // On x11 the delta for vertical scrolling might also be on X for whatever reason | ||||
620 | const int delta = qAbs(event->angleDelta().x()) > qAbs(event->angleDelta().y()) ? event->angleDelta().x() : event->angleDelta().y(); | ||||
621 | d->wheelAngleDelta += delta; | ||||
luebking: x + y? | |||||
dangerous. If there is a scrolling in both horizontal and vertical (could happen on touchpad) it could result in no scrolling if one is negative and the other is positive. graesslin: dangerous. If there is a scrolling in both horizontal and vertical (could happen on touchpad)… | |||||
One might call that unsoecific user behavior :-P -> pick the only with the bigger absolute? luebking: One might call that unsoecific user behavior :-P
But on that touchpad the present… | |||||
622 | while (d->wheelAngleDelta <= -120) { | ||||
623 | d->wheelAngleDelta += 120; | ||||
624 | const QModelIndex index = nextPrev(true); | ||||
625 | if (index.isValid()) { | ||||
626 | setCurrentIndex(index); | ||||
draw the indev var out, find the last one and if it's in the end valid, set it only once? luebking: draw the indev var out, find the last one and if it's in the end valid, set it only once? | |||||
just checked - doesn't work as nextPrev doesn't update the reference, but just returns the index for the next one. Without setting the index, the next call would return the same index. graesslin: just checked - doesn't work as nextPrev doesn't update the reference, but just returns the… | |||||
627 | } | ||||
628 | } | ||||
629 | while (d->wheelAngleDelta >= 120) { | ||||
630 | d->wheelAngleDelta -= 120; | ||||
631 | const QModelIndex index = nextPrev(false); | ||||
632 | if (index.isValid()) { | ||||
633 | setCurrentIndex(index); | ||||
634 | } | ||||
635 | } | ||||
636 | return true; | ||||
637 | } | ||||
638 | // pass on | ||||
639 | return QObject::eventFilter(watched, e); | ||||
640 | } | ||||
641 | | ||||
610 | TabBoxHandler* tabBox = nullptr; | 642 | TabBoxHandler* tabBox = nullptr; | ||
611 | 643 | | |||
612 | TabBoxClient::TabBoxClient() | 644 | TabBoxClient::TabBoxClient() | ||
613 | { | 645 | { | ||
614 | } | 646 | } | ||
615 | 647 | | |||
616 | TabBoxClient::~TabBoxClient() | 648 | TabBoxClient::~TabBoxClient() | ||
617 | { | 649 | { | ||
618 | } | 650 | } | ||
619 | 651 | | |||
620 | } // namespace TabBox | 652 | } // namespace TabBox | ||
621 | } // namespace KWin | 653 | } // namespace KWin |
test type first - you'll get many paint events etc. but the filter is installed to only one object, ie. first check will currently always hit and second very few times only