Support new touch screen edge swipe callbacks in TabBox

Summary: Last but not least the TabBox gets adjusted for the new touch callbacks.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D5281
This commit is contained in:
Martin Gräßlin 2017-04-02 18:22:44 +02:00
parent e6aabf5b9f
commit e1a46976e6
2 changed files with 37 additions and 4 deletions

View file

@ -815,6 +815,29 @@ void TabBox::reconfigure()
borders = &m_borderAlternativeActivate;
borderConfig = QStringLiteral("BorderAlternativeActivate");
}
auto touchConfig = [this, config] (const QString &key, QHash<ElectricBorder, QAction *> &actions, TabBoxMode mode) {
// fist erase old config
for (auto it = actions.begin(); it != actions.end(); ) {
delete it.value();
it = actions.erase(it);
}
// now new config
const QStringList list = config.readEntry(key, QStringList());
for (const auto &s : list) {
bool ok;
const int i = s.toInt(&ok);
if (!ok) {
continue;
}
QAction *a = new QAction(this);
connect(a, &QAction::triggered, this, std::bind(&TabBox::toggleMode, this, mode));
ScreenEdges::self()->reserveTouch(ElectricBorder(i), a);
actions.insert(ElectricBorder(i), a);
}
};
touchConfig(QStringLiteral("TouchBorderActivate"), m_touchActivate, TabBoxWindowsMode);
touchConfig(QStringLiteral("TouchBorderAlternativeActivate"), m_touchAlternativeActivate, TabBoxWindowsAlternativeMode);
}
void TabBox::loadConfig(const KConfigGroup& config, TabBoxConfig& tabBoxConfig)
@ -1220,6 +1243,15 @@ void TabBox::shadeActivate(AbstractClient *c)
}
bool TabBox::toggle(ElectricBorder eb)
{
if (m_borderAlternativeActivate.contains(eb)) {
return toggleMode(TabBoxWindowsAlternativeMode);
} else {
return toggleMode(TabBoxWindowsMode);
}
}
bool TabBox::toggleMode(TabBoxMode mode)
{
if (!options->focusPolicyIsReasonable())
return false; // not supported.
@ -1230,10 +1262,7 @@ bool TabBox::toggle(ElectricBorder eb)
if (!establishTabBoxGrab())
return false;
m_noModifierGrab = m_tabGrab = true;
if (m_borderAlternativeActivate.contains(eb))
setMode(TabBoxWindowsAlternativeMode);
else
setMode(TabBoxWindowsMode);
setMode(mode);
reset();
show();
return true;

View file

@ -241,6 +241,8 @@ private:
void shadeActivate(AbstractClient *c);
bool toggleMode(TabBoxMode mode);
private Q_SLOTS:
void reconfigure();
void globalShortcutChanged(QAction *action, const QKeySequence &seq);
@ -276,6 +278,8 @@ private:
bool m_forcedGlobalMouseGrab;
bool m_ready; // indicates whether the config is completely loaded
QList<ElectricBorder> m_borderActivate, m_borderAlternativeActivate;
QHash<ElectricBorder, QAction *> m_touchActivate;
QHash<ElectricBorder, QAction *> m_touchAlternativeActivate;
static TabBox *s_self;
};