13 #include "workspace.h"
15 #include <tqpainter.h>
17 #include <tqdrawutil.h>
19 #include <tdeglobal.h>
21 #include <tdeconfig.h>
22 #include <tdelocale.h>
23 #include <tqapplication.h>
24 #include <tqdesktopwidget.h>
25 #include <kstringhandler.h>
28 #include <kglobalaccel.h>
29 #include <kkeynative.h>
30 #include <tdeglobalsettings.h>
31 #include <kiconeffect.h>
32 #include <X11/keysym.h>
33 #include <X11/keysymdef.h>
37 namespace KWinInternal
40 extern TQPixmap* twin_get_menu_pix_hack();
42 TabBox::TabBox( Workspace *ws,
const char *name )
43 : TQFrame( 0, name, TQt::WNoAutoErase ), current_client( NULL ), wspace(ws)
45 setFrameStyle(TQFrame::StyledPanel | TQFrame::Plain);
52 no_tasks = i18n(
"*** No Windows ***");
56 connect(&delayedShowTimer, TQ_SIGNAL(timeout()),
this, TQ_SLOT(show()));
58 XSetWindowAttributes attr;
59 attr.override_redirect = 1;
60 outline_left = XCreateWindow( tqt_xdisplay(), tqt_xrootwin(), 0, 0, 1, 1, 0,
61 CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attr );
62 outline_right = XCreateWindow( tqt_xdisplay(), tqt_xrootwin(), 0, 0, 1, 1, 0,
63 CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attr );
64 outline_top = XCreateWindow( tqt_xdisplay(), tqt_xrootwin(), 0, 0, 1, 1, 0,
65 CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attr );
66 outline_bottom = XCreateWindow( tqt_xdisplay(), tqt_xrootwin(), 0, 0, 1, 1, 0,
67 CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attr );
72 XDestroyWindow( tqt_xdisplay(), outline_left );
73 XDestroyWindow( tqt_xdisplay(), outline_right );
74 XDestroyWindow( tqt_xdisplay(), outline_top );
75 XDestroyWindow( tqt_xdisplay(), outline_bottom );
84 void TabBox::setMode( Mode mode )
93 void TabBox::setAppsOnly(
bool a )
101 void TabBox::createClientList(ClientList &list,
int desktop , Client *c,
bool chain)
103 ClientList::size_type idx = 0;
110 startClass = start->resourceClass();
113 c = workspace()->nextFocusChainClient(c);
115 c = workspace()->stackingOrder().first();
122 if ( ((desktop == -1) || c->isOnDesktop(desktop))
123 && c->wantsTabFocus() )
125 Client* modal = c->findModal();
126 if( modal == NULL || modal == c )
128 else if( !list.contains( modal ))
135 if(appsOnly && (TQString::compare( startClass, c->resourceClass()) != 0))
140 if( options->separateScreenFocus && options->xineramaEnabled )
142 if( c->screen() != workspace()->activeScreen())
158 c = workspace()->nextFocusChainClient( c );
161 if ( idx >= (workspace()->stackingOrder().size()-1) )
164 c = workspace()->stackingOrder()[++idx];
179 int w, h, cw = 0, wmax = 0;
181 TQRect r = workspace()->screenGeometry( workspace()->activeScreen());
185 lineHeight = TQMAX(fontMetrics().height() + 2, 32 + 4);
187 if ( mode() == WindowsMode )
189 setCurrentClient( workspace()->activeClient());
192 createClientList(clients, options_traverse_all ? -1 : workspace()->currentDesktop(), current_client,
true);
195 cw = fontMetrics().width(no_tasks)+20;
196 for (ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it)
198 cw = fontMetrics().width( (*it)->caption() );
199 if ( cw > wmax ) wmax = cw;
203 if ( clients.count() == 0 )
207 f.setPointSize( 14 );
209 h = TQFontMetrics(f).height()*4;
213 showMiniIcon =
false;
214 h = clients.count() * lineHeight;
216 if ( h > (r.height()-(2*frameWidth())) )
220 lineHeight = TQMAX(fontMetrics().height() + 2, 16 + 2);
222 h = clients.count() * lineHeight;
224 if ( h > (r.height()-(2*frameWidth())) )
227 int howMany = (h - (r.height()-(2*frameWidth())))/lineHeight;
228 for (; howMany; howMany--)
229 clients.remove(clients.last());
231 h = clients.count() * lineHeight;
238 showMiniIcon =
false;
239 desk = workspace()->currentDesktop();
241 for (
int i = 1; i <= workspace()->numberOfDesktops(); i++ )
243 cw = fontMetrics().width( workspace()->desktopName(i) );
244 if ( cw > wmax ) wmax = cw;
248 h = workspace()->numberOfDesktops() * lineHeight;
252 h += 2 * frameWidth();
253 w = 2*frameWidth() + 5*2 + ( showMiniIcon ? 16 : 32 ) + 8 + wmax;
254 w = kClamp( w, r.width()/3 , r.width() * 4 / 5 );
256 setGeometry( (r.width()-w)/2 + r.x(),
257 (r.height()-h)/2+ r.y(),
265 void TabBox::nextPrev(
bool next)
267 if ( mode() == WindowsMode )
269 Client* firstClient = NULL;
270 Client* client = current_client;
274 client = workspace()->nextFocusChainClient(client);
276 client = workspace()->previousFocusChainClient(client);
281 firstClient = client;
283 else if (client == firstClient)
289 }
while ( client && !clients.contains( client ));
290 setCurrentClient( client );
292 else if( mode() == DesktopMode )
295 desk = workspace()->nextDesktopFocusChain( desk );
297 desk = workspace()->previousDesktopFocusChain( desk );
304 if ( desk > workspace()->numberOfDesktops() )
311 desk = workspace()->numberOfDesktops();
324 Client* TabBox::currentClient()
326 if ( mode() != WindowsMode )
328 if (!workspace()->hasClient( current_client ))
330 return current_client;
333 void TabBox::setCurrentClient( Client* c )
335 if( current_client != c )
347 int TabBox::currentDesktop()
349 if ( mode() == DesktopListMode || mode() == DesktopMode )
359 void TabBox::showEvent( TQShowEvent* )
362 XRaiseWindow( tqt_xdisplay(), outline_left );
363 XRaiseWindow( tqt_xdisplay(), outline_right );
364 XRaiseWindow( tqt_xdisplay(), outline_top );
365 XRaiseWindow( tqt_xdisplay(), outline_bottom );
373 void TabBox::hideEvent( TQHideEvent* )
375 XUnmapWindow( tqt_xdisplay(), outline_left );
376 XUnmapWindow( tqt_xdisplay(), outline_right );
377 XUnmapWindow( tqt_xdisplay(), outline_top );
378 XUnmapWindow( tqt_xdisplay(), outline_bottom );
384 void TabBox::drawContents( TQPainter * )
386 TQRect r(contentsRect());
387 TQPixmap pix(r.size());
388 pix.fill(
this, 0, 0);
393 TQPixmap* menu_pix = twin_get_menu_pix_hack();
395 int iconWidth = showMiniIcon ? 16 : 32;
399 if ( mode () == WindowsMode )
401 if ( !currentClient() )
405 f.setPointSize( 14 );
408 p.drawText( r, AlignCenter, no_tasks);
412 for (ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it)
414 if ( workspace()->hasClient( *it ) )
417 if ( (*it) == current_client )
418 p.fillRect(x, y, r.width(), lineHeight, colorGroup().highlight());
424 if ( !(*it)->miniIcon().isNull() )
425 icon = (*it)->miniIcon();
428 if ( !(*it)->icon().isNull() )
429 icon = (*it)->icon();
435 if( (*it)->isMinimized())
436 TDEIconEffect::semiTransparent( icon );
437 p.drawPixmap( x+5, y + (lineHeight - iconWidth)/2, icon );
443 if ( !(*it)->isOnDesktop(workspace()->currentDesktop()) )
444 s = workspace()->desktopName((*it)->desktop()) +
": ";
446 if ( (*it)->isMinimized() )
447 s += TQString(
"(") + (*it)->caption() +
")";
449 s += (*it)->caption();
451 s = KStringHandler::cPixelSqueeze(s, fontMetrics(), r.width() - 5 - iconWidth - 8);
454 if ( (*it) == current_client )
455 p.setPen(colorGroup().highlightedText());
456 else if( (*it)->isMinimized())
458 TQColor c1 = colorGroup().text();
459 TQColor c2 = colorGroup().background();
464 c1.rgb( &r1, &g1, &b1 );
465 c2.rgb( &r2, &g2, &b2 );
467 r1 += (int) ( .5 * ( r2 - r1 ) );
468 g1 += (int) ( .5 * ( g2 - g1 ) );
469 b1 += (int) ( .5 * ( b2 - b1 ) );
471 p.setPen(TQColor( r1, g1, b1 ));
474 p.setPen(colorGroup().text());
476 p.drawText(x+5 + iconWidth + 8, y, r.width() - 5 - iconWidth - 8, lineHeight,
477 TQt::AlignLeft | TQt::AlignVCenter | TQt::SingleLine, s);
481 if ( y >= r.height() )
break;
487 int iconHeight = iconWidth;
492 f.setPixelSize(iconHeight - 4);
496 for (
int i = 1; i <= workspace()->numberOfDesktops(); i++ )
498 wmax = TQMAX(wmax, fontMetrics().width(workspace()->desktopName(i)));
501 TQString num = TQString::number(i);
502 iconWidth = TQMAX(iconWidth - 4, fm.boundingRect(num).width()) + 4;
507 int iDesktop = (mode() == DesktopMode) ? workspace()->currentDesktop() : 1;
508 for (
int i = 1; i <= workspace()->numberOfDesktops(); i++ )
511 if ( iDesktop == desk )
512 p.fillRect(x, y, r.width(), lineHeight, colorGroup().highlight());
517 p.fillRect(x+5, y+2, iconWidth, iconHeight, colorGroup().base());
518 p.setPen(colorGroup().text());
519 p.drawRect(x+5, y+2, iconWidth, iconHeight);
523 TQString num = TQString::number(iDesktop);
524 p.drawText(x+5, y+2, iconWidth, iconHeight, TQt::AlignCenter, num);
529 if ( iDesktop == desk )
530 p.setPen(colorGroup().highlightedText());
532 p.setPen(colorGroup().text());
534 p.drawText(x+5 + iconWidth + 8, y, r.width() - 5 - iconWidth - 8, lineHeight,
535 TQt::AlignLeft | TQt::AlignVCenter | TQt::SingleLine,
536 workspace()->desktopName(iDesktop));
539 int x1 = x + 5 + iconWidth + 8 + wmax + 5;
542 createClientList(list, iDesktop, 0,
false);
544 for (ClientList::ConstIterator it = list.fromLast(); it != list.end(); --it)
546 if ( !(*it)->miniIcon().isNull() )
548 if ( x1+18 >= x+r.width() )
551 p.drawPixmap( x1, y + (lineHeight - 16)/2, (*it)->miniIcon() );
558 if ( y >= r.height() )
break;
560 if( mode() == DesktopMode )
561 iDesktop = workspace()->nextDesktopFocusChain( iDesktop );
567 bitBlt(
this, r.x(), r.y(), &pix);
570 void TabBox::updateOutline()
572 Client* c = currentClient();
573 if( !options->tabboxOutline || c == NULL || this->isHidden() || !c->isShown(
true ) || !c->isOnCurrentDesktop())
575 XUnmapWindow( tqt_xdisplay(), outline_left );
576 XUnmapWindow( tqt_xdisplay(), outline_right );
577 XUnmapWindow( tqt_xdisplay(), outline_top );
578 XUnmapWindow( tqt_xdisplay(), outline_bottom );
582 XMoveResizeWindow( tqt_xdisplay(), outline_left, c->x(), c->y() + 5, 5, c->height() - 10 );
583 XMoveResizeWindow( tqt_xdisplay(), outline_right, c->x() + c->width() - 5, c->y() + 5, 5, c->height() - 10 );
584 XMoveResizeWindow( tqt_xdisplay(), outline_top, c->x(), c->y(), c->width(), 5 );
585 XMoveResizeWindow( tqt_xdisplay(), outline_bottom, c->x(), c->y() + c->height() - 5, c->width(), 5 );
587 TQPixmap pix( 5, c->height() - 10 );
590 p.drawLine( 0, 0, 0, pix.height() - 1 );
591 p.drawLine( 4, 0, 4, pix.height() - 1 );
593 p.drawLine( 1, 0, 1, pix.height() - 1 );
594 p.drawLine( 3, 0, 3, pix.height() - 1 );
596 p.drawLine( 2, 0, 2, pix.height() - 1 );
598 XSetWindowBackgroundPixmap( tqt_xdisplay(), outline_left, pix.handle());
599 XSetWindowBackgroundPixmap( tqt_xdisplay(), outline_right, pix.handle());
602 TQPixmap pix( c->width(), 5 );
605 p.drawLine( 0, 0, pix.width() - 1 - 0, 0 );
606 p.drawLine( 4, 4, pix.width() - 1 - 4, 4 );
607 p.drawLine( 0, 0, 0, 4 );
608 p.drawLine( pix.width() - 1 - 0, 0, pix.width() - 1 - 0, 4 );
610 p.drawLine( 1, 1, pix.width() - 1 - 1, 1 );
611 p.drawLine( 3, 3, pix.width() - 1 - 3, 3 );
612 p.drawLine( 1, 1, 1, 4 );
613 p.drawLine( 3, 3, 3, 4 );
614 p.drawLine( pix.width() - 1 - 1, 1, pix.width() - 1 - 1, 4 );
615 p.drawLine( pix.width() - 1 - 3, 3, pix.width() - 1 - 3, 4 );
617 p.drawLine( 2, 2, pix.width() - 1 - 2, 2 );
618 p.drawLine( 2, 2, 2, 4 );
619 p.drawLine( pix.width() - 1 - 2, 2, pix.width() - 1 - 2, 4 );
621 XSetWindowBackgroundPixmap( tqt_xdisplay(), outline_top, pix.handle());
624 TQPixmap pix( c->width(), 5 );
627 p.drawLine( 4, 0, pix.width() - 1 - 4, 0 );
628 p.drawLine( 0, 4, pix.width() - 1 - 0, 4 );
629 p.drawLine( 0, 4, 0, 0 );
630 p.drawLine( pix.width() - 1 - 0, 4, pix.width() - 1 - 0, 0 );
632 p.drawLine( 3, 1, pix.width() - 1 - 3, 1 );
633 p.drawLine( 1, 3, pix.width() - 1 - 1, 3 );
634 p.drawLine( 3, 1, 3, 0 );
635 p.drawLine( 1, 3, 1, 0 );
636 p.drawLine( pix.width() - 1 - 3, 1, pix.width() - 1 - 3, 0 );
637 p.drawLine( pix.width() - 1 - 1, 3, pix.width() - 1 - 1, 0 );
639 p.drawLine( 2, 2, pix.width() - 1 - 2, 2 );
640 p.drawLine( 2, 0, 2, 2 );
641 p.drawLine( pix.width() - 1 - 2, 0, pix.width() - 1 - 2, 2 );
643 XSetWindowBackgroundPixmap( tqt_xdisplay(), outline_bottom, pix.handle());
645 XClearWindow( tqt_xdisplay(), outline_left );
646 XClearWindow( tqt_xdisplay(), outline_right );
647 XClearWindow( tqt_xdisplay(), outline_top );
648 XClearWindow( tqt_xdisplay(), outline_bottom );
649 XMapWindow( tqt_xdisplay(), outline_left );
650 XMapWindow( tqt_xdisplay(), outline_right );
651 XMapWindow( tqt_xdisplay(), outline_top );
652 XMapWindow( tqt_xdisplay(), outline_bottom );
657 delayedShowTimer.stop();
659 TQApplication::syncX();
661 while (XCheckTypedEvent (tqt_xdisplay(), EnterNotify, &otherEvent ) )
667 void TabBox::reconfigure()
669 TDEConfig * c(TDEGlobal::config());
670 c->setGroup(
"TabBox");
671 options_traverse_all = c->readBoolEntry(
"TraverseAll",
false );
692 void TabBox::delayedShow()
694 TDEConfig * c(TDEGlobal::config());
695 c->setGroup(
"TabBox");
696 bool delay = c->readBoolEntry(
"ShowDelay",
true);
704 int delayTime = c->readNumEntry(
"DelayTime", 90);
705 delayedShowTimer.start(delayTime,
true);
709 void TabBox::handleMouseEvent( XEvent* e )
711 XAllowEvents( tqt_xdisplay(), AsyncPointer, get_tqt_x_time() );
712 if( e->type != ButtonPress )
714 TQPoint pos( e->xbutton.x_root, e->xbutton.y_root );
715 if( !geometry().contains( pos ))
717 workspace()->closeTabBox();
722 int num = (pos.y()-frameWidth()) / lineHeight;
724 if( mode() == WindowsMode )
726 for( ClientList::ConstIterator it = clients.begin();
730 if( workspace()->hasClient( *it ) && (num == 0) )
732 setCurrentClient( *it );
740 int iDesktop = (mode() == DesktopMode) ? workspace()->currentDesktop() : 1;
742 i <= workspace()->numberOfDesktops();
751 if( mode() == DesktopMode )
752 iDesktop = workspace()->nextDesktopFocusChain( iDesktop );
770 bool areKeySymXsDepressed(
bool bAll,
const uint keySyms[],
int nKeySyms )
774 kdDebug(125) <<
"areKeySymXsDepressed: " << (bAll ?
"all of " :
"any of ") << nKeySyms << endl;
776 XQueryKeymap( tqt_xdisplay(), keymap );
778 for(
int iKeySym = 0; iKeySym < nKeySyms; iKeySym++ )
780 uint keySymX = keySyms[ iKeySym ];
781 uchar keyCodeX = XKeysymToKeycode( tqt_xdisplay(), keySymX );
782 int i = keyCodeX / 8;
783 char mask = 1 << (keyCodeX - (i * 8));
785 kdDebug(125) << iKeySym <<
": keySymX=0x" << TQString::number( keySymX, 16 )
786 <<
" i=" << i <<
" mask=0x" << TQString::number( mask, 16 )
787 <<
" keymap[i]=0x" << TQString::number( keymap[i], 16 ) << endl;
790 if( i < 0 || i >= 32 )
796 if( (keymap[i] & mask) == 0 )
802 if( keymap[i] & mask )
812 static bool areModKeysDepressed(
const KKeySequence& seq )
818 int mod = seq.key(seq.count()-1).modFlags();
820 if ( mod & KKey::SHIFT )
822 rgKeySyms[nKeySyms++] = XK_Shift_L;
823 rgKeySyms[nKeySyms++] = XK_Shift_R;
825 if ( mod & KKey::CTRL )
827 rgKeySyms[nKeySyms++] = XK_Control_L;
828 rgKeySyms[nKeySyms++] = XK_Control_R;
830 if( mod & KKey::ALT )
832 rgKeySyms[nKeySyms++] = XK_Alt_L;
833 rgKeySyms[nKeySyms++] = XK_Alt_R;
835 if( mod & KKey::WIN )
840 rgKeySyms[nKeySyms++] = XK_Super_L;
841 rgKeySyms[nKeySyms++] = XK_Super_R;
842 rgKeySyms[nKeySyms++] = XK_Meta_L;
843 rgKeySyms[nKeySyms++] = XK_Meta_R;
846 return areKeySymXsDepressed(
false, rgKeySyms, nKeySyms );
849 static bool areModKeysDepressed(
const TDEShortcut& cut )
851 for(
unsigned int i = 0;
855 if( areModKeysDepressed( cut.seq( i )))
861 void Workspace::slotWalkThroughWindows()
863 if ( root != tqt_xrootwin() )
865 if ( tab_grab || control_grab )
867 if ( options->altTabStyle == Options::CDE || !options->focusPolicyIsReasonable())
871 CDEWalkThroughWindows(
true );
875 if ( areModKeysDepressed( cutWalkThroughWindows ) )
877 if ( startKDEWalkThroughWindows() )
878 KDEWalkThroughWindows(
true );
883 KDEOneStepThroughWindows(
true );
887 void Workspace::slotWalkBackThroughWindows()
889 if ( root != tqt_xrootwin() )
891 if( tab_grab || control_grab )
893 if ( options->altTabStyle == Options::CDE || !options->focusPolicyIsReasonable())
896 CDEWalkThroughWindows(
false );
900 if ( areModKeysDepressed( cutWalkThroughWindowsReverse ) )
902 if ( startKDEWalkThroughWindows() )
903 KDEWalkThroughWindows(
false );
907 KDEOneStepThroughWindows(
false );
912 void Workspace::slotWalkThroughApps()
914 tab_box->setAppsOnly(
true);
915 slotWalkThroughWindows();
918 void Workspace::slotWalkBackThroughApps()
920 tab_box->setAppsOnly(
true);
921 slotWalkBackThroughWindows();
924 void Workspace::slotWalkThroughDesktops()
926 if ( root != tqt_xrootwin() )
928 if( tab_grab || control_grab )
930 if ( areModKeysDepressed( cutWalkThroughDesktops ) )
932 if ( startWalkThroughDesktops() )
933 walkThroughDesktops(
true );
937 oneStepThroughDesktops(
true );
941 void Workspace::slotWalkBackThroughDesktops()
943 if ( root != tqt_xrootwin() )
945 if( tab_grab || control_grab )
947 if ( areModKeysDepressed( cutWalkThroughDesktopsReverse ) )
949 if ( startWalkThroughDesktops() )
950 walkThroughDesktops(
false );
954 oneStepThroughDesktops(
false );
958 void Workspace::slotWalkThroughDesktopList()
960 if ( root != tqt_xrootwin() )
962 if( tab_grab || control_grab )
964 if ( areModKeysDepressed( cutWalkThroughDesktopList ) )
966 if ( startWalkThroughDesktopList() )
967 walkThroughDesktops(
true );
971 oneStepThroughDesktopList(
true );
975 void Workspace::slotWalkBackThroughDesktopList()
977 if ( root != tqt_xrootwin() )
979 if( tab_grab || control_grab )
981 if ( areModKeysDepressed( cutWalkThroughDesktopListReverse ) )
983 if ( startWalkThroughDesktopList() )
984 walkThroughDesktops(
false );
988 oneStepThroughDesktopList(
false );
992 bool Workspace::startKDEWalkThroughWindows()
994 if( !establishTabBoxGrab())
997 keys->suspend(
true );
998 disable_shortcuts_keys->suspend(
true );
999 client_keys->suspend(
true );
1000 tab_box->setMode( TabBox::WindowsMode );
1005 bool Workspace::startWalkThroughDesktops(
int mode )
1007 if( !establishTabBoxGrab())
1009 control_grab = TRUE;
1010 keys->suspend(
true );
1011 disable_shortcuts_keys->suspend(
true );
1012 client_keys->suspend(
true );
1013 tab_box->setMode( (TabBox::Mode) mode );
1018 bool Workspace::startWalkThroughDesktops()
1020 return startWalkThroughDesktops( TabBox::DesktopMode );
1023 bool Workspace::startWalkThroughDesktopList()
1025 return startWalkThroughDesktops( TabBox::DesktopListMode );
1028 void Workspace::KDEWalkThroughWindows(
bool forward )
1030 tab_box->nextPrev( forward );
1031 tab_box->delayedShow();
1034 void Workspace::walkThroughDesktops(
bool forward )
1036 tab_box->nextPrev( forward );
1037 tab_box->delayedShow();
1040 void Workspace::CDEWalkThroughWindows(
bool forward )
1046 Q_ASSERT( block_stacking_updates == 0 );
1047 for( ClientList::ConstIterator it = stacking_order.fromLast();
1048 it != stacking_order.end();
1051 if ( (*it)->isOnCurrentDesktop() && !(*it)->isSpecialWindow()
1052 && (*it)->isShown(
false ) && (*it)->wantsTabFocus()
1053 && !(*it)->keepAbove() && !(*it)->keepBelow())
1060 bool options_traverse_all;
1062 TDEConfigGroupSaver saver( TDEGlobal::config(),
"TabBox" );
1063 options_traverse_all = TDEGlobal::config()->readBoolEntry(
"TraverseAll",
false );
1066 Client* firstClient = 0;
1069 nc = forward ? nextStaticClient(nc) : previousStaticClient(nc);
1076 else if (nc == firstClient)
1082 }
while (nc && nc != c &&
1083 (( !options_traverse_all && !nc->isOnDesktop(currentDesktop())) ||
1084 nc->isMinimized() || !nc->wantsTabFocus() || nc->keepAbove() || nc->keepBelow() ) );
1089 if ( options->focusPolicyIsReasonable() )
1091 activateClient( nc );
1092 if( nc->isShade() && options->shadeHover )
1093 nc->setShade( ShadeActivated );
1097 if( !nc->isOnDesktop( currentDesktop()))
1098 setCurrentDesktop( nc->desktop());
1104 void Workspace::KDEOneStepThroughWindows(
bool forward )
1106 tab_box->setMode( TabBox::WindowsMode );
1108 tab_box->nextPrev( forward );
1109 if( Client* c = tab_box->currentClient() )
1111 activateClient( c );
1112 if( c->isShade() && options->shadeHover )
1113 c->setShade( ShadeActivated );
1117 void Workspace::oneStepThroughDesktops(
bool forward,
int mode )
1119 tab_box->setMode( (TabBox::Mode) mode );
1121 tab_box->nextPrev( forward );
1122 if ( tab_box->currentDesktop() != -1 )
1123 setCurrentDesktop( tab_box->currentDesktop() );
1126 void Workspace::oneStepThroughDesktops(
bool forward )
1128 oneStepThroughDesktops( forward, TabBox::DesktopMode );
1131 void Workspace::oneStepThroughDesktopList(
bool forward )
1133 oneStepThroughDesktops( forward, TabBox::DesktopListMode );
1139 void Workspace::tabBoxKeyPress(
const KKeyNative& keyX )
1141 bool forward =
false;
1142 bool backward =
false;
1143 bool forwardapps =
false;
1144 bool backwardapps =
false;
1148 forward = cutWalkThroughWindows.contains( keyX );
1149 backward = cutWalkThroughWindowsReverse.contains( keyX );
1151 forwardapps = cutWalkThroughApps.contains( keyX );
1152 backwardapps = cutWalkThroughAppsReverse.contains( keyX );
1154 if ( (forward || backward) && (!tab_box->isAppsOnly()) )
1156 kdDebug(125) <<
"== " << cutWalkThroughWindows.toStringInternal()
1157 <<
" or " << cutWalkThroughWindowsReverse.toStringInternal() << endl;
1159 KDEWalkThroughWindows( forward );
1162 if ( (forwardapps || backwardapps) && (tab_box->isAppsOnly()) )
1164 kdDebug(125) <<
"== " << cutWalkThroughWindows.toStringInternal()
1165 <<
" or " << cutWalkThroughWindowsReverse.toStringInternal() << endl;
1166 KDEWalkThroughWindows( forwardapps );
1170 else if (control_grab)
1172 forward = cutWalkThroughDesktops.contains( keyX ) ||
1173 cutWalkThroughDesktopList.contains( keyX );
1174 backward = cutWalkThroughDesktopsReverse.contains( keyX ) ||
1175 cutWalkThroughDesktopListReverse.contains( keyX );
1176 if (forward || backward)
1177 walkThroughDesktops(forward);
1180 if (control_grab || tab_grab)
1182 uint keyQt = keyX.keyCodeQt();
1183 if ( ((keyQt & 0xffff) == TQt::Key_Escape)
1184 && !(forward || backward) )
1191 void Workspace::closeTabBox()
1195 keys->suspend(
false );
1196 disable_shortcuts_keys->suspend(
false );
1197 client_keys->suspend(
false );
1199 control_grab = FALSE;
1205 void Workspace::tabBoxKeyRelease(
const XKeyEvent& ev )
1207 unsigned int mk = ev.state &
1208 (KKeyNative::modX(KKey::SHIFT) |
1209 KKeyNative::modX(KKey::CTRL) |
1210 KKeyNative::modX(KKey::ALT) |
1211 KKeyNative::modX(KKey::WIN));
1217 for(
int i = ShiftMapIndex;
1220 if(( mk & ( 1 << i )) != 0 )
1222 if( mod_index >= 0 )
1226 bool release =
false;
1227 if( mod_index == -1 )
1231 XModifierKeymap* xmk = XGetModifierMapping(tqt_xdisplay());
1232 for (
int i=0; i<xmk->max_keypermod; i++)
1233 if (xmk->modifiermap[xmk->max_keypermod * mod_index + i]
1236 XFreeModifiermap(xmk);
1244 keys->suspend(
false );
1245 disable_shortcuts_keys->suspend(
false );
1246 client_keys->suspend(
false );
1248 if( Client* c = tab_box->currentClient())
1250 activateClient( c );
1251 if( c->isShade() && options->shadeHover )
1252 c->setShade( ShadeActivated );
1259 keys->suspend(
false );
1260 disable_shortcuts_keys->suspend(
false );
1261 client_keys->suspend(
false );
1262 control_grab = False;
1263 if ( tab_box->currentDesktop() != -1 )
1265 setCurrentDesktop( tab_box->currentDesktop() );
1271 int Workspace::nextDesktopFocusChain(
int iDesktop )
const
1273 int i = desktop_focus_chain.find( iDesktop );
1274 if( i >= 0 && i+1 < (
int)desktop_focus_chain.size() )
1275 return desktop_focus_chain[i+1];
1276 else if( desktop_focus_chain.size() > 0 )
1277 return desktop_focus_chain[ 0 ];
1282 int Workspace::previousDesktopFocusChain(
int iDesktop )
const
1284 int i = desktop_focus_chain.find( iDesktop );
1286 return desktop_focus_chain[i-1];
1287 else if( desktop_focus_chain.size() > 0 )
1288 return desktop_focus_chain[desktop_focus_chain.size()-1];
1290 return numberOfDesktops();
1297 Client* Workspace::nextFocusChainClient( Client* c )
const
1299 if ( global_focus_chain.isEmpty() )
1301 ClientList::ConstIterator it = global_focus_chain.find( c );
1302 if ( it == global_focus_chain.end() )
1303 return global_focus_chain.last();
1304 if ( it == global_focus_chain.begin() )
1305 return global_focus_chain.last();
1314 Client* Workspace::previousFocusChainClient( Client* c )
const
1316 if ( global_focus_chain.isEmpty() )
1318 ClientList::ConstIterator it = global_focus_chain.find( c );
1319 if ( it == global_focus_chain.end() )
1320 return global_focus_chain.first();
1322 if ( it == global_focus_chain.end() )
1323 return global_focus_chain.first();
1331 Client* Workspace::nextStaticClient( Client* c )
const
1333 if ( !c || clients.isEmpty() )
1335 ClientList::ConstIterator it = clients.find( c );
1336 if ( it == clients.end() )
1337 return clients.first();
1339 if ( it == clients.end() )
1340 return clients.first();
1347 Client* Workspace::previousStaticClient( Client* c )
const
1349 if ( !c || clients.isEmpty() )
1351 ClientList::ConstIterator it = clients.find( c );
1352 if ( it == clients.end() )
1353 return clients.last();
1354 if ( it == clients.begin() )
1355 return clients.last();
1360 bool Workspace::establishTabBoxGrab()
1362 if( XGrabKeyboard( tqt_xdisplay(), root, FALSE,
1363 GrabModeAsync, GrabModeAsync, get_tqt_x_time()) != GrabSuccess )
1370 assert( !forced_global_mouse_grab );
1371 forced_global_mouse_grab =
true;
1372 if( active_client != NULL )
1373 active_client->updateMouseGrab();
1377 void Workspace::removeTabBoxGrab()
1379 XUngrabKeyboard(tqt_xdisplay(), get_tqt_x_time());
1380 assert( forced_global_mouse_grab );
1381 forced_global_mouse_grab =
false;
1382 if( active_client != NULL )
1383 active_client->updateMouseGrab();
1388 #include "tabbox.moc"