diff --git a/effects/flipswitch/flipswitch.cpp b/effects/flipswitch/flipswitch.cpp index d01c51a1ba..6291e12b43 100644 --- a/effects/flipswitch/flipswitch.cpp +++ b/effects/flipswitch/flipswitch.cpp @@ -91,22 +91,6 @@ bool FlipSwitchEffect::supported() void FlipSwitchEffect::reconfigure(ReconfigureFlags) { FlipSwitchConfig::self()->readConfig(); - foreach (ElectricBorder border, m_borderActivate) { - effects->unreserveElectricBorder(border, this); - } - foreach (ElectricBorder border, m_borderActivateAll) { - effects->unreserveElectricBorder(border, this); - } - m_borderActivate.clear(); - m_borderActivateAll.clear(); - foreach (int i, FlipSwitchConfig::borderActivate()) { - m_borderActivate.append(ElectricBorder(i)); - effects->reserveElectricBorder(ElectricBorder(i), this); - } - foreach (int i, FlipSwitchConfig::borderActivateAll()) { - m_borderActivateAll.append(ElectricBorder(i)); - effects->reserveElectricBorder(ElectricBorder(i), this); - } m_tabbox = FlipSwitchConfig::tabBox(); m_tabboxAlternative = FlipSwitchConfig::tabBoxAlternative(); const int duration = animationTime(200); @@ -716,19 +700,6 @@ void FlipSwitchEffect::toggleActiveCurrent() } } -bool FlipSwitchEffect::borderActivated(ElectricBorder border) -{ - if (!m_borderActivate.contains(border) && !m_borderActivateAll.contains(border)) - return false; - if (effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this) - return true; - if (m_borderActivate.contains(border)) - toggleActiveCurrent(); - else - toggleActiveAllDesktops(); - return true; -} - //************************************************************* // Helper function //************************************************************* diff --git a/effects/flipswitch/flipswitch.h b/effects/flipswitch/flipswitch.h index b7001ee2d8..35b67dc45e 100644 --- a/effects/flipswitch/flipswitch.h +++ b/effects/flipswitch/flipswitch.h @@ -42,7 +42,6 @@ class FlipSwitchEffect Q_PROPERTY(qreal xPosition READ xPosition) Q_PROPERTY(qreal yPosition READ yPosition) Q_PROPERTY(bool windowTitle READ isWindowTitle) - // TODO: electric borders public: FlipSwitchEffect(); ~FlipSwitchEffect(); @@ -53,7 +52,6 @@ public: virtual void postPaintScreen(); virtual void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); - virtual bool borderActivated(ElectricBorder border); virtual void grabbedKeyboardEvent(QKeyEvent* e); virtual void windowInputMouseEvent(Window w, QEvent* e); virtual bool isActive() const; @@ -137,8 +135,6 @@ private: EffectWindowList m_flipOrderedWindows; QHash< const EffectWindow*, ItemInfo* > m_windows; // options - QList m_borderActivate; - QList m_borderActivateAll; bool m_tabbox; bool m_tabboxAlternative; float m_angle; diff --git a/effects/flipswitch/flipswitch.kcfg b/effects/flipswitch/flipswitch.kcfg index 94611c11b1..da6fb62a9f 100644 --- a/effects/flipswitch/flipswitch.kcfg +++ b/effects/flipswitch/flipswitch.kcfg @@ -5,8 +5,6 @@ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > - - false diff --git a/events.cpp b/events.cpp index 1dfc287555..98d61d4ade 100644 --- a/events.cpp +++ b/events.cpp @@ -259,11 +259,20 @@ bool Workspace::workspaceEvent(XEvent * e) case MotionNotify: #ifdef KWIN_BUILD_TABBOX if (TabBox::TabBox::self()->isGrabbed()) { +#ifdef KWIN_BUILD_SCREENEDGES + ScreenEdges::self()->check(QPoint(e->xbutton.x_root, e->xbutton.y_root), QDateTime::fromMSecsSinceEpoch(xTime()), true); +#endif return TabBox::TabBox::self()->handleMouseEvent(e); } #endif - if (effects && static_cast(effects)->checkInputWindowEvent(e)) + if (effects && static_cast(effects)->checkInputWindowEvent(e)) { return true; + } +#ifdef KWIN_BUILD_SCREENEDGES + if (QWidget::mouseGrabber()) { + ScreenEdges::self()->check(QPoint(e->xbutton.x_root, e->xbutton.y_root), QDateTime::fromMSecsSinceEpoch(xTime()), true); + } +#endif break; case KeyPress: { was_user_interaction = true; diff --git a/kcmkwin/kwinscreenedges/main.cpp b/kcmkwin/kwinscreenedges/main.cpp index e7a42e77a4..e07cba6cf8 100644 --- a/kcmkwin/kwinscreenedges/main.cpp +++ b/kcmkwin/kwinscreenedges/main.cpp @@ -216,16 +216,9 @@ void KWinScreenEdgesConfig::monitorInit() monitorAddItem(services.first()->name() + " - " + i18n("Cylinder")); monitorAddItem(services.first()->name() + " - " + i18n("Sphere")); } - services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_flipswitch'"); - if (services.isEmpty()) { - // adding empty strings in case the effect is not found - // TODO: after string freeze add a info that the effect is missing - monitorAddItem(QString()); - monitorAddItem(QString()); - } else { - monitorAddItem(services.first()->name() + " - " + i18n("All Desktops")); - monitorAddItem(services.first()->name() + " - " + i18n("Current Desktop")); - } + + monitorAddItem(i18n("Toggle window switching")); + monitorAddItem(i18n("Toggle alternative window switching")); monitorShowEvent(); } @@ -308,21 +301,21 @@ void KWinScreenEdgesConfig::monitorLoad() monitorChangeEdge(ElectricBorder(i), int(Sphere)); } - // Flip Switch - KConfigGroup flipSwitchConfig(m_config, "Effect-FlipSwitch"); + // TabBox + KConfigGroup tabBoxConfig(m_config, "TabBox"); list.clear(); - // FlipSwitch BorderActivateAll + // TabBox list.append(int(ElectricNone)); - list = flipSwitchConfig.readEntry("BorderActivateAll", list); + list = tabBoxConfig.readEntry("BorderActivate", list); foreach (int i, list) { - monitorChangeEdge(ElectricBorder(i), int(FlipSwitchAll)); + monitorChangeEdge(ElectricBorder(i), int(TabBox)); } - // FlipSwitch BorderActivate + // Alternative TabBox list.clear(); list.append(int(ElectricNone)); - list = flipSwitchConfig.readEntry("BorderActivate", list); + list = tabBoxConfig.readEntry("BorderAlternativeActivate", list); foreach (int i, list) { - monitorChangeEdge(ElectricBorder(i), int(FlipSwitchCurrent)); + monitorChangeEdge(ElectricBorder(i), int(TabBoxAlternative)); } } @@ -389,12 +382,12 @@ void KWinScreenEdgesConfig::monitorSave() cubeConfig.writeEntry("BorderActivateSphere", monitorCheckEffectHasEdge(int(Sphere))); - // Flip Switch - KConfigGroup flipSwitchConfig(m_config, "Effect-FlipSwitch"); - flipSwitchConfig.writeEntry("BorderActivateAll", - monitorCheckEffectHasEdge(int(FlipSwitchAll))); - flipSwitchConfig.writeEntry("BorderActivate", - monitorCheckEffectHasEdge(int(FlipSwitchCurrent))); + // TabBox + KConfigGroup tabBoxConfig(m_config, "TabBox"); + tabBoxConfig.writeEntry("BorderActivate", + monitorCheckEffectHasEdge(int(TabBox))); + tabBoxConfig.writeEntry("BorderAlternativeActivate", + monitorCheckEffectHasEdge(int(TabBoxAlternative))); } void KWinScreenEdgesConfig::monitorDefaults() @@ -429,11 +422,6 @@ void KWinScreenEdgesConfig::monitorShowEvent() monitorItemSetEnabled(int(Cube), enabled); monitorItemSetEnabled(int(Cylinder), enabled); monitorItemSetEnabled(int(Sphere), enabled); - - // Flip Switch - enabled = effectEnabled("flipswitch", config); - monitorItemSetEnabled(int(FlipSwitchAll), enabled); - monitorItemSetEnabled(int(FlipSwitchCurrent), enabled); } else { // Compositing disabled monitorItemSetEnabled(int(PresentWindowsCurrent), false); monitorItemSetEnabled(int(PresentWindowsAll), false); @@ -441,9 +429,13 @@ void KWinScreenEdgesConfig::monitorShowEvent() monitorItemSetEnabled(int(Cube), false); monitorItemSetEnabled(int(Cylinder), false); monitorItemSetEnabled(int(Sphere), false); - monitorItemSetEnabled(int(FlipSwitchAll), false); - monitorItemSetEnabled(int(FlipSwitchCurrent), false); } + // tabbox, depends on reasonable focus policy. + KConfigGroup config2(m_config, "Windows"); + QString focusPolicy = config2.readEntry("FocusPolicy", QString()); + bool reasonable = focusPolicy != "FocusStrictlyUnderMouse" && focusPolicy != "FocusUnderMouse"; + monitorItemSetEnabled(int(TabBox), reasonable); + monitorItemSetEnabled(int(TabBoxAlternative), reasonable); } void KWinScreenEdgesConfig::monitorChangeEdge(ElectricBorder border, int index) diff --git a/kcmkwin/kwinscreenedges/main.h b/kcmkwin/kwinscreenedges/main.h index d2e9a24671..ec802d6be2 100644 --- a/kcmkwin/kwinscreenedges/main.h +++ b/kcmkwin/kwinscreenedges/main.h @@ -69,8 +69,8 @@ private: Cube, Cylinder, Sphere, - FlipSwitchAll, - FlipSwitchCurrent + TabBox, + TabBoxAlternative }; bool effectEnabled(const QString& effect, const KConfigGroup& cfg) const; diff --git a/tabbox/tabbox.cpp b/tabbox/tabbox.cpp index 34e84f88fb..205dfa94ef 100644 --- a/tabbox/tabbox.cpp +++ b/tabbox/tabbox.cpp @@ -35,6 +35,7 @@ along with this program. If not, see . #include "client.h" #include "effects.h" #include "focuschain.h" +#include "screenedge.h" #include "screens.h" #include "virtualdesktops.h" #include "workspace.h" @@ -743,6 +744,26 @@ void TabBox::reconfigure() m_delayShow = config.readEntry("ShowDelay", true); m_delayShowTime = config.readEntry("DelayTime", 90); + + QList *borders = &m_borderActivate; + QString borderConfig = "BorderActivate"; + for (int i = 0; i < 2; ++i) { + foreach (ElectricBorder border, *borders) { + ScreenEdges::self()->unreserve(border, this); + } + borders->clear(); + QStringList list = config.readEntry(borderConfig, QStringList()); + foreach (const QString &s, list) { + bool ok; + const int i = s.toInt(&ok); + if (!ok) + continue; + borders->append(ElectricBorder(i)); + ScreenEdges::self()->reserve(ElectricBorder(i), this, "toggle"); + } + borders = &m_borderAlternativeActivate; + borderConfig = "BorderAlternativeActivate"; + } } void TabBox::loadConfig(const KConfigGroup& config, TabBoxConfig& tabBoxConfig) @@ -1124,6 +1145,27 @@ void TabBox::modalActionsSwitch(bool enabled) action->setEnabled(enabled); } +bool TabBox::toggle(ElectricBorder eb) +{ + if (!options->focusPolicyIsReasonable()) + return false; // not supported. + if (isDisplayed()) { + ungrabXKeyboard(); + accept(); + return true; + } + if (!grabXKeyboard()) + return false; + m_noModifierGrab = m_tabGrab = true; + if (m_borderAlternativeActivate.contains(eb)) + setMode(TabBoxWindowsAlternativeMode); + else + setMode(TabBoxWindowsMode); + reset(); + show(); + return true; +} + void TabBox::open(bool modal, const QString &layout) { if (isDisplayed()) { diff --git a/tabbox/tabbox.h b/tabbox/tabbox.h index 82e3c19ded..03a3962cb1 100644 --- a/tabbox/tabbox.h +++ b/tabbox/tabbox.h @@ -235,6 +235,8 @@ public slots: void handlerReady(); + bool toggle(ElectricBorder eb); + signals: void tabBoxAdded(int); Q_SCRIPTABLE void tabBoxClosed(); @@ -297,6 +299,7 @@ private: KShortcut m_cutWalkThroughCurrentAppWindowsAlternative, m_cutWalkThroughCurrentAppWindowsAlternativeReverse; bool m_forcedGlobalMouseGrab; bool m_ready; // indicates whether the config is completely loaded + QList m_borderActivate, m_borderAlternativeActivate; static TabBox *s_self; };