diff --git a/tabbox/tabbox.h b/tabbox/tabbox.h --- a/tabbox/tabbox.h +++ b/tabbox/tabbox.h @@ -241,6 +241,8 @@ void shadeActivate(AbstractClient *c); + bool toggleMode(TabBoxMode mode); + private Q_SLOTS: void reconfigure(); void globalShortcutChanged(QAction *action, const QKeySequence &seq); @@ -276,6 +278,8 @@ bool m_forcedGlobalMouseGrab; bool m_ready; // indicates whether the config is completely loaded QList m_borderActivate, m_borderAlternativeActivate; + QHash m_touchActivate; + QHash m_touchAlternativeActivate; static TabBox *s_self; }; diff --git a/tabbox/tabbox.cpp b/tabbox/tabbox.cpp --- a/tabbox/tabbox.cpp +++ b/tabbox/tabbox.cpp @@ -815,6 +815,29 @@ borders = &m_borderAlternativeActivate; borderConfig = QStringLiteral("BorderAlternativeActivate"); } + + auto touchConfig = [this, config] (const QString &key, QHash &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) @@ -1221,6 +1244,15 @@ 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. if (isDisplayed()) { @@ -1230,10 +1262,7 @@ 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;