Key Bindings for Switching between Windows of current Application

Additional TabBox Mode which allows to switch between all open
windows of the current selected application. By default Alt+tilde
is used which is on qwerty just one key above tab. For non-qwerty
layouts the shortcut is unfortunately not convenient.

REVIEW: 104730
FEATURE: 299308
FIXED-IN: 4.9.0
This commit is contained in:
Ghislain MARY 2012-04-25 22:57:48 +02:00 committed by Martin Gräßlin
parent ee92a35f39
commit c66c78f1d2
6 changed files with 140 additions and 12 deletions

View file

@ -533,7 +533,9 @@ void CoverSwitchEffect::slotTabBoxAdded(int mode)
if (!mActivated) {
// only for windows mode
if (((mode == TabBoxWindowsMode && primaryTabBox) ||
(mode == TabBoxWindowsAlternativeMode && secondaryTabBox))
(mode == TabBoxWindowsAlternativeMode && secondaryTabBox) ||
(mode == TabBoxCurrentAppWindowsMode && primaryTabBox) ||
(mode == TabBoxCurrentAppWindowsAlternativeMode && secondaryTabBox))
&& effects->currentTabBoxWindowList().count() > 0) {
input = effects->createFullScreenInputWindow(this, Qt::ArrowCursor);
activeScreen = effects->activeScreen();

View file

@ -513,7 +513,9 @@ void FlipSwitchEffect::slotTabBoxAdded(int mode)
return;
// only for windows mode
if (((mode == TabBoxWindowsMode && m_tabbox) ||
(mode == TabBoxWindowsAlternativeMode && m_tabboxAlternative))
(mode == TabBoxWindowsAlternativeMode && m_tabboxAlternative) ||
(mode == TabBoxCurrentAppWindowsMode && m_tabbox) ||
(mode == TabBoxCurrentAppWindowsAlternativeMode && m_tabboxAlternative))
&& (!m_active || (m_active && m_stop))
&& !effects->currentTabBoxWindowList().isEmpty()) {
setActive(true, TabboxMode);

View file

@ -93,6 +93,22 @@ KWinTabBoxConfig::KWinTabBoxConfig(QWidget* parent, const QVariantList& args)
a->setProperty("isConfigurationAction", true);
a->setText(i18n("Walk Through Windows Alternative (Reverse)"));
a->setGlobalShortcut(KShortcut(), KAction::ActiveShortcut);
a = qobject_cast<KAction*>(m_actionCollection->addAction("Walk Through Windows of Current Application"));
a->setProperty("isConfigurationAction", true);
a->setText(i18n("Walk Through Windows of Current Application"));
a->setGlobalShortcut(KShortcut(Qt::ALT + Qt::Key_QuoteLeft));
a = qobject_cast<KAction*>(m_actionCollection->addAction("Walk Through Windows of Current Application (Reverse)"));
a->setProperty("isConfigurationAction", true);
a->setText(i18n("Walk Through Windows of Current Application (Reverse)"));
a->setGlobalShortcut(KShortcut(Qt::ALT + Qt::Key_AsciiTilde));
a = qobject_cast<KAction*>(m_actionCollection->addAction("Walk Through Windows of Current Application Alternative"));
a->setProperty("isConfigurationAction", true);
a->setText(i18n("Walk Through Windows of Current Application Alternative"));
a->setGlobalShortcut(KShortcut(), KAction::ActiveShortcut);
a = qobject_cast<KAction*>(m_actionCollection->addAction("Walk Through Windows of Current Application Alternative (Reverse)"));
a->setProperty("isConfigurationAction", true);
a->setText(i18n("Walk Through Windows of Current Application Alternative (Reverse)"));
a->setGlobalShortcut(KShortcut(), KAction::ActiveShortcut);
m_editor->addCollection(m_actionCollection, i18n("Navigation"));
layout->addWidget(m_editor);
setLayout(layout);

View file

@ -99,10 +99,12 @@ enum ElectricBorderAction {
// or window were viewed.
// DesktopListMode lists them in the order created.
enum TabBoxMode {
TabBoxDesktopMode, // Focus chain of desktops
TabBoxDesktopListMode, // Static desktop order
TabBoxWindowsMode, // Primary window switching mode
TabBoxWindowsAlternativeMode // Secondary window switching mode
TabBoxDesktopMode, // Focus chain of desktops
TabBoxDesktopListMode, // Static desktop order
TabBoxWindowsMode, // Primary window switching mode
TabBoxWindowsAlternativeMode, // Secondary window switching mode
TabBoxCurrentAppWindowsMode, // Same as primary window switching mode but only for windows of current application
TabBoxCurrentAppWindowsAlternativeMode, // Same as secondary switching mode but only for windows of current application
};
enum KWinOption {

View file

@ -408,6 +408,12 @@ TabBox::TabBox(QObject *parent)
m_alternativeConfig.setClientSwitchingMode(TabBoxConfig::FocusChainSwitching);
m_alternativeConfig.setLayout(TabBoxConfig::VerticalLayout);
m_defaultCurrentApplicationConfig = m_defaultConfig;
m_defaultCurrentApplicationConfig.setClientApplicationsMode(TabBoxConfig::AllWindowsCurrentApplication);
m_alternativeCurrentApplicationConfig = m_alternativeConfig;
m_alternativeCurrentApplicationConfig.setClientApplicationsMode(TabBoxConfig::AllWindowsCurrentApplication);
m_desktopConfig = TabBoxConfig();
m_desktopConfig.setTabBoxMode(TabBoxConfig::DesktopTabBox);
m_desktopConfig.setShowTabBox(true);
@ -463,6 +469,10 @@ void TabBox::initShortcuts(KActionCollection* keys)
KEY(I18N_NOOP("Walk Through Windows (Reverse)"), Qt::ALT + Qt::SHIFT + Qt::Key_Backtab, slotWalkBackThroughWindows(), m_cutWalkThroughWindowsReverse, slotWalkBackThroughWindowsKeyChanged(QKeySequence))
KEY(I18N_NOOP("Walk Through Windows Alternative"), 0, slotWalkThroughWindowsAlternative(), m_cutWalkThroughWindowsAlternative, slotWalkThroughWindowsAlternativeKeyChanged(QKeySequence))
KEY(I18N_NOOP("Walk Through Windows Alternative (Reverse)"), 0, slotWalkBackThroughWindowsAlternative(), m_cutWalkThroughWindowsAlternativeReverse, slotWalkBackThroughWindowsAlternativeKeyChanged(QKeySequence))
KEY(I18N_NOOP("Walk Through Windows of Current Application"), Qt::ALT + Qt::Key_QuoteLeft, slotWalkThroughCurrentAppWindows(), m_cutWalkThroughCurrentAppWindows, slotWalkThroughCurrentAppWindowsKeyChanged(QKeySequence))
KEY(I18N_NOOP("Walk Through Windows of Current Application (Reverse)"), Qt::ALT + Qt::Key_AsciiTilde, slotWalkBackThroughCurrentAppWindows(), m_cutWalkThroughCurrentAppWindowsReverse, slotWalkBackThroughCurrentAppWindowsKeyChanged(QKeySequence))
KEY(I18N_NOOP("Walk Through Windows of Current Application Alternative"), 0, slotWalkThroughCurrentAppWindowsAlternative(), m_cutWalkThroughCurrentAppWindowsAlternative, slotWalkThroughCurrentAppWindowsAlternativeKeyChanged(QKeySequence))
KEY(I18N_NOOP("Walk Through Windows of Current Application Alternative (Reverse)"), 0, slotWalkBackThroughCurrentAppWindowsAlternative(), m_cutWalkThroughCurrentAppWindowsAlternativeReverse, slotWalkBackThroughCurrentAppWindowsAlternativeKeyChanged(QKeySequence))
KEY(I18N_NOOP("Walk Through Desktops"), 0, slotWalkThroughDesktops(), m_cutWalkThroughDesktops, slotWalkThroughDesktopsKeyChanged(QKeySequence))
KEY(I18N_NOOP("Walk Through Desktops (Reverse)"), 0, slotWalkBackThroughDesktops(), m_cutWalkThroughDesktopsReverse, slotWalkBackThroughDesktopsKeyChanged(QKeySequence))
KEY(I18N_NOOP("Walk Through Desktop List"), 0, slotWalkThroughDesktopList(), m_cutWalkThroughDesktopList, slotWalkThroughDesktopListKeyChanged(QKeySequence))
@ -485,6 +495,12 @@ void TabBox::setMode(TabBoxMode mode)
case TabBoxWindowsAlternativeMode:
m_tabBox->setConfig(m_alternativeConfig);
break;
case TabBoxCurrentAppWindowsMode:
m_tabBox->setConfig(m_defaultCurrentApplicationConfig);
break;
case TabBoxCurrentAppWindowsAlternativeMode:
m_tabBox->setConfig(m_alternativeCurrentApplicationConfig);
break;
case TabBoxDesktopMode:
m_tabBox->setConfig(m_desktopConfig);
break;
@ -659,6 +675,11 @@ void TabBox::reconfigure()
loadConfig(c->group("TabBox"), m_defaultConfig);
loadConfig(c->group("TabBoxAlternative"), m_alternativeConfig);
m_defaultCurrentApplicationConfig = m_defaultConfig;
m_defaultCurrentApplicationConfig.setClientApplicationsMode(TabBoxConfig::AllWindowsCurrentApplication);
m_alternativeCurrentApplicationConfig = m_alternativeConfig;
m_alternativeCurrentApplicationConfig.setClientApplicationsMode(TabBoxConfig::AllWindowsCurrentApplication);
m_tabBox->setConfig(m_defaultConfig);
m_delayShow = config.readEntry<bool>("ShowDelay", true);
@ -903,6 +924,38 @@ void TabBox::slotWalkBackThroughWindowsAlternative()
navigatingThroughWindows(false, m_cutWalkThroughWindowsAlternativeReverse, TabBoxWindowsAlternativeMode);
}
void TabBox::slotWalkThroughCurrentAppWindows()
{
if (!m_ready){
return;
}
navigatingThroughWindows(true, m_cutWalkThroughCurrentAppWindows, TabBoxCurrentAppWindowsMode);
}
void TabBox::slotWalkBackThroughCurrentAppWindows()
{
if (!m_ready){
return;
}
navigatingThroughWindows(false, m_cutWalkThroughCurrentAppWindowsReverse, TabBoxCurrentAppWindowsMode);
}
void TabBox::slotWalkThroughCurrentAppWindowsAlternative()
{
if (!m_ready){
return;
}
navigatingThroughWindows(true, m_cutWalkThroughCurrentAppWindowsAlternative, TabBoxCurrentAppWindowsAlternativeMode);
}
void TabBox::slotWalkBackThroughCurrentAppWindowsAlternative()
{
if (!m_ready){
return;
}
navigatingThroughWindows(false, m_cutWalkThroughCurrentAppWindowsAlternativeReverse, TabBoxCurrentAppWindowsAlternativeMode);
}
void TabBox::slotWalkThroughDesktops()
{
if (!m_ready){
@ -1012,6 +1065,26 @@ void TabBox::slotWalkBackThroughWindowsAlternativeKeyChanged(const QKeySequence&
m_cutWalkThroughWindowsAlternativeReverse = KShortcut(seq);
}
void TabBox::slotWalkThroughCurrentAppWindowsKeyChanged(const QKeySequence& seq)
{
m_cutWalkThroughCurrentAppWindows = KShortcut(seq);
}
void TabBox::slotWalkBackThroughCurrentAppWindowsKeyChanged(const QKeySequence& seq)
{
m_cutWalkThroughCurrentAppWindowsReverse = KShortcut(seq);
}
void TabBox::slotWalkThroughCurrentAppWindowsAlternativeKeyChanged(const QKeySequence& seq)
{
m_cutWalkThroughCurrentAppWindowsAlternative = KShortcut(seq);
}
void TabBox::slotWalkBackThroughCurrentAppWindowsAlternativeKeyChanged(const QKeySequence& seq)
{
m_cutWalkThroughCurrentAppWindowsAlternativeReverse = KShortcut(seq);
}
void TabBox::modalActionsSwitch(bool enabled)
{
QList<KActionCollection*> collections;
@ -1214,15 +1287,36 @@ void TabBox::keyPress(int keyQt)
if (m_tabGrab) {
KShortcut forwardShortcut;
KShortcut backwardShortcut;
if (mode() == TabBoxWindowsMode) {
forwardShortcut = m_cutWalkThroughWindows;
backwardShortcut = m_cutWalkThroughWindowsReverse;
} else {
forwardShortcut = m_cutWalkThroughWindowsAlternative;
backwardShortcut = m_cutWalkThroughWindowsAlternativeReverse;
switch (mode()) {
case TabBoxWindowsMode:
forwardShortcut = m_cutWalkThroughWindows;
backwardShortcut = m_cutWalkThroughWindowsReverse;
break;
case TabBoxWindowsAlternativeMode:
forwardShortcut = m_cutWalkThroughWindowsAlternative;
backwardShortcut = m_cutWalkThroughWindowsAlternativeReverse;
break;
case TabBoxCurrentAppWindowsMode:
forwardShortcut = m_cutWalkThroughCurrentAppWindows;
backwardShortcut = m_cutWalkThroughCurrentAppWindowsReverse;
break;
case TabBoxCurrentAppWindowsAlternativeMode:
forwardShortcut = m_cutWalkThroughCurrentAppWindowsAlternative;
backwardShortcut = m_cutWalkThroughCurrentAppWindowsAlternativeReverse;
break;
default:
kDebug(125) << "Invalid TabBoxMode";
return;
}
forward = forwardShortcut.contains(keyQt);
backward = backwardShortcut.contains(keyQt);
if (!forward && !backward) {
// if the shortcuts do not match, try matching again after filtering the shift key from keyQt
// it is needed to handle correctly the ALT+~ shorcut for example as it is coded as ALT+SHIFT+~ in keyQt
keyQt &= ~Qt::ShiftModifier;
forward = forwardShortcut.contains(keyQt);
backward = backwardShortcut.contains(keyQt);
}
if (forward || backward) {
kDebug(125) << "== " << forwardShortcut.toString()
<< " or " << backwardShortcut.toString() << endl;

View file

@ -212,6 +212,10 @@ public slots:
void slotWalkBackThroughWindows();
void slotWalkThroughWindowsAlternative();
void slotWalkBackThroughWindowsAlternative();
void slotWalkThroughCurrentAppWindows();
void slotWalkBackThroughCurrentAppWindows();
void slotWalkThroughCurrentAppWindowsAlternative();
void slotWalkBackThroughCurrentAppWindowsAlternative();
void slotWalkThroughDesktopsKeyChanged(const QKeySequence& seq);
void slotWalkBackThroughDesktopsKeyChanged(const QKeySequence& seq);
@ -223,6 +227,10 @@ public slots:
void slotMoveToTabRightKeyChanged(const QKeySequence& seq);
void slotWalkThroughWindowsAlternativeKeyChanged(const QKeySequence& seq);
void slotWalkBackThroughWindowsAlternativeKeyChanged(const QKeySequence& seq);
void slotWalkThroughCurrentAppWindowsKeyChanged(const QKeySequence& seq);
void slotWalkBackThroughCurrentAppWindowsKeyChanged(const QKeySequence& seq);
void slotWalkThroughCurrentAppWindowsAlternativeKeyChanged(const QKeySequence& seq);
void slotWalkBackThroughCurrentAppWindowsAlternativeKeyChanged(const QKeySequence& seq);
void handlerReady();
@ -267,6 +275,8 @@ private:
TabBoxConfig m_defaultConfig;
TabBoxConfig m_alternativeConfig;
TabBoxConfig m_defaultCurrentApplicationConfig;
TabBoxConfig m_alternativeCurrentApplicationConfig;
TabBoxConfig m_desktopConfig;
TabBoxConfig m_desktopListConfig;
// false if an effect has referenced the tabbox
@ -281,6 +291,8 @@ private:
KShortcut m_cutWalkThroughWindows, m_cutWalkThroughWindowsReverse;
KShortcut m_cutWalkThroughGroupWindows, m_cutWalkThroughGroupWindowsReverse;
KShortcut m_cutWalkThroughWindowsAlternative, m_cutWalkThroughWindowsAlternativeReverse;
KShortcut m_cutWalkThroughCurrentAppWindows, m_cutWalkThroughCurrentAppWindowsReverse;
KShortcut m_cutWalkThroughCurrentAppWindowsAlternative, m_cutWalkThroughCurrentAppWindowsAlternativeReverse;
bool m_forcedGlobalMouseGrab;
bool m_ready; // indicates whether the config is completely loaded
};