Refactoring TabBox

Move the funtionality of TabBox from class Workspace to class TabBox to make
it possible to deactivate this feature by setting a compile flag.
All methods and variables are now provided by class TabBox and calls from other
classes go directly to TabBox.
The code for configuring the shortcut keys has also been moved to class TabBox
from kwinbindings.cpp.
icc-effect-5.14.5
Arthur Arlt 2011-06-25 18:05:07 +02:00
parent ec1df109d9
commit d1b5d00129
8 changed files with 380 additions and 479 deletions

View File

@ -752,18 +752,28 @@ void EffectsHandlerImpl::setElevatedWindow(EffectWindow* w, bool set)
void EffectsHandlerImpl::setTabBoxWindow(EffectWindow* w) void EffectsHandlerImpl::setTabBoxWindow(EffectWindow* w)
{ {
if (Client* c = dynamic_cast< Client* >(static_cast< EffectWindowImpl* >(w)->window())) if (Client* c = dynamic_cast< Client* >(static_cast< EffectWindowImpl* >(w)->window()))
Workspace::self()->setTabBoxClient(c); if (Workspace::self()->hasTabBox()) {
Workspace::self()->tabBox()->setCurrentClient(c);
}
} }
void EffectsHandlerImpl::setTabBoxDesktop(int desktop) void EffectsHandlerImpl::setTabBoxDesktop(int desktop)
{ {
Workspace::self()->setTabBoxDesktop(desktop); if (Workspace::self()->hasTabBox()) {
Workspace::self()->tabBox()->setCurrentDesktop(desktop);
}
} }
EffectWindowList EffectsHandlerImpl::currentTabBoxWindowList() const EffectWindowList EffectsHandlerImpl::currentTabBoxWindowList() const
{ {
EffectWindowList ret; EffectWindowList ret;
ClientList clients = Workspace::self()->currentTabBoxClientList(); ClientList clients;
if (Workspace::self()->hasTabBox()) {
clients = Workspace::self()->tabBox()->currentClientList();
} else {
clients = ClientList();
}
foreach (Client * c, clients) foreach (Client * c, clients)
ret.append(c->effectWindow()); ret.append(c->effectWindow());
return ret; return ret;
@ -771,33 +781,47 @@ EffectWindowList EffectsHandlerImpl::currentTabBoxWindowList() const
void EffectsHandlerImpl::refTabBox() void EffectsHandlerImpl::refTabBox()
{ {
Workspace::self()->refTabBox(); if (Workspace::self()->hasTabBox()) {
Workspace::self()->tabBox()->reference();
}
} }
void EffectsHandlerImpl::unrefTabBox() void EffectsHandlerImpl::unrefTabBox()
{ {
Workspace::self()->unrefTabBox(); if (Workspace::self()->hasTabBox()) {
Workspace::self()->tabBox()->unreference();
}
} }
void EffectsHandlerImpl::closeTabBox() void EffectsHandlerImpl::closeTabBox()
{ {
Workspace::self()->closeTabBox(); if (Workspace::self()->hasTabBox()) {
Workspace::self()->tabBox()->close();
}
} }
QList< int > EffectsHandlerImpl::currentTabBoxDesktopList() const QList< int > EffectsHandlerImpl::currentTabBoxDesktopList() const
{ {
return Workspace::self()->currentTabBoxDesktopList(); if (Workspace::self()->hasTabBox()) {
return Workspace::self()->tabBox()->currentDesktopList();
}
return QList< int >();
} }
int EffectsHandlerImpl::currentTabBoxDesktop() const int EffectsHandlerImpl::currentTabBoxDesktop() const
{ {
return Workspace::self()->currentTabBoxDesktop(); if (Workspace::self()->hasTabBox()) {
return Workspace::self()->tabBox()->currentDesktop();
}
return -1;
} }
EffectWindow* EffectsHandlerImpl::currentTabBoxWindow() const EffectWindow* EffectsHandlerImpl::currentTabBoxWindow() const
{ {
if (Client* c = Workspace::self()->currentTabBoxClient()) if (Workspace::self()->hasTabBox()) {
if (Client* c = Workspace::self()->tabBox()->currentClient())
return c->effectWindow(); return c->effectWindow();
}
return NULL; return NULL;
} }

View File

@ -242,7 +242,7 @@ bool Workspace::workspaceEvent(XEvent * e)
was_user_interaction = true; was_user_interaction = true;
// fallthrough // fallthrough
case MotionNotify: case MotionNotify:
if (tab_grab || control_grab) { if (tabBox()->isGrabbed()) {
tab_box->handleMouseEvent(e); tab_box->handleMouseEvent(e);
return true; return true;
} }
@ -258,16 +258,16 @@ bool Workspace::workspaceEvent(XEvent * e)
movingClient->keyPressEvent(keyQt); movingClient->keyPressEvent(keyQt);
return true; return true;
} }
if (tab_grab || control_grab) { if (tabBox()->isGrabbed()) {
tabBoxKeyPress(keyQt); tabBox()->keyPress(keyQt);
return true; return true;
} }
break; break;
} }
case KeyRelease: case KeyRelease:
was_user_interaction = true; was_user_interaction = true;
if (tab_grab || control_grab) { if (tabBox()->isGrabbed()) {
tabBoxKeyRelease(e->xkey); tabBox()->keyRelease(e->xkey);
return true; return true;
} }
break; break;

View File

@ -59,17 +59,9 @@ a->setText(i18n("System"));
a = actionCollection->addAction("Group:Navigation"); a = actionCollection->addAction("Group:Navigation");
a->setText(i18n("Navigation")); a->setText(i18n("Navigation"));
DEF(I18N_NOOP("Walk Through Windows"), Qt::ALT + Qt::Key_Tab, slotWalkThroughWindows());
DEF(I18N_NOOP("Walk Through Windows (Reverse)"), Qt::ALT + Qt::SHIFT + Qt::Key_Backtab, slotWalkBackThroughWindows());
DEF(I18N_NOOP("Walk Through Window Tabs"), 0, slotSwitchToTabRight()); DEF(I18N_NOOP("Walk Through Window Tabs"), 0, slotSwitchToTabRight());
DEF(I18N_NOOP("Walk Through Window Tabs (Reverse)"), 0, slotSwitchToTabLeft()); DEF(I18N_NOOP("Walk Through Window Tabs (Reverse)"), 0, slotSwitchToTabLeft());
DEF(I18N_NOOP("Remove Window From Group"), 0, slotRemoveFromGroup()); DEF(I18N_NOOP("Remove Window From Group"), 0, slotRemoveFromGroup());
DEF(I18N_NOOP("Walk Through Windows Alternative"), 0, slotWalkThroughWindowsAlternative());
DEF(I18N_NOOP("Walk Through Windows Alternative (Reverse)"), 0, slotWalkBackThroughWindowsAlternative());
DEF(I18N_NOOP("Walk Through Desktops"), 0, slotWalkThroughDesktops());
DEF(I18N_NOOP("Walk Through Desktops (Reverse)"), 0, slotWalkBackThroughDesktops());
DEF(I18N_NOOP("Walk Through Desktop List"), 0, slotWalkThroughDesktopList());
DEF(I18N_NOOP("Walk Through Desktop List (Reverse)"), 0, slotWalkBackThroughDesktopList());
a = actionCollection->addAction("Group:Windows"); a = actionCollection->addAction("Group:Windows");
a->setText(i18n("Windows")); a->setText(i18n("Windows"));

View File

@ -46,6 +46,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <X11/keysym.h> #include <X11/keysym.h>
#include <X11/keysymdef.h> #include <X11/keysymdef.h>
#include "outline.h" #include "outline.h"
#include <kaction.h>
// specify externals before namespace // specify externals before namespace
@ -57,8 +58,9 @@ extern QPixmap* kwin_get_menu_pix_hack();
namespace TabBox namespace TabBox
{ {
TabBoxHandlerImpl::TabBoxHandlerImpl() TabBoxHandlerImpl::TabBoxHandlerImpl(TabBox* tabBox)
: TabBoxHandler() : TabBoxHandler()
, m_tabBox(tabBox)
{ {
} }
@ -93,7 +95,7 @@ QString TabBoxHandlerImpl::desktopName(int desktop) const
TabBoxClient* TabBoxHandlerImpl::nextClientFocusChain(TabBoxClient* client) const TabBoxClient* TabBoxHandlerImpl::nextClientFocusChain(TabBoxClient* client) const
{ {
if (TabBoxClientImpl* c = static_cast< TabBoxClientImpl* >(client)) { if (TabBoxClientImpl* c = static_cast< TabBoxClientImpl* >(client)) {
Client* next = Workspace::self()->nextClientFocusChain(c->client()); Client* next = Workspace::self()->tabBox()->nextClientFocusChain(c->client());
if (next) if (next)
return next->tabBoxClient(); return next->tabBoxClient();
} }
@ -102,7 +104,7 @@ TabBoxClient* TabBoxHandlerImpl::nextClientFocusChain(TabBoxClient* client) cons
int TabBoxHandlerImpl::nextDesktopFocusChain(int desktop) const int TabBoxHandlerImpl::nextDesktopFocusChain(int desktop) const
{ {
return Workspace::self()->nextDesktopFocusChain(desktop); return m_tabBox->nextDesktopFocusChain(desktop);
} }
int TabBoxHandlerImpl::numberOfDesktops() const int TabBoxHandlerImpl::numberOfDesktops() const
@ -272,10 +274,12 @@ int TabBoxClientImpl::height() const
/********************************************************* /*********************************************************
* TabBox * TabBox
*********************************************************/ *********************************************************/
TabBox::TabBox(Workspace *ws) TabBox::TabBox()
: QObject() : QObject()
, wspace(ws) , m_displayRefcount(0)
, display_refcount(0) , m_forcedGlobalMouseGrab(false)
, m_desktopGrab(false)
, m_tabGrab(false)
{ {
m_isShown = false; m_isShown = false;
m_defaultConfig = TabBoxConfig(); m_defaultConfig = TabBoxConfig();
@ -303,19 +307,40 @@ TabBox::TabBox(Workspace *ws)
m_desktopListConfig.setShowDesktop(false); m_desktopListConfig.setShowDesktop(false);
m_desktopListConfig.setDesktopSwitchingMode(TabBoxConfig::StaticDesktopSwitching); m_desktopListConfig.setDesktopSwitchingMode(TabBoxConfig::StaticDesktopSwitching);
m_desktopListConfig.setLayout(TabBoxConfig::VerticalLayout); m_desktopListConfig.setLayout(TabBoxConfig::VerticalLayout);
m_tabBox = new TabBoxHandlerImpl(); m_tabBox = new TabBoxHandlerImpl(this);
m_tabBox->setConfig(m_defaultConfig); m_tabBox->setConfig(m_defaultConfig);
m_tabBoxMode = TabBoxDesktopMode; // init variables m_tabBoxMode = TabBoxDesktopMode; // init variables
reconfigure(); reconfigure();
connect(&delayedShowTimer, SIGNAL(timeout()), this, SLOT(show())); connect(&m_delayedShowTimer, SIGNAL(timeout()), this, SLOT(show()));
} }
TabBox::~TabBox() TabBox::~TabBox()
{ {
} }
void TabBox::initShortcuts(KActionCollection* keys)
{
KAction *a = NULL;
#define KEY( name, key, fnSlot, shortcut, shortcutSlot ) \
a = keys->addAction( name ); \
a->setText( i18n(name) ); \
shortcut = KShortcut(key); \
qobject_cast<KAction*>( a )->setGlobalShortcut(shortcut); \
connect(a, SIGNAL(triggered(bool)), SLOT(fnSlot)); \
connect(a, SIGNAL(globalShortcutChanged(QKeySequence)), SLOT(shortcutSlot));
KEY(I18N_NOOP("Walk Through Windows"), Qt::ALT + Qt::Key_Tab, slotWalkThroughWindows(), m_cutWalkThroughWindows, slotWalkThroughWindowsKeyChanged(QKeySequence))
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 Desktops"), 0, slotWalkThroughDesktops(), m_cutWalkThroughDesktops, slotWalkBackThroughDesktopsKeyChanged(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))
KEY(I18N_NOOP("Walk Through Desktop List (Reverse)"), 0, slotWalkBackThroughDesktopList(), m_cutWalkThroughDesktopListReverse, slotWalkBackThroughDesktopListKeyChanged(QKeySequence))
#undef KEY
}
/*! /*!
Sets the current mode to \a mode, either TabBoxDesktopListMode or TabBoxWindowsMode Sets the current mode to \a mode, either TabBoxDesktopListMode or TabBoxWindowsMode
@ -351,8 +376,8 @@ void TabBox::reset(bool partial_reset)
case TabBoxConfig::ClientTabBox: case TabBoxConfig::ClientTabBox:
m_tabBox->createModel(partial_reset); m_tabBox->createModel(partial_reset);
if (!partial_reset) { if (!partial_reset) {
if (workspace()->activeClient()) if (Workspace::self()->activeClient())
setCurrentClient(workspace()->activeClient()); setCurrentClient(Workspace::self()->activeClient());
// it's possible that the active client is not part of the model // it's possible that the active client is not part of the model
// in that case the index is invalid // in that case the index is invalid
if (!m_index.isValid()) if (!m_index.isValid())
@ -366,7 +391,7 @@ void TabBox::reset(bool partial_reset)
m_tabBox->createModel(); m_tabBox->createModel();
if (!partial_reset) if (!partial_reset)
setCurrentDesktop(workspace()->currentDesktop()); setCurrentDesktop(Workspace::self()->currentDesktop());
break; break;
} }
@ -382,7 +407,6 @@ void TabBox::nextPrev(bool next)
emit tabBoxUpdated(); emit tabBoxUpdated();
} }
/*! /*!
Returns the currently displayed client ( only works in TabBoxWindowsMode ). Returns the currently displayed client ( only works in TabBoxWindowsMode ).
Returns 0 if no client is displayed. Returns 0 if no client is displayed.
@ -390,7 +414,7 @@ void TabBox::nextPrev(bool next)
Client* TabBox::currentClient() Client* TabBox::currentClient()
{ {
if (TabBoxClientImpl* client = static_cast< TabBoxClientImpl* >(m_tabBox->client(m_index))) { if (TabBoxClientImpl* client = static_cast< TabBoxClientImpl* >(m_tabBox->client(m_index))) {
if (!workspace()->hasClient(client->client())) if (!Workspace::self()->hasClient(client->client()))
return NULL; return NULL;
return client->client(); return client->client();
} else } else
@ -413,7 +437,6 @@ ClientList TabBox::currentClientList()
return ret; return ret;
} }
/*! /*!
Returns the currently displayed virtual desktop ( only works in Returns the currently displayed virtual desktop ( only works in
TabBoxDesktopListMode ) TabBoxDesktopListMode )
@ -424,7 +447,6 @@ int TabBox::currentDesktop()
return m_tabBox->desktop(m_index); return m_tabBox->desktop(m_index);
} }
/*! /*!
Returns the list of desktops potentially displayed ( only works in Returns the list of desktops potentially displayed ( only works in
TabBoxDesktopListMode ) TabBoxDesktopListMode )
@ -435,7 +457,6 @@ QList< int > TabBox::currentDesktopList()
return m_tabBox->desktopList(); return m_tabBox->desktopList();
} }
/*! /*!
Change the currently selected client, and notify the effects. Change the currently selected client, and notify the effects.
@ -478,21 +499,20 @@ void TabBox::show()
m_isShown = false; m_isShown = false;
return; return;
} }
refDisplay(); reference();
m_isShown = true; m_isShown = true;
m_tabBox->show(); m_tabBox->show();
} }
/*! /*!
Notify effects that the tab box is being hidden. Notify effects that the tab box is being hidden.
*/ */
void TabBox::hide(bool abort) void TabBox::hide(bool abort)
{ {
delayedShowTimer.stop(); m_delayedShowTimer.stop();
if (m_isShown) { if (m_isShown) {
m_isShown = false; m_isShown = false;
unrefDisplay(); unreference();
} }
emit tabBoxClosed(); emit tabBoxClosed();
if (isDisplayed()) if (isDisplayed())
@ -505,16 +525,6 @@ void TabBox::hide(bool abort)
; ;
} }
/*!
Decrease the reference count. Only when the reference count is 0 will
the default tab box be shown.
*/
void TabBox::unrefDisplay()
{
--display_refcount;
}
void TabBox::reconfigure() void TabBox::reconfigure()
{ {
KSharedConfigPtr c(KGlobal::config()); KSharedConfigPtr c(KGlobal::config());
@ -578,7 +588,7 @@ void TabBox::loadConfig(const KConfigGroup& config, TabBoxConfig& tabBoxConfig)
*/ */
void TabBox::delayedShow() void TabBox::delayedShow()
{ {
if (isDisplayed() || delayedShowTimer.isActive()) if (isDisplayed() || m_delayedShowTimer.isActive())
// already called show - no need to call it twice // already called show - no need to call it twice
return; return;
@ -587,8 +597,8 @@ void TabBox::delayedShow()
return; return;
} }
delayedShowTimer.setSingleShot(true); m_delayedShowTimer.setSingleShot(true);
delayedShowTimer.start(m_delayShowTime); m_delayedShowTimer.start(m_delayShowTime);
} }
@ -607,7 +617,7 @@ void TabBox::handleMouseEvent(XEvent* e)
if ((!m_isShown && isDisplayed()) if ((!m_isShown && isDisplayed())
|| (!m_tabBox->containsPos(pos) && || (!m_tabBox->containsPos(pos) &&
(e->xbutton.button == Button1 || e->xbutton.button == Button2 || e->xbutton.button == Button3))) { (e->xbutton.button == Button1 || e->xbutton.button == Button2 || e->xbutton.button == Button3))) {
workspace()->closeTabBox(); // click outside closes tab close(); // click outside closes tab
return; return;
} }
@ -616,7 +626,7 @@ void TabBox::handleMouseEvent(XEvent* e)
index = m_tabBox->indexAt(pos); index = m_tabBox->indexAt(pos);
if (e->xbutton.button == Button2 && index.isValid()) { if (e->xbutton.button == Button2 && index.isValid()) {
if (TabBoxClientImpl* client = static_cast< TabBoxClientImpl* >(m_tabBox->client(index))) { if (TabBoxClientImpl* client = static_cast< TabBoxClientImpl* >(m_tabBox->client(index))) {
if (workspace()->hasClient(client->client())) { if (Workspace::self()->hasClient(client->client())) {
client->client()->closeWindow(); client->client()->closeWindow();
return; return;
} }
@ -631,7 +641,7 @@ void TabBox::handleMouseEvent(XEvent* e)
setCurrentIndex(index); setCurrentIndex(index);
} }
void TabBox::TabBox::grabbedKeyEvent(QKeyEvent* event) void TabBox::grabbedKeyEvent(QKeyEvent* event)
{ {
emit tabBoxKeyEvent(event); emit tabBoxKeyEvent(event);
if (!m_isShown && isDisplayed()) { if (!m_isShown && isDisplayed()) {
@ -641,21 +651,10 @@ void TabBox::TabBox::grabbedKeyEvent(QKeyEvent* event)
setCurrentIndex(m_tabBox->grabbedKeyEvent(event)); setCurrentIndex(m_tabBox->grabbedKeyEvent(event));
} }
} // namespace TabBox
//*******************************
// Workspace
//*******************************
/*! /*!
Handles alt-tab / control-tab Handles alt-tab / control-tab
*/ */
static bool areKeySymXsDepressed(bool bAll, const uint keySyms[], int nKeySyms) {
static
bool areKeySymXsDepressed(bool bAll, const uint keySyms[], int nKeySyms)
{
char keymap[32]; char keymap[32];
kDebug(125) << "areKeySymXsDepressed: " << (bAll ? "all of " : "any of ") << nKeySyms; kDebug(125) << "areKeySymXsDepressed: " << (bAll ? "all of " : "any of ") << nKeySyms;
@ -692,8 +691,7 @@ bool areKeySymXsDepressed(bool bAll, const uint keySyms[], int nKeySyms)
return bAll; return bAll;
} }
static bool areModKeysDepressed(const QKeySequence& seq) static bool areModKeysDepressed(const QKeySequence& seq) {
{
uint rgKeySyms[10]; uint rgKeySyms[10];
int nKeySyms = 0; int nKeySyms = 0;
if (seq.isEmpty()) if (seq.isEmpty())
@ -733,9 +731,9 @@ static bool areModKeysDepressed(const KShortcut& cut)
return false; return false;
} }
void Workspace::navigatingThroughWindows(bool forward, const KShortcut& shortcut, TabBoxMode mode) void TabBox::navigatingThroughWindows(bool forward, const KShortcut& shortcut, TabBoxMode mode)
{ {
if (tab_grab || control_grab) if (isGrabbed())
return; return;
if (!options->focusPolicyIsReasonable()) { if (!options->focusPolicyIsReasonable()) {
//ungrabXKeyboard(); // need that because of accelerator raw mode //ungrabXKeyboard(); // need that because of accelerator raw mode
@ -752,31 +750,31 @@ void Workspace::navigatingThroughWindows(bool forward, const KShortcut& shortcut
} }
} }
void Workspace::slotWalkThroughWindows() void TabBox::slotWalkThroughWindows()
{ {
navigatingThroughWindows(true, cutWalkThroughWindows, TabBoxWindowsMode); navigatingThroughWindows(true, m_cutWalkThroughWindows, TabBoxWindowsMode);
} }
void Workspace::slotWalkBackThroughWindows() void TabBox::slotWalkBackThroughWindows()
{ {
navigatingThroughWindows(false, cutWalkThroughWindowsReverse, TabBoxWindowsMode); navigatingThroughWindows(false, m_cutWalkThroughWindowsReverse, TabBoxWindowsMode);
} }
void Workspace::slotWalkThroughWindowsAlternative() void TabBox::slotWalkThroughWindowsAlternative()
{ {
navigatingThroughWindows(true, cutWalkThroughWindowsAlternative, TabBoxWindowsAlternativeMode); navigatingThroughWindows(true, m_cutWalkThroughWindowsAlternative, TabBoxWindowsAlternativeMode);
} }
void Workspace::slotWalkBackThroughWindowsAlternative() void TabBox::slotWalkBackThroughWindowsAlternative()
{ {
navigatingThroughWindows(false, cutWalkThroughWindowsAlternativeReverse, TabBoxWindowsAlternativeMode); navigatingThroughWindows(false, m_cutWalkThroughWindowsAlternativeReverse, TabBoxWindowsAlternativeMode);
} }
void Workspace::slotWalkThroughDesktops() void TabBox::slotWalkThroughDesktops()
{ {
if (tab_grab || control_grab) if (isGrabbed())
return; return;
if (areModKeysDepressed(cutWalkThroughDesktops)) { if (areModKeysDepressed(m_cutWalkThroughDesktops)) {
if (startWalkThroughDesktops()) if (startWalkThroughDesktops())
walkThroughDesktops(true); walkThroughDesktops(true);
} else { } else {
@ -784,11 +782,11 @@ void Workspace::slotWalkThroughDesktops()
} }
} }
void Workspace::slotWalkBackThroughDesktops() void TabBox::slotWalkBackThroughDesktops()
{ {
if (tab_grab || control_grab) if (isGrabbed())
return; return;
if (areModKeysDepressed(cutWalkThroughDesktopsReverse)) { if (areModKeysDepressed(m_cutWalkThroughDesktopsReverse)) {
if (startWalkThroughDesktops()) if (startWalkThroughDesktops())
walkThroughDesktops(false); walkThroughDesktops(false);
} else { } else {
@ -796,11 +794,11 @@ void Workspace::slotWalkBackThroughDesktops()
} }
} }
void Workspace::slotWalkThroughDesktopList() void TabBox::slotWalkThroughDesktopList()
{ {
if (tab_grab || control_grab) if (isGrabbed())
return; return;
if (areModKeysDepressed(cutWalkThroughDesktopList)) { if (areModKeysDepressed(m_cutWalkThroughDesktopList)) {
if (startWalkThroughDesktopList()) if (startWalkThroughDesktopList())
walkThroughDesktops(true); walkThroughDesktops(true);
} else { } else {
@ -808,11 +806,11 @@ void Workspace::slotWalkThroughDesktopList()
} }
} }
void Workspace::slotWalkBackThroughDesktopList() void TabBox::slotWalkBackThroughDesktopList()
{ {
if (tab_grab || control_grab) if (isGrabbed())
return; return;
if (areModKeysDepressed(cutWalkThroughDesktopListReverse)) { if (areModKeysDepressed(m_cutWalkThroughDesktopListReverse)) {
if (startWalkThroughDesktopList()) if (startWalkThroughDesktopList())
walkThroughDesktops(false); walkThroughDesktops(false);
} else { } else {
@ -820,121 +818,121 @@ void Workspace::slotWalkBackThroughDesktopList()
} }
} }
void Workspace::slotWalkThroughDesktopsKeyChanged(const QKeySequence& seq) void TabBox::slotWalkThroughDesktopsKeyChanged(const QKeySequence& seq)
{ {
cutWalkThroughDesktops = KShortcut(seq); m_cutWalkThroughDesktops = KShortcut(seq);
} }
void Workspace::slotWalkBackThroughDesktopsKeyChanged(const QKeySequence& seq) void TabBox::slotWalkBackThroughDesktopsKeyChanged(const QKeySequence& seq)
{ {
cutWalkThroughDesktopsReverse = KShortcut(seq); m_cutWalkThroughDesktopsReverse = KShortcut(seq);
} }
void Workspace::slotWalkThroughDesktopListKeyChanged(const QKeySequence& seq) void TabBox::slotWalkThroughDesktopListKeyChanged(const QKeySequence& seq)
{ {
cutWalkThroughDesktopList = KShortcut(seq); m_cutWalkThroughDesktopList = KShortcut(seq);
} }
void Workspace::slotWalkBackThroughDesktopListKeyChanged(const QKeySequence& seq) void TabBox::slotWalkBackThroughDesktopListKeyChanged(const QKeySequence& seq)
{ {
cutWalkThroughDesktopListReverse = KShortcut(seq); m_cutWalkThroughDesktopListReverse = KShortcut(seq);
} }
void Workspace::slotWalkThroughWindowsKeyChanged(const QKeySequence& seq) void TabBox::slotWalkThroughWindowsKeyChanged(const QKeySequence& seq)
{ {
cutWalkThroughWindows = KShortcut(seq); m_cutWalkThroughWindows = KShortcut(seq);
} }
void Workspace::slotWalkBackThroughWindowsKeyChanged(const QKeySequence& seq) void TabBox::slotWalkBackThroughWindowsKeyChanged(const QKeySequence& seq)
{ {
cutWalkThroughWindowsReverse = KShortcut(seq); m_cutWalkThroughWindowsReverse = KShortcut(seq);
} }
void Workspace::slotMoveToTabLeftKeyChanged(const QKeySequence& seq) void TabBox::slotMoveToTabLeftKeyChanged(const QKeySequence& seq)
{ {
cutWalkThroughGroupWindows = KShortcut(seq); m_cutWalkThroughGroupWindows = KShortcut(seq);
} }
void Workspace::slotMoveToTabRightKeyChanged(const QKeySequence& seq) void TabBox::slotMoveToTabRightKeyChanged(const QKeySequence& seq)
{ {
cutWalkThroughGroupWindowsReverse = KShortcut(seq); m_cutWalkThroughGroupWindowsReverse = KShortcut(seq);
} }
void Workspace::slotWalkThroughWindowsAlternativeKeyChanged(const QKeySequence& seq) void TabBox::slotWalkThroughWindowsAlternativeKeyChanged(const QKeySequence& seq)
{ {
cutWalkThroughWindowsAlternative = KShortcut(seq); m_cutWalkThroughWindowsAlternative = KShortcut(seq);
} }
void Workspace::slotWalkBackThroughWindowsAlternativeKeyChanged(const QKeySequence& seq) void TabBox::slotWalkBackThroughWindowsAlternativeKeyChanged(const QKeySequence& seq)
{ {
cutWalkThroughWindowsAlternativeReverse = KShortcut(seq); m_cutWalkThroughWindowsAlternativeReverse = KShortcut(seq);
} }
void Workspace::modalActionsSwitch(bool enabled) void TabBox::modalActionsSwitch(bool enabled)
{ {
QList<KActionCollection*> collections; QList<KActionCollection*> collections;
collections.append(keys); collections.append(Workspace::self()->actionCollection());
collections.append(disable_shortcuts_keys); collections.append(Workspace::self()->disableShortcutsKeys());
collections.append(client_keys); collections.append(Workspace::self()->clientKeys());
foreach (KActionCollection * collection, collections) foreach (KActionCollection * collection, collections)
foreach (QAction * action, collection->actions()) foreach (QAction * action, collection->actions())
action->setEnabled(enabled); action->setEnabled(enabled);
} }
bool Workspace::startKDEWalkThroughWindows(TabBoxMode mode) bool TabBox::startKDEWalkThroughWindows(TabBoxMode mode)
{ {
if (!establishTabBoxGrab()) if (!establishTabBoxGrab())
return false; return false;
tab_grab = true; m_tabGrab = true;
modalActionsSwitch(false); modalActionsSwitch(false);
tab_box->setMode(mode); setMode(mode);
tab_box->reset(); reset();
return true; return true;
} }
bool Workspace::startWalkThroughDesktops(TabBoxMode mode) bool TabBox::startWalkThroughDesktops(TabBoxMode mode)
{ {
if (!establishTabBoxGrab()) if (!establishTabBoxGrab())
return false; return false;
control_grab = true; m_desktopGrab = true;
modalActionsSwitch(false); modalActionsSwitch(false);
tab_box->setMode(mode); setMode(mode);
tab_box->reset(); reset();
return true; return true;
} }
bool Workspace::startWalkThroughDesktops() bool TabBox::startWalkThroughDesktops()
{ {
return startWalkThroughDesktops(TabBoxDesktopMode); return startWalkThroughDesktops(TabBoxDesktopMode);
} }
bool Workspace::startWalkThroughDesktopList() bool TabBox::startWalkThroughDesktopList()
{ {
return startWalkThroughDesktops(TabBoxDesktopListMode); return startWalkThroughDesktops(TabBoxDesktopListMode);
} }
void Workspace::KDEWalkThroughWindows(bool forward) void TabBox::KDEWalkThroughWindows(bool forward)
{ {
tab_box->nextPrev(forward); nextPrev(forward);
tab_box->delayedShow(); delayedShow();
} }
void Workspace::walkThroughDesktops(bool forward) void TabBox::walkThroughDesktops(bool forward)
{ {
tab_box->nextPrev(forward); nextPrev(forward);
tab_box->delayedShow(); delayedShow();
} }
void Workspace::CDEWalkThroughWindows(bool forward) void TabBox::CDEWalkThroughWindows(bool forward)
{ {
Client* c = NULL; Client* c = NULL;
// this function find the first suitable client for unreasonable focus // this function find the first suitable client for unreasonable focus
// policies - the topmost one, with some exceptions (can't be keepabove/below, // policies - the topmost one, with some exceptions (can't be keepabove/below,
// otherwise it gets stuck on them) // otherwise it gets stuck on them)
Q_ASSERT(block_stacking_updates == 0); // Q_ASSERT(Workspace::self()->block_stacking_updates == 0);
for (int i = stacking_order.size() - 1; for (int i = Workspace::self()->stackingOrder().size() - 1;
i >= 0 ; i >= 0 ;
--i) { --i) {
Client* it = stacking_order.at(i); Client* it = Workspace::self()->stackingOrder().at(i);
if (it->isOnCurrentActivity() && it->isOnCurrentDesktop() && !it->isSpecialWindow() if (it->isOnCurrentActivity() && it->isOnCurrentDesktop() && !it->isSpecialWindow()
&& it->isShown(false) && it->wantsTabFocus() && it->isShown(false) && it->wantsTabFocus()
&& !it->keepAbove() && !it->keepBelow()) { && !it->keepAbove() && !it->keepBelow()) {
@ -966,46 +964,46 @@ void Workspace::CDEWalkThroughWindows(bool forward)
nc->isMinimized() || !nc->wantsTabFocus() || nc->keepAbove() || nc->keepBelow() || !nc->isOnCurrentActivity())); nc->isMinimized() || !nc->wantsTabFocus() || nc->keepAbove() || nc->keepBelow() || !nc->isOnCurrentActivity()));
if (nc) { if (nc) {
if (c && c != nc) if (c && c != nc)
lowerClient(c); Workspace::self()->lowerClient(c);
if (options->focusPolicyIsReasonable()) { if (options->focusPolicyIsReasonable()) {
activateClient(nc); Workspace::self()->activateClient(nc);
if (nc->isShade() && options->shadeHover) if (nc->isShade() && options->shadeHover)
nc->setShade(ShadeActivated); nc->setShade(ShadeActivated);
} else { } else {
if (!nc->isOnDesktop(currentDesktop())) if (!nc->isOnDesktop(currentDesktop()))
setCurrentDesktop(nc->desktop()); setCurrentDesktop(nc->desktop());
raiseClient(nc); Workspace::self()->raiseClient(nc);
} }
} }
} }
void Workspace::KDEOneStepThroughWindows(bool forward, TabBoxMode mode) void TabBox::KDEOneStepThroughWindows(bool forward, TabBoxMode mode)
{ {
tab_box->setMode(mode); setMode(mode);
tab_box->reset(); reset();
tab_box->nextPrev(forward); nextPrev(forward);
if (Client* c = tab_box->currentClient()) { if (Client* c = currentClient()) {
activateClient(c); Workspace::self()->activateClient(c);
if (c->isShade() && options->shadeHover) if (c->isShade() && options->shadeHover)
c->setShade(ShadeActivated); c->setShade(ShadeActivated);
} }
} }
void Workspace::oneStepThroughDesktops(bool forward, TabBoxMode mode) void TabBox::oneStepThroughDesktops(bool forward, TabBoxMode mode)
{ {
tab_box->setMode(mode); setMode(mode);
tab_box->reset(); reset();
tab_box->nextPrev(forward); nextPrev(forward);
if (tab_box->currentDesktop() != -1) if (currentDesktop() != -1)
setCurrentDesktop(tab_box->currentDesktop()); setCurrentDesktop(currentDesktop());
} }
void Workspace::oneStepThroughDesktops(bool forward) void TabBox::oneStepThroughDesktops(bool forward)
{ {
oneStepThroughDesktops(forward, TabBoxDesktopMode); oneStepThroughDesktops(forward, TabBoxDesktopMode);
} }
void Workspace::oneStepThroughDesktopList(bool forward) void TabBox::oneStepThroughDesktopList(bool forward)
{ {
oneStepThroughDesktops(forward, TabBoxDesktopListMode); oneStepThroughDesktops(forward, TabBoxDesktopListMode);
} }
@ -1013,20 +1011,20 @@ void Workspace::oneStepThroughDesktopList(bool forward)
/*! /*!
Handles holding alt-tab / control-tab Handles holding alt-tab / control-tab
*/ */
void Workspace::tabBoxKeyPress(int keyQt) void TabBox::keyPress(int keyQt)
{ {
bool forward = false; bool forward = false;
bool backward = false; bool backward = false;
if (tab_grab) { if (m_tabGrab) {
KShortcut forwardShortcut; KShortcut forwardShortcut;
KShortcut backwardShortcut; KShortcut backwardShortcut;
if (tab_box->mode() == TabBoxWindowsMode) { if (mode() == TabBoxWindowsMode) {
forwardShortcut = cutWalkThroughWindows; forwardShortcut = m_cutWalkThroughWindows;
backwardShortcut = cutWalkThroughWindowsReverse; backwardShortcut = m_cutWalkThroughWindowsReverse;
} else { } else {
forwardShortcut = cutWalkThroughWindowsAlternative; forwardShortcut = m_cutWalkThroughWindowsAlternative;
backwardShortcut = cutWalkThroughWindowsAlternativeReverse; backwardShortcut = m_cutWalkThroughWindowsAlternativeReverse;
} }
forward = forwardShortcut.contains(keyQt); forward = forwardShortcut.contains(keyQt);
backward = backwardShortcut.contains(keyQt); backward = backwardShortcut.contains(keyQt);
@ -1035,52 +1033,40 @@ void Workspace::tabBoxKeyPress(int keyQt)
<< " or " << backwardShortcut.toString() << endl; << " or " << backwardShortcut.toString() << endl;
KDEWalkThroughWindows(forward); KDEWalkThroughWindows(forward);
} }
} else if (control_grab) { } else if (m_desktopGrab) {
forward = cutWalkThroughDesktops.contains(keyQt) || forward = m_cutWalkThroughDesktops.contains(keyQt) ||
cutWalkThroughDesktopList.contains(keyQt); m_cutWalkThroughDesktopList.contains(keyQt);
backward = cutWalkThroughDesktopsReverse.contains(keyQt) || backward = m_cutWalkThroughDesktopsReverse.contains(keyQt) ||
cutWalkThroughDesktopListReverse.contains(keyQt); m_cutWalkThroughDesktopListReverse.contains(keyQt);
if (forward || backward) if (forward || backward)
walkThroughDesktops(forward); walkThroughDesktops(forward);
} }
if (control_grab || tab_grab) { if (m_desktopGrab || m_tabGrab) {
if (((keyQt & ~Qt::KeyboardModifierMask) == Qt::Key_Escape) if (((keyQt & ~Qt::KeyboardModifierMask) == Qt::Key_Escape)
&& !(forward || backward)) { && !(forward || backward)) {
// if Escape is part of the shortcut, don't cancel // if Escape is part of the shortcut, don't cancel
closeTabBox(true); close(true);
} else if (!(forward || backward)) { } else if (!(forward || backward)) {
QKeyEvent* event = new QKeyEvent(QEvent::KeyPress, keyQt & ~Qt::KeyboardModifierMask, Qt::NoModifier); QKeyEvent* event = new QKeyEvent(QEvent::KeyPress, keyQt & ~Qt::KeyboardModifierMask, Qt::NoModifier);
tab_box->grabbedKeyEvent(event); grabbedKeyEvent(event);
} }
} }
} }
void Workspace::refTabBox() void TabBox::close(bool abort)
{
if (tab_box)
tab_box->refDisplay();
}
void Workspace::unrefTabBox()
{
if (tab_box)
tab_box->unrefDisplay();
}
void Workspace::closeTabBox(bool abort)
{ {
removeTabBoxGrab(); removeTabBoxGrab();
tab_box->hide(abort); hide(abort);
modalActionsSwitch(true); modalActionsSwitch(true);
tab_grab = false; m_tabGrab = false;
control_grab = false; m_desktopGrab = false;
} }
/*! /*!
Handles alt-tab / control-tab releasing Handles alt-tab / control-tab releasing
*/ */
void Workspace::tabBoxKeyRelease(const XKeyEvent& ev) void TabBox::keyRelease(const XKeyEvent& ev)
{ {
unsigned int mk = ev.state & unsigned int mk = ev.state &
(KKeyServer::modXShift() | (KKeyServer::modXShift() |
@ -1113,66 +1099,67 @@ void Workspace::tabBoxKeyRelease(const XKeyEvent& ev)
} }
if (!release) if (!release)
return; return;
if (tab_grab) { if (m_tabGrab) {
bool old_control_grab = control_grab; bool old_control_grab = m_desktopGrab;
Client* c = tab_box->currentClient(); Client* c = currentClient();
closeTabBox(); close();
control_grab = old_control_grab; m_desktopGrab = old_control_grab;
if (c) { if (c) {
activateClient(c); Workspace::self()->activateClient(c);
if (c->isShade() && options->shadeHover) if (c->isShade() && options->shadeHover)
c->setShade(ShadeActivated); c->setShade(ShadeActivated);
if (c->isDesktop()) if (c->isDesktop())
setShowingDesktop(!showingDesktop()); Workspace::self()->setShowingDesktop(!Workspace::self()->showingDesktop());
} }
} }
if (control_grab) { if (m_desktopGrab) {
bool old_tab_grab = tab_grab; bool old_tab_grab = m_tabGrab;
int desktop = tab_box->currentDesktop(); int desktop = currentDesktop();
closeTabBox(); close();
tab_grab = old_tab_grab; m_tabGrab = old_tab_grab;
if (desktop != -1) { if (desktop != -1) {
setCurrentDesktop(desktop); setCurrentDesktop(desktop);
} }
} }
} }
int TabBox::nextDesktopFocusChain(int iDesktop) const
int Workspace::nextDesktopFocusChain(int iDesktop) const
{ {
int i = desktop_focus_chain.indexOf(iDesktop); const QVector<int> &desktopFocusChain = Workspace::self()->desktopFocusChain();
if (i >= 0 && i + 1 < (int)desktop_focus_chain.size()) int i = desktopFocusChain.indexOf(iDesktop);
return desktop_focus_chain[i+1]; if (i >= 0 && i + 1 < desktopFocusChain.size())
else if (desktop_focus_chain.size() > 0) return desktopFocusChain[i+1];
return desktop_focus_chain[ 0 ]; else if (desktopFocusChain.size() > 0)
return desktopFocusChain[ 0 ];
else else
return 1; return 1;
} }
int Workspace::previousDesktopFocusChain(int iDesktop) const int TabBox::previousDesktopFocusChain(int iDesktop) const
{ {
int i = desktop_focus_chain.indexOf(iDesktop); const QVector<int> &desktopFocusChain = Workspace::self()->desktopFocusChain();
int i = desktopFocusChain.indexOf(iDesktop);
if (i - 1 >= 0) if (i - 1 >= 0)
return desktop_focus_chain[i-1]; return desktopFocusChain[i-1];
else if (desktop_focus_chain.size() > 0) else if (desktopFocusChain.size() > 0)
return desktop_focus_chain[desktop_focus_chain.size()-1]; return desktopFocusChain[desktopFocusChain.size()-1];
else else
return numberOfDesktops(); return Workspace::self()->numberOfDesktops();
} }
int Workspace::nextDesktopStatic(int iDesktop) const int TabBox::nextDesktopStatic(int iDesktop) const
{ {
int i = ++iDesktop; int i = ++iDesktop;
if (i > numberOfDesktops()) if (i > Workspace::self()->numberOfDesktops())
i = 1; i = 1;
return i; return i;
} }
int Workspace::previousDesktopStatic(int iDesktop) const int TabBox::previousDesktopStatic(int iDesktop) const
{ {
int i = --iDesktop; int i = --iDesktop;
if (i < 1) if (i < 1)
i = numberOfDesktops(); i = Workspace::self()->numberOfDesktops();
return i; return i;
} }
@ -1180,110 +1167,73 @@ int Workspace::previousDesktopStatic(int iDesktop) const
auxiliary functions to travers all clients according to the focus auxiliary functions to travers all clients according to the focus
order. Useful for kwms Alt-tab feature. order. Useful for kwms Alt-tab feature.
*/ */
Client* Workspace::nextClientFocusChain(Client* c) const Client* TabBox::nextClientFocusChain(Client* c) const
{ {
if (global_focus_chain.isEmpty()) const ClientList &globalFocusChain = Workspace::self()->globalFocusChain();
if (globalFocusChain.isEmpty())
return 0; return 0;
int pos = global_focus_chain.indexOf(c); int pos = globalFocusChain.indexOf(c);
if (pos == -1) if (pos == -1)
return global_focus_chain.last(); return globalFocusChain.last();
if (pos == 0) if (pos == 0)
return global_focus_chain.last(); return globalFocusChain.last();
pos--; pos--;
return global_focus_chain[ pos ]; return globalFocusChain[ pos ];
} }
/*! /*!
auxiliary functions to travers all clients according to the focus auxiliary functions to travers all clients according to the focus
order. Useful for kwms Alt-tab feature. order. Useful for kwms Alt-tab feature.
*/ */
Client* Workspace::previousClientFocusChain(Client* c) const Client* TabBox::previousClientFocusChain(Client* c) const
{ {
if (global_focus_chain.isEmpty()) const ClientList &globalFocusChain = Workspace::self()->globalFocusChain();
if (globalFocusChain.isEmpty())
return 0; return 0;
int pos = global_focus_chain.indexOf(c); int pos = globalFocusChain.indexOf(c);
if (pos == -1) if (pos == -1)
return global_focus_chain.first(); return globalFocusChain.first();
pos++; pos++;
if (pos == global_focus_chain.count()) if (pos == globalFocusChain.count())
return global_focus_chain.first(); return globalFocusChain.first();
return global_focus_chain[ pos ]; return globalFocusChain[ pos ];
} }
/*! /*!
auxiliary functions to travers all clients according to the static auxiliary functions to travers all clients according to the static
order. Useful for the CDE-style Alt-tab feature. order. Useful for the CDE-style Alt-tab feature.
*/ */
Client* Workspace::nextClientStatic(Client* c) const Client* TabBox::nextClientStatic(Client* c) const
{ {
if (!c || clients.isEmpty()) if (!c || Workspace::self()->clientList().isEmpty())
return 0; return 0;
int pos = clients.indexOf(c); int pos = Workspace::self()->clientList().indexOf(c);
if (pos == -1) if (pos == -1)
return clients.first(); return Workspace::self()->clientList().first();
++pos; ++pos;
if (pos == clients.count()) if (pos == Workspace::self()->clientList().count())
return clients.first(); return Workspace::self()->clientList().first();
return clients[ pos ]; return Workspace::self()->clientList()[ pos ];
} }
/*! /*!
auxiliary functions to travers all clients according to the static auxiliary functions to travers all clients according to the static
order. Useful for the CDE-style Alt-tab feature. order. Useful for the CDE-style Alt-tab feature.
*/ */
Client* Workspace::previousClientStatic(Client* c) const Client* TabBox::previousClientStatic(Client* c) const
{ {
if (!c || clients.isEmpty()) if (!c || Workspace::self()->clientList().isEmpty())
return 0; return 0;
int pos = clients.indexOf(c); int pos = Workspace::self()->clientList().indexOf(c);
if (pos == -1) if (pos == -1)
return clients.last(); return Workspace::self()->clientList().last();
if (pos == 0) if (pos == 0)
return clients.last(); return Workspace::self()->clientList().last();
--pos; --pos;
return clients[ pos ]; return Workspace::self()->clientList()[ pos ];
} }
Client* Workspace::currentTabBoxClient() const bool TabBox::establishTabBoxGrab()
{
if (!tab_box)
return 0;
return tab_box->currentClient();
}
ClientList Workspace::currentTabBoxClientList() const
{
if (!tab_box)
return ClientList();
return tab_box->currentClientList();
}
int Workspace::currentTabBoxDesktop() const
{
if (!tab_box)
return -1;
return tab_box->currentDesktop();
}
QList< int > Workspace::currentTabBoxDesktopList() const
{
if (!tab_box)
return QList< int >();
return tab_box->currentDesktopList();
}
void Workspace::setTabBoxClient(Client* c)
{
if (tab_box)
tab_box->setCurrentClient(c);
}
void Workspace::setTabBoxDesktop(int iDesktop)
{
if (tab_box)
tab_box->setCurrentDesktop(iDesktop);
}
bool Workspace::establishTabBoxGrab()
{ {
if (!grabXKeyboard()) if (!grabXKeyboard())
return false; return false;
@ -1292,22 +1242,22 @@ bool Workspace::establishTabBoxGrab()
// in order to catch MouseRelease events and close the tabbox (#67416). // in order to catch MouseRelease events and close the tabbox (#67416).
// All clients already have passive grabs in their wrapper windows, so check only // All clients already have passive grabs in their wrapper windows, so check only
// the active client, which may not have it. // the active client, which may not have it.
assert(!forced_global_mouse_grab); assert(!m_forcedGlobalMouseGrab);
forced_global_mouse_grab = true; m_forcedGlobalMouseGrab = true;
if (active_client != NULL) if (Workspace::self()->activeClient() != NULL)
active_client->updateMouseGrab(); Workspace::self()->activeClient()->updateMouseGrab();
return true; return true;
} }
void Workspace::removeTabBoxGrab() void TabBox::removeTabBoxGrab()
{ {
ungrabXKeyboard(); ungrabXKeyboard();
assert(forced_global_mouse_grab); assert(m_forcedGlobalMouseGrab);
forced_global_mouse_grab = false; m_forcedGlobalMouseGrab = false;
if (active_client != NULL) if (Workspace::self()->activeClient() != NULL)
active_client->updateMouseGrab(); Workspace::self()->activeClient()->updateMouseGrab();
} }
} // namespace TabBox
} // namespace } // namespace
#include "tabbox.moc" #include "tabbox.moc"

136
tabbox.h
View File

@ -38,11 +38,11 @@ class Client;
namespace TabBox namespace TabBox
{ {
class TabBoxConfig; class TabBoxConfig;
class TabBox;
class TabBoxHandlerImpl : public TabBoxHandler class TabBoxHandlerImpl : public TabBoxHandler
{ {
public: public:
TabBoxHandlerImpl(); TabBoxHandlerImpl(TabBox* tabBox);
virtual ~TabBoxHandlerImpl(); virtual ~TabBoxHandlerImpl();
virtual int activeScreen() const; virtual int activeScreen() const;
@ -61,6 +61,9 @@ public:
virtual void hideOutline(); virtual void hideOutline();
virtual void showOutline(const QRect &outline); virtual void showOutline(const QRect &outline);
virtual QVector< Window > outlineWindowIds() const; virtual QVector< Window > outlineWindowIds() const;
private:
TabBox* m_tabBox;
}; };
class TabBoxClientImpl : public TabBoxClient class TabBoxClientImpl : public TabBoxClient
@ -93,7 +96,7 @@ class TabBox : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
TabBox(Workspace *ws); TabBox();
~TabBox(); ~TabBox();
Client* currentClient(); Client* currentClient();
@ -115,19 +118,75 @@ public:
void delayedShow(); void delayedShow();
void hide(bool abort = false); void hide(bool abort = false);
void refDisplay(); /*!
void unrefDisplay(); Increase the reference count, preventing the default tabbox from showing.
bool isDisplayed() const;
\sa unreference(), isDisplayed()
*/
void reference() {
++m_displayRefcount;
}
/*!
Decrease the reference count. Only when the reference count is 0 will
the default tab box be shown.
*/
void unreference() {
--m_displayRefcount;
}
/*!
Returns whether the tab box is being displayed, either natively or by an
effect.
\sa reference(), unreference()
*/
bool isDisplayed() const {
return m_displayRefcount > 0;
};
void handleMouseEvent(XEvent*); void handleMouseEvent(XEvent*);
void grabbedKeyEvent(QKeyEvent* event); void grabbedKeyEvent(QKeyEvent* event);
Workspace* workspace() const;
void reconfigure(); void reconfigure();
bool isGrabbed() const {
return m_tabGrab || m_desktopGrab;
};
void initShortcuts(KActionCollection* keys);
Client* nextClientFocusChain(Client*) const;
Client* previousClientFocusChain(Client*) const;
Client* nextClientStatic(Client*) const;
Client* previousClientStatic(Client*) const;
int nextDesktopFocusChain(int iDesktop) const;
int previousDesktopFocusChain(int iDesktop) const;
int nextDesktopStatic(int iDesktop) const;
int previousDesktopStatic(int iDesktop) const;
void close(bool abort = false);
void keyPress(int key);
void keyRelease(const XKeyEvent& ev);
public slots: public slots:
void show(); void show();
void slotWalkThroughDesktops();
void slotWalkBackThroughDesktops();
void slotWalkThroughDesktopList();
void slotWalkBackThroughDesktopList();
void slotWalkThroughWindows();
void slotWalkBackThroughWindows();
void slotWalkThroughWindowsAlternative();
void slotWalkBackThroughWindowsAlternative();
void slotWalkThroughDesktopsKeyChanged(const QKeySequence& seq);
void slotWalkBackThroughDesktopsKeyChanged(const QKeySequence& seq);
void slotWalkThroughDesktopListKeyChanged(const QKeySequence& seq);
void slotWalkBackThroughDesktopListKeyChanged(const QKeySequence& seq);
void slotWalkThroughWindowsKeyChanged(const QKeySequence& seq);
void slotWalkBackThroughWindowsKeyChanged(const QKeySequence& seq);
void slotMoveToTabLeftKeyChanged(const QKeySequence& seq);
void slotMoveToTabRightKeyChanged(const QKeySequence& seq);
void slotWalkThroughWindowsAlternativeKeyChanged(const QKeySequence& seq);
void slotWalkBackThroughWindowsAlternativeKeyChanged(const QKeySequence& seq);
signals: signals:
void tabBoxAdded(int); void tabBoxAdded(int);
@ -139,16 +198,31 @@ private:
void setCurrentIndex(QModelIndex index, bool notifyEffects = true); void setCurrentIndex(QModelIndex index, bool notifyEffects = true);
void loadConfig(const KConfigGroup& config, TabBoxConfig& tabBoxConfig); void loadConfig(const KConfigGroup& config, TabBoxConfig& tabBoxConfig);
bool startKDEWalkThroughWindows(TabBoxMode mode); // TabBoxWindowsMode | TabBoxWindowsAlternativeMode
bool startWalkThroughDesktops(TabBoxMode mode); // TabBoxDesktopMode | TabBoxDesktopListMode
bool startWalkThroughDesktops();
bool startWalkThroughDesktopList();
void navigatingThroughWindows(bool forward, const KShortcut& shortcut, TabBoxMode mode); // TabBoxWindowsMode | TabBoxWindowsAlternativeMode
void KDEWalkThroughWindows(bool forward);
void CDEWalkThroughWindows(bool forward);
void walkThroughDesktops(bool forward);
void KDEOneStepThroughWindows(bool forward, TabBoxMode mode); // TabBoxWindowsMode | TabBoxWindowsAlternativeMode
void oneStepThroughDesktops(bool forward, TabBoxMode mode); // TabBoxDesktopMode | TabBoxDesktopListMode
void oneStepThroughDesktops(bool forward);
void oneStepThroughDesktopList(bool forward);
bool establishTabBoxGrab();
void removeTabBoxGrab();
void modalActionsSwitch(bool enabled);
private: private:
Workspace* wspace;
TabBoxMode m_tabBoxMode; TabBoxMode m_tabBoxMode;
QModelIndex m_index; QModelIndex m_index;
TabBoxHandlerImpl* m_tabBox; TabBoxHandlerImpl* m_tabBox;
bool m_delayShow; bool m_delayShow;
int m_delayShowTime; int m_delayShowTime;
QTimer delayedShowTimer; QTimer m_delayedShowTimer;
int display_refcount; int m_displayRefcount;
TabBoxConfig m_defaultConfig; TabBoxConfig m_defaultConfig;
TabBoxConfig m_alternativeConfig; TabBoxConfig m_alternativeConfig;
@ -157,39 +231,15 @@ private:
// false if an effect has referenced the tabbox // false if an effect has referenced the tabbox
// true if tabbox is active (independent on showTabbox setting) // true if tabbox is active (independent on showTabbox setting)
bool m_isShown; bool m_isShown;
bool m_desktopGrab;
bool m_tabGrab;
KShortcut m_cutWalkThroughDesktops, m_cutWalkThroughDesktopsReverse;
KShortcut m_cutWalkThroughDesktopList, m_cutWalkThroughDesktopListReverse;
KShortcut m_cutWalkThroughWindows, m_cutWalkThroughWindowsReverse;
KShortcut m_cutWalkThroughGroupWindows, m_cutWalkThroughGroupWindowsReverse;
KShortcut m_cutWalkThroughWindowsAlternative, m_cutWalkThroughWindowsAlternativeReverse;
bool m_forcedGlobalMouseGrab;
}; };
/*!
Returns the tab box' workspace
*/
inline Workspace* TabBox::workspace() const
{
return wspace;
}
/*!
Increase the reference count, preventing the default tabbox from showing.
\sa unrefDisplay(), isDisplayed()
*/
inline void TabBox::refDisplay()
{
++display_refcount;
}
/*!
Returns whether the tab box is being displayed, either natively or by an
effect.
\sa refDisplay(), unrefDisplay()
*/
inline bool TabBox::isDisplayed() const
{
return display_refcount > 0;
}
} // namespace TabBox } // namespace TabBox
} // namespace } // namespace
#endif #endif

View File

@ -557,79 +557,12 @@ void Workspace::initShortcuts()
//disable_shortcuts_keys->disableBlocking( true ); //disable_shortcuts_keys->disableBlocking( true );
#define IN_KWIN #define IN_KWIN
#include "kwinbindings.cpp" #include "kwinbindings.cpp"
readShortcuts(); if (tab_box) {
} tab_box->initShortcuts(actionCollection);
void Workspace::readShortcuts()
{
// TODO: PORT ME (KGlobalAccel related)
//KGlobalAccel::self()->readSettings();
KAction *kaction = qobject_cast<KAction*>(keys->action("Walk Through Desktops"));
if (kaction != 0) {
cutWalkThroughDesktops = kaction->globalShortcut();
connect(kaction, SIGNAL(globalShortcutChanged(QKeySequence)), this, SLOT(slotWalkThroughDesktopsKeyChanged(QKeySequence)));
}
kaction = qobject_cast<KAction*>(keys->action("Walk Through Desktops (Reverse)"));
if (kaction != 0) {
cutWalkThroughDesktopsReverse = kaction->globalShortcut();
connect(kaction, SIGNAL(globalShortcutChanged(QKeySequence)), this, SLOT(slotWalkBackThroughDesktopsKeyChanged(QKeySequence)));
}
kaction = qobject_cast<KAction*>(keys->action("Walk Through Desktop List"));
if (kaction != 0) {
cutWalkThroughDesktopList = kaction->globalShortcut();
connect(kaction, SIGNAL(globalShortcutChanged(QKeySequence)), this, SLOT(slotWalkThroughDesktopListKeyChanged(QKeySequence)));
}
kaction = qobject_cast<KAction*>(keys->action("Walk Through Desktop List (Reverse)"));
if (kaction != 0) {
cutWalkThroughDesktopListReverse = kaction->globalShortcut();
connect(kaction, SIGNAL(globalShortcutChanged(QKeySequence)), this, SLOT(slotWalkBackThroughDesktopListKeyChanged(QKeySequence)));
}
kaction = qobject_cast<KAction*>(keys->action("Walk Through Windows"));
if (kaction != 0) {
cutWalkThroughWindows = kaction->globalShortcut();
connect(kaction, SIGNAL(globalShortcutChanged(QKeySequence)), this, SLOT(slotWalkThroughWindowsKeyChanged(QKeySequence)));
}
kaction = qobject_cast<KAction*>(keys->action("Walk Through Windows (Reverse)"));
if (kaction != 0) {
cutWalkThroughWindowsReverse = kaction->globalShortcut();
connect(kaction, SIGNAL(globalShortcutChanged(QKeySequence)), this, SLOT(slotWalkBackThroughWindowsKeyChanged(QKeySequence)));
}
kaction = qobject_cast<KAction*>(keys->action("Walk Through Window Tabs"));
if (kaction != 0) {
cutWalkThroughGroupWindows = kaction->globalShortcut();
connect(kaction, SIGNAL(globalShortcutChanged(QKeySequence)), this,
SLOT(slotMoveToTabRightKeyChanged(QKeySequence)));
}
kaction = qobject_cast<KAction*>(keys->action("Walk Through Window Tabs (Reverse)"));
if (kaction != 0) {
cutWalkThroughGroupWindowsReverse = kaction->globalShortcut();
connect(kaction, SIGNAL(globalShortcutChanged(QKeySequence)), this,
SLOT(slotMoveToTabLeftKeyChanged(QKeySequence)));
}
kaction = qobject_cast<KAction*>(keys->action("Walk Through Windows Alternative"));
if (kaction != 0) {
cutWalkThroughWindowsAlternative = kaction->globalShortcut();
connect(kaction, SIGNAL(globalShortcutChanged(QKeySequence)), this, SLOT(slotWalkThroughWindowsAlternativeKeyChanged(QKeySequence)));
}
kaction = qobject_cast<KAction*>(keys->action("Walk Through Windows Alternative (Reverse)"));
if (kaction != 0) {
cutWalkThroughWindowsAlternativeReverse = kaction->globalShortcut();
connect(kaction, SIGNAL(globalShortcutChanged(QKeySequence)), this, SLOT(slotWalkBackThroughWindowsAlternativeKeyChanged(QKeySequence)));
} }
discardPopup(); // so that it's recreated next time discardPopup(); // so that it's recreated next time
} }
void Workspace::setupWindowShortcut(Client* c) void Workspace::setupWindowShortcut(Client* c)
{ {
assert(client_keys_dialog == NULL); assert(client_keys_dialog == NULL);

View File

@ -121,8 +121,6 @@ Workspace::Workspace(bool restore)
, block_showing_desktop(0) , block_showing_desktop(0)
, was_user_interaction(false) , was_user_interaction(false)
, session_saving(false) , session_saving(false)
, control_grab(false)
, tab_grab(false)
, block_focus(0) , block_focus(0)
, tab_box(0) , tab_box(0)
, desktop_change_osd(0) , desktop_change_osd(0)
@ -211,7 +209,7 @@ Workspace::Workspace(bool restore)
Extensions::init(); Extensions::init();
compositingSuspended = !options->useCompositing; compositingSuspended = !options->useCompositing;
// need to create the tabbox before compositing scene is setup // need to create the tabbox before compositing scene is setup
tab_box = new TabBox::TabBox(this); tab_box = new TabBox::TabBox();
setupCompositing(); setupCompositing();
// Compatibility // Compatibility
@ -589,7 +587,7 @@ void Workspace::addClient(Client* c, allowed_t)
if (c->isUtility() || c->isMenu() || c->isToolbar()) if (c->isUtility() || c->isMenu() || c->isToolbar())
updateToolWindows(true); updateToolWindows(true);
checkNonExistentClients(); checkNonExistentClients();
if (tab_grab) if (tabBox()->isGrabbed())
tab_box->reset(true); tab_box->reset(true);
} }
@ -621,7 +619,7 @@ void Workspace::removeClient(Client* c, allowed_t)
if (c->isNormalWindow()) if (c->isNormalWindow())
Notify::raise(Notify::Delete); Notify::raise(Notify::Delete);
if (tab_grab && tab_box->currentClient() == c) if (tabBox()->isGrabbed() && tabBox()->currentClient() == c)
tab_box->nextPrev(true); tab_box->nextPrev(true);
Q_ASSERT(clients.contains(c) || desktops.contains(c)); Q_ASSERT(clients.contains(c) || desktops.contains(c));
@ -658,7 +656,7 @@ void Workspace::removeClient(Client* c, allowed_t)
updateCompositeBlocking(); updateCompositeBlocking();
if (tab_grab) if (tabBox()->isGrabbed())
tab_box->reset(true); tab_box->reset(true);
updateClientArea(); updateClientArea();
@ -890,7 +888,7 @@ void Workspace::slotSettingsChanged(int category)
{ {
kDebug(1212) << "Workspace::slotSettingsChanged()"; kDebug(1212) << "Workspace::slotSettingsChanged()";
if (category == KGlobalSettings::SETTINGS_SHORTCUTS) if (category == KGlobalSettings::SETTINGS_SHORTCUTS)
readShortcuts(); discardPopup();
} }
/** /**
@ -915,7 +913,7 @@ void Workspace::slotReconfigure()
tab_box->reconfigure(); tab_box->reconfigure();
desktop_change_osd->reconfigure(); desktop_change_osd->reconfigure();
initPositioning->reinitCascading(0); initPositioning->reinitCascading(0);
readShortcuts(); discardPopup();
forEachClient(CheckIgnoreFocusStealingProcedure()); forEachClient(CheckIgnoreFocusStealingProcedure());
updateToolWindows(true); updateToolWindows(true);

View File

@ -42,6 +42,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "sm.h" #include "sm.h"
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include "tabbox.h"
// TODO: Cleanup the order of things in this .h file // TODO: Cleanup the order of things in this .h file
@ -348,26 +349,27 @@ public:
} }
// Tab box // Tab box
Client* currentTabBoxClient() const;
ClientList currentTabBoxClientList() const;
int currentTabBoxDesktop() const;
QList<int> currentTabBoxDesktopList() const;
void setTabBoxClient(Client*);
void setTabBoxDesktop(int);
Client* nextClientFocusChain(Client*) const;
Client* previousClientFocusChain(Client*) const;
Client* nextClientStatic(Client*) const;
Client* previousClientStatic(Client*) const;
int nextDesktopFocusChain(int iDesktop) const;
int previousDesktopFocusChain(int iDesktop) const;
int nextDesktopStatic(int iDesktop) const;
int previousDesktopStatic(int iDesktop) const;
void refTabBox();
void unrefTabBox();
void closeTabBox(bool abort = false);
TabBox::TabBox *tabBox() const { TabBox::TabBox *tabBox() const {
return tab_box; return tab_box;
} }
bool hasTabBox() const {
return tab_box != NULL;
}
const QVector<int> &desktopFocusChain() const {
return desktop_focus_chain;
}
const ClientList &globalFocusChain() const {
return global_focus_chain;
}
KActionCollection* actionCollection() const {
return keys;
}
KActionCollection* disableShortcutsKeys() const {
return disable_shortcuts_keys;
}
KActionCollection* clientKeys() const {
return client_keys;
}
// Tabbing // Tabbing
void addClientGroup(ClientGroup* group); void addClientGroup(ClientGroup* group);
@ -595,26 +597,6 @@ public slots:
void slotWindowQuickTileBottomLeft(); void slotWindowQuickTileBottomLeft();
void slotWindowQuickTileBottomRight(); void slotWindowQuickTileBottomRight();
void slotWalkThroughDesktops();
void slotWalkBackThroughDesktops();
void slotWalkThroughDesktopList();
void slotWalkBackThroughDesktopList();
void slotWalkThroughWindows();
void slotWalkBackThroughWindows();
void slotWalkThroughWindowsAlternative();
void slotWalkBackThroughWindowsAlternative();
void slotWalkThroughDesktopsKeyChanged(const QKeySequence& seq);
void slotWalkBackThroughDesktopsKeyChanged(const QKeySequence& seq);
void slotWalkThroughDesktopListKeyChanged(const QKeySequence& seq);
void slotWalkBackThroughDesktopListKeyChanged(const QKeySequence& seq);
void slotWalkThroughWindowsKeyChanged(const QKeySequence& seq);
void slotWalkBackThroughWindowsKeyChanged(const QKeySequence& seq);
void slotMoveToTabLeftKeyChanged(const QKeySequence& seq);
void slotMoveToTabRightKeyChanged(const QKeySequence& seq);
void slotWalkThroughWindowsAlternativeKeyChanged(const QKeySequence& seq);
void slotWalkBackThroughWindowsAlternativeKeyChanged(const QKeySequence& seq);
void slotSwitchWindowUp(); void slotSwitchWindowUp();
void slotSwitchWindowDown(); void slotSwitchWindowDown();
void slotSwitchWindowRight(); void slotSwitchWindowRight();
@ -742,7 +724,6 @@ signals:
private: private:
void init(); void init();
void initShortcuts(); void initShortcuts();
void readShortcuts();
void initDesktopPopup(); void initDesktopPopup();
void initActivityPopup(); void initActivityPopup();
void discardPopup(); void discardPopup();
@ -756,20 +737,6 @@ private:
DirectionWest DirectionWest
}; };
void switchWindow(Direction direction); void switchWindow(Direction direction);
bool startKDEWalkThroughWindows(TabBoxMode mode); // TabBoxWindowsMode | TabBoxWindowsAlternativeMode
bool startWalkThroughDesktops(TabBoxMode mode); // TabBoxDesktopMode | TabBoxDesktopListMode
bool startWalkThroughDesktops();
bool startWalkThroughDesktopList();
void navigatingThroughWindows(bool forward, const KShortcut& shortcut, TabBoxMode mode); // TabBoxWindowsMode | TabBoxWindowsAlternativeMode
void KDEWalkThroughWindows(bool forward);
void CDEWalkThroughWindows(bool forward);
void walkThroughDesktops(bool forward);
void KDEOneStepThroughWindows(bool forward, TabBoxMode mode); // TabBoxWindowsMode | TabBoxWindowsAlternativeMode
void oneStepThroughDesktops(bool forward, TabBoxMode mode); // TabBoxDesktopMode | TabBoxDesktopListMode
void oneStepThroughDesktops(bool forward);
void oneStepThroughDesktopList(bool forward);
bool establishTabBoxGrab();
void removeTabBoxGrab();
void propagateClients(bool propagate_new_clients); // Called only from updateStackingOrder void propagateClients(bool propagate_new_clients); // Called only from updateStackingOrder
ClientList constrainedStackingOrder(); ClientList constrainedStackingOrder();
@ -797,9 +764,6 @@ private:
void loadDesktopSettings(); void loadDesktopSettings();
void saveDesktopSettings(); void saveDesktopSettings();
void tabBoxKeyPress(int key);
void tabBoxKeyRelease(const XKeyEvent& ev);
//--------------------------------------------------------------------- //---------------------------------------------------------------------
void helperDialog(const QString& message, const Client* c); void helperDialog(const QString& message, const Client* c);
@ -881,16 +845,6 @@ private:
int session_active_client; int session_active_client;
int session_desktop; int session_desktop;
bool control_grab;
bool tab_grab;
//KKeyNative walkThroughDesktopsKeycode, walkBackThroughDesktopsKeycode;
//KKeyNative walkThroughDesktopListKeycode, walkBackThroughDesktopListKeycode;
//KKeyNative walkThroughWindowsKeycode, walkBackThroughWindowsKeycode;
KShortcut cutWalkThroughDesktops, cutWalkThroughDesktopsReverse;
KShortcut cutWalkThroughDesktopList, cutWalkThroughDesktopListReverse;
KShortcut cutWalkThroughWindows, cutWalkThroughWindowsReverse;
KShortcut cutWalkThroughGroupWindows, cutWalkThroughGroupWindowsReverse;
KShortcut cutWalkThroughWindowsAlternative, cutWalkThroughWindowsAlternativeReverse;
int block_focus; int block_focus;
TabBox::TabBox* tab_box; TabBox::TabBox* tab_box;
@ -909,6 +863,7 @@ private:
KActionCollection* keys; KActionCollection* keys;
KActionCollection* client_keys; KActionCollection* client_keys;
KActionCollection* disable_shortcuts_keys;
QAction* mResizeOpAction; QAction* mResizeOpAction;
QAction* mMoveOpAction; QAction* mMoveOpAction;
QAction* mMaximizeOpAction; QAction* mMaximizeOpAction;
@ -924,7 +879,6 @@ private:
QAction* mCloseGroup; // Close all clients in the group QAction* mCloseGroup; // Close all clients in the group
ShortcutDialog* client_keys_dialog; ShortcutDialog* client_keys_dialog;
Client* client_keys_client; Client* client_keys_client;
KActionCollection* disable_shortcuts_keys;
bool global_shortcuts_disabled; bool global_shortcuts_disabled;
bool global_shortcuts_disabled_for_client; bool global_shortcuts_disabled_for_client;