From 1e959a2aeca4499a1b8a79d1793953348638b69f Mon Sep 17 00:00:00 2001 From: Darrell Anderson Date: Sat, 9 Jun 2012 21:42:15 -0500 Subject: Added Mac-like window switching for one app with keyboard shortcut Alt-~. This resolves bug report 869. Thanks to Calvin Morrison. --- twin/tabbox.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- twin/tabbox.h | 16 +++++++++++++++- twin/twinbindings.cpp | 2 ++ twin/useractions.cpp | 2 ++ twin/workspace.h | 4 ++++ 5 files changed, 70 insertions(+), 4 deletions(-) diff --git a/twin/tabbox.cpp b/twin/tabbox.cpp index 284a920bc..4f5a19364 100644 --- a/twin/tabbox.cpp +++ b/twin/tabbox.cpp @@ -47,6 +47,7 @@ TabBox::TabBox( Workspace *ws, const char *name ) setLineWidth(2); setMargin(2); + appsOnly = false; showMiniIcon = false; no_tasks = i18n("*** No Windows ***"); @@ -86,6 +87,14 @@ void TabBox::setMode( Mode mode ) m = mode; } +/*! + Sets AppsOnly, which when true, createClientList will return only applications within the same class + + */ +void TabBox::setAppsOnly( bool a ) + { + appsOnly = a; + } /*! Create list of clients on specified desktop, starting with client c @@ -93,11 +102,14 @@ void TabBox::setMode( Mode mode ) void TabBox::createClientList(ClientList &list, int desktop /*-1 = all*/, Client *c, bool chain) { ClientList::size_type idx = 0; - + TQString startClass; list.clear(); Client* start = c; + if( start ) + startClass = start->resourceClass(); + if ( chain ) c = workspace()->nextFocusChainClient(c); else @@ -121,6 +133,10 @@ void TabBox::createClientList(ClientList &list, int desktop /*-1 = all*/, Client // nothing } } + if(appsOnly && (TQString::compare( startClass, c->resourceClass()) != 0)) + { + add = NULL; + } if( options->separateScreenFocus && options->xineramaEnabled ) { @@ -645,6 +661,7 @@ void TabBox::hide() XEvent otherEvent; while (XCheckTypedEvent (tqt_xdisplay(), EnterNotify, &otherEvent ) ) ; + appsOnly = false; } @@ -893,6 +910,18 @@ void Workspace::slotWalkBackThroughWindows() } } +void Workspace::slotWalkThroughApps() + { + tab_box->setAppsOnly(true); + slotWalkThroughWindows(); + } + +void Workspace::slotWalkBackThroughApps() + { + tab_box->setAppsOnly(true); + slotWalkBackThroughWindows(); + } + void Workspace::slotWalkThroughDesktops() { if ( root != tqt_xrootwin() ) @@ -1112,18 +1141,33 @@ void Workspace::tabBoxKeyPress( const KKeyNative& keyX ) { bool forward = false; bool backward = false; + bool forwardapps = false; + bool backwardapps = false; if (tab_grab) { forward = cutWalkThroughWindows.contains( keyX ); backward = cutWalkThroughWindowsReverse.contains( keyX ); - if (forward || backward) + + forwardapps = cutWalkThroughApps.contains( keyX ); + backwardapps = cutWalkThroughAppsReverse.contains( keyX ); + + if ( (forward || backward) && (!tab_box->isAppsOnly()) ) { kdDebug(125) << "== " << cutWalkThroughWindows.toStringInternal() << " or " << cutWalkThroughWindowsReverse.toStringInternal() << endl; + KDEWalkThroughWindows( forward ); } - } + + if ( (forwardapps || backwardapps) && (tab_box->isAppsOnly()) ) + { + kdDebug(125) << "== " << cutWalkThroughWindows.toStringInternal() + << " or " << cutWalkThroughWindowsReverse.toStringInternal() << endl; + KDEWalkThroughWindows( forwardapps ); + } + } + else if (control_grab) { forward = cutWalkThroughDesktops.contains( keyX ) || diff --git a/twin/tabbox.h b/twin/tabbox.h index d77633125..f9e3a8e0f 100644 --- a/twin/tabbox.h +++ b/twin/tabbox.h @@ -35,13 +35,15 @@ class TabBox : public TQFrame Client* currentClient(); void setCurrentClient( Client* c ); int currentDesktop(); - + // DesktopMode and WindowsMode are based on the order in which the desktop // or window were viewed. // DesktopListMode lists them in the order created. enum Mode { DesktopMode, DesktopListMode, WindowsMode }; void setMode( Mode mode ); + void setAppsOnly( bool a ); Mode mode() const; + bool isAppsOnly() const; void reset(); void nextPrev( bool next = TRUE); @@ -72,6 +74,7 @@ class TabBox : public TQFrame int desk; int lineHeight; bool showMiniIcon; + bool appsOnly; TQTimer delayedShowTimer; TQString no_tasks; bool options_traverse_all; @@ -97,6 +100,17 @@ inline TabBox::Mode TabBox::mode() const return m; } +/*! + Returns the appsOnly variable + + \sa setAppsOnly() + */ +inline bool TabBox::isAppsOnly() const + { + return appsOnly; + } + + } // namespace #endif diff --git a/twin/twinbindings.cpp b/twin/twinbindings.cpp index 265e5b8e9..f1c47cda0 100644 --- a/twin/twinbindings.cpp +++ b/twin/twinbindings.cpp @@ -20,6 +20,8 @@ keys->insert( "Group:Navigation", i18n("Navigation") ); DEF( I18N_NOOP("Walk Through Windows"), ALT+Qt::Key_Tab, ALT+Qt::Key_Tab, slotWalkThroughWindows() ); DEF( I18N_NOOP("Walk Through Windows (Reverse)"), ALT+SHIFT+Qt::Key_Tab, ALT+SHIFT+Qt::Key_Tab, slotWalkBackThroughWindows() ); + DEF( I18N_NOOP("Walk Through Windows of Same Application"), ALT+Qt::Key_QuoteLeft, ALT+Qt::Key_QuoteLeft, slotWalkThroughApps() ); + DEF( I18N_NOOP("Walk Through Windows of Same Application (Reverse)"), ALT+Qt::Key_AsciiTilde, ALT+Qt::Key_AsciiTilde, slotWalkBackThroughApps() ); DEF( I18N_NOOP("Walk Through Desktops"), 0, WIN+Qt::Key_Tab, slotWalkThroughDesktops() ); DEF( I18N_NOOP("Walk Through Desktops (Reverse)"), 0, WIN+SHIFT+Qt::Key_Tab, slotWalkBackThroughDesktops() ); DEF( I18N_NOOP("Walk Through Desktop List"), 0, 0, slotWalkThroughDesktopList() ); diff --git a/twin/useractions.cpp b/twin/useractions.cpp index e036adc76..37001bd93 100644 --- a/twin/useractions.cpp +++ b/twin/useractions.cpp @@ -279,6 +279,8 @@ void Workspace::readShortcuts() cutWalkThroughDesktopListReverse = keys->shortcut("Walk Through Desktop List (Reverse)"); cutWalkThroughWindows = keys->shortcut("Walk Through Windows"); cutWalkThroughWindowsReverse = keys->shortcut("Walk Through Windows (Reverse)"); + cutWalkThroughApps = keys->shortcut("Walk Through Windows of Same Application"); + cutWalkThroughAppsReverse = keys->shortcut("Walk Through Windows of Same Application (Reverse)"); keys->updateConnections(); disable_shortcuts_keys->updateConnections(); diff --git a/twin/workspace.h b/twin/workspace.h index fb9302a00..7cb2c3a6a 100644 --- a/twin/workspace.h +++ b/twin/workspace.h @@ -343,6 +343,9 @@ class Workspace : public TQObject, public KWinInterface, public KDecorationDefin void slotWalkThroughDesktops(); void slotWalkBackThroughDesktops(); + void slotWalkThroughApps(); + void slotWalkBackThroughApps(); + void slotWalkThroughDesktopList(); void slotWalkBackThroughDesktopList(); void slotWalkThroughWindows(); @@ -565,6 +568,7 @@ class Workspace : public TQObject, public KWinInterface, public KDecorationDefin KShortcut cutWalkThroughDesktops, cutWalkThroughDesktopsReverse; KShortcut cutWalkThroughDesktopList, cutWalkThroughDesktopListReverse; KShortcut cutWalkThroughWindows, cutWalkThroughWindowsReverse; + KShortcut cutWalkThroughApps, cutWalkThroughAppsReverse; bool mouse_emulation; unsigned int mouse_emulation_state; WId mouse_emulation_window; -- cgit v1.2.1