general tabbox support for screenedges
REVIEW: 109362 BUG: 316288 FIXED-IN: 4.11
This commit is contained in:
parent
c6ff7932c2
commit
8cf6e39eab
8 changed files with 80 additions and 69 deletions
|
@ -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<FlipSwitchConfig>(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
|
||||
//*************************************************************
|
||||
|
|
|
@ -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<ElectricBorder> m_borderActivate;
|
||||
QList<ElectricBorder> m_borderActivateAll;
|
||||
bool m_tabbox;
|
||||
bool m_tabboxAlternative;
|
||||
float m_angle;
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
|
||||
<kcfgfile name="kwinrc"/>
|
||||
<group name="Effect-FlipSwitch">
|
||||
<entry name="BorderActivate" type="IntList" />
|
||||
<entry name="BorderActivateAll" type="IntList" />
|
||||
<entry name="TabBox" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
|
|
11
events.cpp
11
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<EffectsHandlerImpl*>(effects)->checkInputWindowEvent(e))
|
||||
if (effects && static_cast<EffectsHandlerImpl*>(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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -69,8 +69,8 @@ private:
|
|||
Cube,
|
||||
Cylinder,
|
||||
Sphere,
|
||||
FlipSwitchAll,
|
||||
FlipSwitchCurrent
|
||||
TabBox,
|
||||
TabBoxAlternative
|
||||
};
|
||||
|
||||
bool effectEnabled(const QString& effect, const KConfigGroup& cfg) const;
|
||||
|
|
|
@ -35,6 +35,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#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<bool>("ShowDelay", true);
|
||||
m_delayShowTime = config.readEntry<int>("DelayTime", 90);
|
||||
|
||||
QList<ElectricBorder> *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()) {
|
||||
|
|
|
@ -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<ElectricBorder> m_borderActivate, m_borderAlternativeActivate;
|
||||
|
||||
static TabBox *s_self;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue