14 #include "workspace.h"
16 #include <tqpainter.h>
18 #include <tqdrawutil.h>
20 #include <tdeglobal.h>
22 #include <tdeconfig.h>
23 #include <tdelocale.h>
24 #include <tqapplication.h>
25 #include <tqdesktopwidget.h>
26 #include <kstringhandler.h>
29 #include <kglobalaccel.h>
30 #include <kkeynative.h>
31 #include <tdeglobalsettings.h>
32 #include <kiconeffect.h>
33 #include <X11/keysym.h>
34 #include <X11/keysymdef.h>
38 namespace KWinInternal
41 extern TQPixmap* twin_get_menu_pix_hack();
43 TabBox::TabBox( Workspace *ws,
const char *name )
44 : TQFrame( 0, name, TQt::WNoAutoErase ), current_client( NULL ), wspace(ws)
46 setFrameStyle(TQFrame::StyledPanel | TQFrame::Plain);
53 no_tasks = i18n(
"*** No Windows ***");
57 connect(&delayedShowTimer, TQT_SIGNAL(timeout()),
this, TQT_SLOT(show()));
59 XSetWindowAttributes attr;
60 attr.override_redirect = 1;
61 outline_left = XCreateWindow( tqt_xdisplay(), tqt_xrootwin(), 0, 0, 1, 1, 0,
62 CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attr );
63 outline_right = XCreateWindow( tqt_xdisplay(), tqt_xrootwin(), 0, 0, 1, 1, 0,
64 CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attr );
65 outline_top = XCreateWindow( tqt_xdisplay(), tqt_xrootwin(), 0, 0, 1, 1, 0,
66 CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attr );
67 outline_bottom = XCreateWindow( tqt_xdisplay(), tqt_xrootwin(), 0, 0, 1, 1, 0,
68 CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attr );
73 XDestroyWindow( tqt_xdisplay(), outline_left );
74 XDestroyWindow( tqt_xdisplay(), outline_right );
75 XDestroyWindow( tqt_xdisplay(), outline_top );
76 XDestroyWindow( tqt_xdisplay(), outline_bottom );
85 void TabBox::setMode( Mode mode )
94 void TabBox::setAppsOnly(
bool a )
102 void TabBox::createClientList(ClientList &list,
int desktop , Client *c,
bool chain)
104 ClientList::size_type idx = 0;
111 startClass = start->resourceClass();
114 c = workspace()->nextFocusChainClient(c);
116 c = workspace()->stackingOrder().first();
123 if ( ((desktop == -1) || c->isOnDesktop(desktop))
124 && c->wantsTabFocus() )
126 Client* modal = c->findModal();
127 if( modal == NULL || modal == c )
129 else if( !list.contains( modal ))
136 if(appsOnly && (TQString::compare( startClass, c->resourceClass()) != 0))
141 if( options->separateScreenFocus && options->xineramaEnabled )
143 if( c->screen() != workspace()->activeScreen())
159 c = workspace()->nextFocusChainClient( c );
162 if ( idx >= (workspace()->stackingOrder().size()-1) )
165 c = workspace()->stackingOrder()[++idx];
180 int w, h, cw = 0, wmax = 0;
182 TQRect r = workspace()->screenGeometry( workspace()->activeScreen());
186 lineHeight = TQMAX(fontMetrics().height() + 2, 32 + 4);
188 if ( mode() == WindowsMode )
190 setCurrentClient( workspace()->activeClient());
193 createClientList(clients, options_traverse_all ? -1 : workspace()->currentDesktop(), current_client,
true);
196 cw = fontMetrics().width(no_tasks)+20;
197 for (ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it)
199 cw = fontMetrics().width( (*it)->caption() );
200 if ( cw > wmax ) wmax = cw;
204 if ( clients.count() == 0 )
208 f.setPointSize( 14 );
210 h = TQFontMetrics(f).height()*4;
214 showMiniIcon =
false;
215 h = clients.count() * lineHeight;
217 if ( h > (r.height()-(2*frameWidth())) )
221 lineHeight = TQMAX(fontMetrics().height() + 2, 16 + 2);
223 h = clients.count() * lineHeight;
225 if ( h > (r.height()-(2*frameWidth())) )
228 int howMany = (h - (r.height()-(2*frameWidth())))/lineHeight;
229 for (; howMany; howMany--)
230 clients.remove(clients.last());
232 h = clients.count() * lineHeight;
239 showMiniIcon =
false;
240 desk = workspace()->currentDesktop();
242 for (
int i = 1; i <= workspace()->numberOfDesktops(); i++ )
244 cw = fontMetrics().width( workspace()->desktopName(i) );
245 if ( cw > wmax ) wmax = cw;
249 h = workspace()->numberOfDesktops() * lineHeight;
253 h += 2 * frameWidth();
254 w = 2*frameWidth() + 5*2 + ( showMiniIcon ? 16 : 32 ) + 8 + wmax;
255 w = kClamp( w, r.width()/3 , r.width() * 4 / 5 );
257 setGeometry( (r.width()-w)/2 + r.x(),
258 (r.height()-h)/2+ r.y(),
266 void TabBox::nextPrev(
bool next)
268 if ( mode() == WindowsMode )
270 Client* firstClient = NULL;
271 Client* client = current_client;
275 client = workspace()->nextFocusChainClient(client);
277 client = workspace()->previousFocusChainClient(client);
282 firstClient = client;
284 else if (client == firstClient)
290 }
while ( client && !clients.contains( client ));
291 setCurrentClient( client );
293 else if( mode() == DesktopMode )
296 desk = workspace()->nextDesktopFocusChain( desk );
298 desk = workspace()->previousDesktopFocusChain( desk );
305 if ( desk > workspace()->numberOfDesktops() )
312 desk = workspace()->numberOfDesktops();
325 Client* TabBox::currentClient()
327 if ( mode() != WindowsMode )
329 if (!workspace()->hasClient( current_client ))
331 return current_client;
334 void TabBox::setCurrentClient( Client* c )
336 if( current_client != c )
348 int TabBox::currentDesktop()
350 if ( mode() == DesktopListMode || mode() == DesktopMode )
360 void TabBox::showEvent( TQShowEvent* )
363 XRaiseWindow( tqt_xdisplay(), outline_left );
364 XRaiseWindow( tqt_xdisplay(), outline_right );
365 XRaiseWindow( tqt_xdisplay(), outline_top );
366 XRaiseWindow( tqt_xdisplay(), outline_bottom );
374 void TabBox::hideEvent( TQHideEvent* )
376 XUnmapWindow( tqt_xdisplay(), outline_left );
377 XUnmapWindow( tqt_xdisplay(), outline_right );
378 XUnmapWindow( tqt_xdisplay(), outline_top );
379 XUnmapWindow( tqt_xdisplay(), outline_bottom );
385 void TabBox::drawContents( TQPainter * )
387 TQRect r(contentsRect());
388 TQPixmap pix(r.size());
389 pix.fill(
this, 0, 0);
394 TQPixmap* menu_pix = twin_get_menu_pix_hack();
396 int iconWidth = showMiniIcon ? 16 : 32;
400 if ( mode () == WindowsMode )
402 if ( !currentClient() )
406 f.setPointSize( 14 );
409 p.drawText( r, AlignCenter, no_tasks);
413 for (ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it)
415 if ( workspace()->hasClient( *it ) )
418 if ( (*it) == current_client )
419 p.fillRect(x, y, r.width(), lineHeight, colorGroup().highlight());
425 if ( !(*it)->miniIcon().isNull() )
426 icon = (*it)->miniIcon();
429 if ( !(*it)->icon().isNull() )
430 icon = (*it)->icon();
436 if( (*it)->isMinimized())
437 TDEIconEffect::semiTransparent( icon );
438 p.drawPixmap( x+5, y + (lineHeight - iconWidth)/2, icon );
444 if ( !(*it)->isOnDesktop(workspace()->currentDesktop()) )
445 s = workspace()->desktopName((*it)->desktop()) +
": ";
447 if ( (*it)->isMinimized() )
448 s += TQString(
"(") + (*it)->caption() +
")";
450 s += (*it)->caption();
452 s = KStringHandler::cPixelSqueeze(s, fontMetrics(), r.width() - 5 - iconWidth - 8);
455 if ( (*it) == current_client )
456 p.setPen(colorGroup().highlightedText());
457 else if( (*it)->isMinimized())
459 TQColor c1 = colorGroup().text();
460 TQColor c2 = colorGroup().background();
465 c1.rgb( &r1, &g1, &b1 );
466 c2.rgb( &r2, &g2, &b2 );
468 r1 += (int) ( .5 * ( r2 - r1 ) );
469 g1 += (int) ( .5 * ( g2 - g1 ) );
470 b1 += (int) ( .5 * ( b2 - b1 ) );
472 p.setPen(TQColor( r1, g1, b1 ));
475 p.setPen(colorGroup().text());
477 p.drawText(x+5 + iconWidth + 8, y, r.width() - 5 - iconWidth - 8, lineHeight,
478 Qt::AlignLeft | Qt::AlignVCenter | TQt::SingleLine, s);
482 if ( y >= r.height() )
break;
488 int iconHeight = iconWidth;
493 f.setPixelSize(iconHeight - 4);
497 for (
int i = 1; i <= workspace()->numberOfDesktops(); i++ )
499 wmax = TQMAX(wmax, fontMetrics().width(workspace()->desktopName(i)));
502 TQString num = TQString::number(i);
503 iconWidth = TQMAX(iconWidth - 4, fm.boundingRect(num).width()) + 4;
508 int iDesktop = (mode() == DesktopMode) ? workspace()->currentDesktop() : 1;
509 for (
int i = 1; i <= workspace()->numberOfDesktops(); i++ )
512 if ( iDesktop == desk )
513 p.fillRect(x, y, r.width(), lineHeight, colorGroup().highlight());
518 p.fillRect(x+5, y+2, iconWidth, iconHeight, colorGroup().base());
519 p.setPen(colorGroup().text());
520 p.drawRect(x+5, y+2, iconWidth, iconHeight);
524 TQString num = TQString::number(iDesktop);
525 p.drawText(x+5, y+2, iconWidth, iconHeight, Qt::AlignCenter, num);
530 if ( iDesktop == desk )
531 p.setPen(colorGroup().highlightedText());
533 p.setPen(colorGroup().text());
535 p.drawText(x+5 + iconWidth + 8, y, r.width() - 5 - iconWidth - 8, lineHeight,
536 Qt::AlignLeft | Qt::AlignVCenter | TQt::SingleLine,
537 workspace()->desktopName(iDesktop));
540 int x1 = x + 5 + iconWidth + 8 + wmax + 5;
543 createClientList(list, iDesktop, 0,
false);
545 for (ClientList::ConstIterator it = list.fromLast(); it != list.end(); --it)
547 if ( !(*it)->miniIcon().isNull() )
549 if ( x1+18 >= x+r.width() )
552 p.drawPixmap( x1, y + (lineHeight - 16)/2, (*it)->miniIcon() );
559 if ( y >= r.height() )
break;
561 if( mode() == DesktopMode )
562 iDesktop = workspace()->nextDesktopFocusChain( iDesktop );
568 bitBlt(
this, r.x(), r.y(), &pix);
571 void TabBox::updateOutline()
573 Client* c = currentClient();
574 if( !options->tabboxOutline || c == NULL || this->isHidden() || !c->isShown(
true ) || !c->isOnCurrentDesktop())
576 XUnmapWindow( tqt_xdisplay(), outline_left );
577 XUnmapWindow( tqt_xdisplay(), outline_right );
578 XUnmapWindow( tqt_xdisplay(), outline_top );
579 XUnmapWindow( tqt_xdisplay(), outline_bottom );
583 XMoveResizeWindow( tqt_xdisplay(), outline_left, c->x(), c->y() + 5, 5, c->height() - 10 );
584 XMoveResizeWindow( tqt_xdisplay(), outline_right, c->x() + c->width() - 5, c->y() + 5, 5, c->height() - 10 );
585 XMoveResizeWindow( tqt_xdisplay(), outline_top, c->x(), c->y(), c->width(), 5 );
586 XMoveResizeWindow( tqt_xdisplay(), outline_bottom, c->x(), c->y() + c->height() - 5, c->width(), 5 );
588 TQPixmap pix( 5, c->height() - 10 );
591 p.drawLine( 0, 0, 0, pix.height() - 1 );
592 p.drawLine( 4, 0, 4, pix.height() - 1 );
594 p.drawLine( 1, 0, 1, pix.height() - 1 );
595 p.drawLine( 3, 0, 3, pix.height() - 1 );
597 p.drawLine( 2, 0, 2, pix.height() - 1 );
599 XSetWindowBackgroundPixmap( tqt_xdisplay(), outline_left, pix.handle());
600 XSetWindowBackgroundPixmap( tqt_xdisplay(), outline_right, pix.handle());
603 TQPixmap pix( c->width(), 5 );
606 p.drawLine( 0, 0, pix.width() - 1 - 0, 0 );
607 p.drawLine( 4, 4, pix.width() - 1 - 4, 4 );
608 p.drawLine( 0, 0, 0, 4 );
609 p.drawLine( pix.width() - 1 - 0, 0, pix.width() - 1 - 0, 4 );
611 p.drawLine( 1, 1, pix.width() - 1 - 1, 1 );
612 p.drawLine( 3, 3, pix.width() - 1 - 3, 3 );
613 p.drawLine( 1, 1, 1, 4 );
614 p.drawLine( 3, 3, 3, 4 );
615 p.drawLine( pix.width() - 1 - 1, 1, pix.width() - 1 - 1, 4 );
616 p.drawLine( pix.width() - 1 - 3, 3, pix.width() - 1 - 3, 4 );
618 p.drawLine( 2, 2, pix.width() - 1 - 2, 2 );
619 p.drawLine( 2, 2, 2, 4 );
620 p.drawLine( pix.width() - 1 - 2, 2, pix.width() - 1 - 2, 4 );
622 XSetWindowBackgroundPixmap( tqt_xdisplay(), outline_top, pix.handle());
625 TQPixmap pix( c->width(), 5 );
628 p.drawLine( 4, 0, pix.width() - 1 - 4, 0 );
629 p.drawLine( 0, 4, pix.width() - 1 - 0, 4 );
630 p.drawLine( 0, 4, 0, 0 );
631 p.drawLine( pix.width() - 1 - 0, 4, pix.width() - 1 - 0, 0 );
633 p.drawLine( 3, 1, pix.width() - 1 - 3, 1 );
634 p.drawLine( 1, 3, pix.width() - 1 - 1, 3 );
635 p.drawLine( 3, 1, 3, 0 );
636 p.drawLine( 1, 3, 1, 0 );
637 p.drawLine( pix.width() - 1 - 3, 1, pix.width() - 1 - 3, 0 );
638 p.drawLine( pix.width() - 1 - 1, 3, pix.width() - 1 - 1, 0 );
640 p.drawLine( 2, 2, pix.width() - 1 - 2, 2 );
641 p.drawLine( 2, 0, 2, 2 );
642 p.drawLine( pix.width() - 1 - 2, 0, pix.width() - 1 - 2, 2 );
644 XSetWindowBackgroundPixmap( tqt_xdisplay(), outline_bottom, pix.handle());
646 XClearWindow( tqt_xdisplay(), outline_left );
647 XClearWindow( tqt_xdisplay(), outline_right );
648 XClearWindow( tqt_xdisplay(), outline_top );
649 XClearWindow( tqt_xdisplay(), outline_bottom );
650 XMapWindow( tqt_xdisplay(), outline_left );
651 XMapWindow( tqt_xdisplay(), outline_right );
652 XMapWindow( tqt_xdisplay(), outline_top );
653 XMapWindow( tqt_xdisplay(), outline_bottom );
658 delayedShowTimer.stop();
660 TQApplication::syncX();
662 while (XCheckTypedEvent (tqt_xdisplay(), EnterNotify, &otherEvent ) )
668 void TabBox::reconfigure()
670 TDEConfig * c(TDEGlobal::config());
671 c->setGroup(
"TabBox");
672 options_traverse_all = c->readBoolEntry(
"TraverseAll",
false );
693 void TabBox::delayedShow()
695 TDEConfig * c(TDEGlobal::config());
696 c->setGroup(
"TabBox");
697 bool delay = c->readBoolEntry(
"ShowDelay",
true);
705 int delayTime = c->readNumEntry(
"DelayTime", 90);
706 delayedShowTimer.start(delayTime,
true);
710 void TabBox::handleMouseEvent( XEvent* e )
712 XAllowEvents( tqt_xdisplay(), AsyncPointer, GET_QT_X_TIME() );
713 if( e->type != ButtonPress )
715 TQPoint pos( e->xbutton.x_root, e->xbutton.y_root );
716 if( !geometry().contains( pos ))
718 workspace()->closeTabBox();
723 int num = (pos.y()-frameWidth()) / lineHeight;
725 if( mode() == WindowsMode )
727 for( ClientList::ConstIterator it = clients.begin();
731 if( workspace()->hasClient( *it ) && (num == 0) )
733 setCurrentClient( *it );
741 int iDesktop = (mode() == DesktopMode) ? workspace()->currentDesktop() : 1;
743 i <= workspace()->numberOfDesktops();
752 if( mode() == DesktopMode )
753 iDesktop = workspace()->nextDesktopFocusChain( iDesktop );
771 bool areKeySymXsDepressed(
bool bAll,
const uint keySyms[],
int nKeySyms )
775 kdDebug(125) <<
"areKeySymXsDepressed: " << (bAll ?
"all of " :
"any of ") << nKeySyms << endl;
777 XQueryKeymap( tqt_xdisplay(), keymap );
779 for(
int iKeySym = 0; iKeySym < nKeySyms; iKeySym++ )
781 uint keySymX = keySyms[ iKeySym ];
782 uchar keyCodeX = XKeysymToKeycode( tqt_xdisplay(), keySymX );
783 int i = keyCodeX / 8;
784 char mask = 1 << (keyCodeX - (i * 8));
786 kdDebug(125) << iKeySym <<
": keySymX=0x" << TQString::number( keySymX, 16 )
787 <<
" i=" << i <<
" mask=0x" << TQString::number( mask, 16 )
788 <<
" keymap[i]=0x" << TQString::number( keymap[i], 16 ) << endl;
791 if( i < 0 || i >= 32 )
797 if( (keymap[i] & mask) == 0 )
803 if( keymap[i] & mask )
813 static bool areModKeysDepressed(
const KKeySequence& seq )
819 int mod = seq.key(seq.count()-1).modFlags();
821 if ( mod & KKey::SHIFT )
823 rgKeySyms[nKeySyms++] = XK_Shift_L;
824 rgKeySyms[nKeySyms++] = XK_Shift_R;
826 if ( mod & KKey::CTRL )
828 rgKeySyms[nKeySyms++] = XK_Control_L;
829 rgKeySyms[nKeySyms++] = XK_Control_R;
831 if( mod & KKey::ALT )
833 rgKeySyms[nKeySyms++] = XK_Alt_L;
834 rgKeySyms[nKeySyms++] = XK_Alt_R;
836 if( mod & KKey::WIN )
841 rgKeySyms[nKeySyms++] = XK_Super_L;
842 rgKeySyms[nKeySyms++] = XK_Super_R;
843 rgKeySyms[nKeySyms++] = XK_Meta_L;
844 rgKeySyms[nKeySyms++] = XK_Meta_R;
847 return areKeySymXsDepressed(
false, rgKeySyms, nKeySyms );
850 static bool areModKeysDepressed(
const TDEShortcut& cut )
852 for(
unsigned int i = 0;
856 if( areModKeysDepressed( cut.seq( i )))
862 void Workspace::slotWalkThroughWindows()
864 if ( root != tqt_xrootwin() )
866 if ( tab_grab || control_grab )
868 if ( options->altTabStyle == Options::CDE || !options->focusPolicyIsReasonable())
872 CDEWalkThroughWindows(
true );
876 if ( areModKeysDepressed( cutWalkThroughWindows ) )
878 if ( startKDEWalkThroughWindows() )
879 KDEWalkThroughWindows(
true );
884 KDEOneStepThroughWindows(
true );
888 void Workspace::slotWalkBackThroughWindows()
890 if ( root != tqt_xrootwin() )
892 if( tab_grab || control_grab )
894 if ( options->altTabStyle == Options::CDE || !options->focusPolicyIsReasonable())
897 CDEWalkThroughWindows(
false );
901 if ( areModKeysDepressed( cutWalkThroughWindowsReverse ) )
903 if ( startKDEWalkThroughWindows() )
904 KDEWalkThroughWindows(
false );
908 KDEOneStepThroughWindows(
false );
913 void Workspace::slotWalkThroughApps()
915 tab_box->setAppsOnly(
true);
916 slotWalkThroughWindows();
919 void Workspace::slotWalkBackThroughApps()
921 tab_box->setAppsOnly(
true);
922 slotWalkBackThroughWindows();
925 void Workspace::slotWalkThroughDesktops()
927 if ( root != tqt_xrootwin() )
929 if( tab_grab || control_grab )
931 if ( areModKeysDepressed( cutWalkThroughDesktops ) )
933 if ( startWalkThroughDesktops() )
934 walkThroughDesktops(
true );
938 oneStepThroughDesktops(
true );
942 void Workspace::slotWalkBackThroughDesktops()
944 if ( root != tqt_xrootwin() )
946 if( tab_grab || control_grab )
948 if ( areModKeysDepressed( cutWalkThroughDesktopsReverse ) )
950 if ( startWalkThroughDesktops() )
951 walkThroughDesktops(
false );
955 oneStepThroughDesktops(
false );
959 void Workspace::slotWalkThroughDesktopList()
961 if ( root != tqt_xrootwin() )
963 if( tab_grab || control_grab )
965 if ( areModKeysDepressed( cutWalkThroughDesktopList ) )
967 if ( startWalkThroughDesktopList() )
968 walkThroughDesktops(
true );
972 oneStepThroughDesktopList(
true );
976 void Workspace::slotWalkBackThroughDesktopList()
978 if ( root != tqt_xrootwin() )
980 if( tab_grab || control_grab )
982 if ( areModKeysDepressed( cutWalkThroughDesktopListReverse ) )
984 if ( startWalkThroughDesktopList() )
985 walkThroughDesktops(
false );
989 oneStepThroughDesktopList(
false );
993 bool Workspace::startKDEWalkThroughWindows()
995 if( !establishTabBoxGrab())
998 keys->suspend(
true );
999 disable_shortcuts_keys->suspend(
true );
1000 client_keys->suspend(
true );
1001 tab_box->setMode( TabBox::WindowsMode );
1006 bool Workspace::startWalkThroughDesktops(
int mode )
1008 if( !establishTabBoxGrab())
1010 control_grab = TRUE;
1011 keys->suspend(
true );
1012 disable_shortcuts_keys->suspend(
true );
1013 client_keys->suspend(
true );
1014 tab_box->setMode( (TabBox::Mode) mode );
1019 bool Workspace::startWalkThroughDesktops()
1021 return startWalkThroughDesktops( TabBox::DesktopMode );
1024 bool Workspace::startWalkThroughDesktopList()
1026 return startWalkThroughDesktops( TabBox::DesktopListMode );
1029 void Workspace::KDEWalkThroughWindows(
bool forward )
1031 tab_box->nextPrev( forward );
1032 tab_box->delayedShow();
1035 void Workspace::walkThroughDesktops(
bool forward )
1037 tab_box->nextPrev( forward );
1038 tab_box->delayedShow();
1041 void Workspace::CDEWalkThroughWindows(
bool forward )
1047 Q_ASSERT( block_stacking_updates == 0 );
1048 for( ClientList::ConstIterator it = stacking_order.fromLast();
1049 it != stacking_order.end();
1052 if ( (*it)->isOnCurrentDesktop() && !(*it)->isSpecialWindow()
1053 && (*it)->isShown(
false ) && (*it)->wantsTabFocus()
1054 && !(*it)->keepAbove() && !(*it)->keepBelow())
1061 bool options_traverse_all;
1063 TDEConfigGroupSaver saver( TDEGlobal::config(),
"TabBox" );
1064 options_traverse_all = TDEGlobal::config()->readBoolEntry(
"TraverseAll",
false );
1067 Client* firstClient = 0;
1070 nc = forward ? nextStaticClient(nc) : previousStaticClient(nc);
1077 else if (nc == firstClient)
1083 }
while (nc && nc != c &&
1084 (( !options_traverse_all && !nc->isOnDesktop(currentDesktop())) ||
1085 nc->isMinimized() || !nc->wantsTabFocus() || nc->keepAbove() || nc->keepBelow() ) );
1090 if ( options->focusPolicyIsReasonable() )
1092 activateClient( nc );
1093 if( nc->isShade() && options->shadeHover )
1094 nc->setShade( ShadeActivated );
1098 if( !nc->isOnDesktop( currentDesktop()))
1099 setCurrentDesktop( nc->desktop());
1105 void Workspace::KDEOneStepThroughWindows(
bool forward )
1107 tab_box->setMode( TabBox::WindowsMode );
1109 tab_box->nextPrev( forward );
1110 if( Client* c = tab_box->currentClient() )
1112 activateClient( c );
1113 if( c->isShade() && options->shadeHover )
1114 c->setShade( ShadeActivated );
1118 void Workspace::oneStepThroughDesktops(
bool forward,
int mode )
1120 tab_box->setMode( (TabBox::Mode) mode );
1122 tab_box->nextPrev( forward );
1123 if ( tab_box->currentDesktop() != -1 )
1124 setCurrentDesktop( tab_box->currentDesktop() );
1127 void Workspace::oneStepThroughDesktops(
bool forward )
1129 oneStepThroughDesktops( forward, TabBox::DesktopMode );
1132 void Workspace::oneStepThroughDesktopList(
bool forward )
1134 oneStepThroughDesktops( forward, TabBox::DesktopListMode );
1140 void Workspace::tabBoxKeyPress(
const KKeyNative& keyX )
1142 bool forward =
false;
1143 bool backward =
false;
1144 bool forwardapps =
false;
1145 bool backwardapps =
false;
1149 forward = cutWalkThroughWindows.contains( keyX );
1150 backward = cutWalkThroughWindowsReverse.contains( keyX );
1152 forwardapps = cutWalkThroughApps.contains( keyX );
1153 backwardapps = cutWalkThroughAppsReverse.contains( keyX );
1155 if ( (forward || backward) && (!tab_box->isAppsOnly()) )
1157 kdDebug(125) <<
"== " << cutWalkThroughWindows.toStringInternal()
1158 <<
" or " << cutWalkThroughWindowsReverse.toStringInternal() << endl;
1160 KDEWalkThroughWindows( forward );
1163 if ( (forwardapps || backwardapps) && (tab_box->isAppsOnly()) )
1165 kdDebug(125) <<
"== " << cutWalkThroughWindows.toStringInternal()
1166 <<
" or " << cutWalkThroughWindowsReverse.toStringInternal() << endl;
1167 KDEWalkThroughWindows( forwardapps );
1171 else if (control_grab)
1173 forward = cutWalkThroughDesktops.contains( keyX ) ||
1174 cutWalkThroughDesktopList.contains( keyX );
1175 backward = cutWalkThroughDesktopsReverse.contains( keyX ) ||
1176 cutWalkThroughDesktopListReverse.contains( keyX );
1177 if (forward || backward)
1178 walkThroughDesktops(forward);
1181 if (control_grab || tab_grab)
1183 uint keyQt = keyX.keyCodeQt();
1184 if ( ((keyQt & 0xffff) == Qt::Key_Escape)
1185 && !(forward || backward) )
1192 void Workspace::closeTabBox()
1196 keys->suspend(
false );
1197 disable_shortcuts_keys->suspend(
false );
1198 client_keys->suspend(
false );
1200 control_grab = FALSE;
1206 void Workspace::tabBoxKeyRelease(
const XKeyEvent& ev )
1208 unsigned int mk = ev.state &
1209 (KKeyNative::modX(KKey::SHIFT) |
1210 KKeyNative::modX(KKey::CTRL) |
1211 KKeyNative::modX(KKey::ALT) |
1212 KKeyNative::modX(KKey::WIN));
1218 for(
int i = ShiftMapIndex;
1221 if(( mk & ( 1 << i )) != 0 )
1223 if( mod_index >= 0 )
1227 bool release =
false;
1228 if( mod_index == -1 )
1232 XModifierKeymap* xmk = XGetModifierMapping(tqt_xdisplay());
1233 for (
int i=0; i<xmk->max_keypermod; i++)
1234 if (xmk->modifiermap[xmk->max_keypermod * mod_index + i]
1237 XFreeModifiermap(xmk);
1245 keys->suspend(
false );
1246 disable_shortcuts_keys->suspend(
false );
1247 client_keys->suspend(
false );
1249 if( Client* c = tab_box->currentClient())
1251 activateClient( c );
1252 if( c->isShade() && options->shadeHover )
1253 c->setShade( ShadeActivated );
1260 keys->suspend(
false );
1261 disable_shortcuts_keys->suspend(
false );
1262 client_keys->suspend(
false );
1263 control_grab = False;
1264 if ( tab_box->currentDesktop() != -1 )
1266 setCurrentDesktop( tab_box->currentDesktop() );
1272 int Workspace::nextDesktopFocusChain(
int iDesktop )
const
1274 int i = desktop_focus_chain.find( iDesktop );
1275 if( i >= 0 && i+1 < (
int)desktop_focus_chain.size() )
1276 return desktop_focus_chain[i+1];
1277 else if( desktop_focus_chain.size() > 0 )
1278 return desktop_focus_chain[ 0 ];
1283 int Workspace::previousDesktopFocusChain(
int iDesktop )
const
1285 int i = desktop_focus_chain.find( iDesktop );
1287 return desktop_focus_chain[i-1];
1288 else if( desktop_focus_chain.size() > 0 )
1289 return desktop_focus_chain[desktop_focus_chain.size()-1];
1291 return numberOfDesktops();
1298 Client* Workspace::nextFocusChainClient( Client* c )
const
1300 if ( global_focus_chain.isEmpty() )
1302 ClientList::ConstIterator it = global_focus_chain.find( c );
1303 if ( it == global_focus_chain.end() )
1304 return global_focus_chain.last();
1305 if ( it == global_focus_chain.begin() )
1306 return global_focus_chain.last();
1315 Client* Workspace::previousFocusChainClient( Client* c )
const
1317 if ( global_focus_chain.isEmpty() )
1319 ClientList::ConstIterator it = global_focus_chain.find( c );
1320 if ( it == global_focus_chain.end() )
1321 return global_focus_chain.first();
1323 if ( it == global_focus_chain.end() )
1324 return global_focus_chain.first();
1332 Client* Workspace::nextStaticClient( Client* c )
const
1334 if ( !c || clients.isEmpty() )
1336 ClientList::ConstIterator it = clients.find( c );
1337 if ( it == clients.end() )
1338 return clients.first();
1340 if ( it == clients.end() )
1341 return clients.first();
1348 Client* Workspace::previousStaticClient( Client* c )
const
1350 if ( !c || clients.isEmpty() )
1352 ClientList::ConstIterator it = clients.find( c );
1353 if ( it == clients.end() )
1354 return clients.last();
1355 if ( it == clients.begin() )
1356 return clients.last();
1361 bool Workspace::establishTabBoxGrab()
1363 if( XGrabKeyboard( tqt_xdisplay(), root, FALSE,
1364 GrabModeAsync, GrabModeAsync, GET_QT_X_TIME()) != GrabSuccess )
1371 assert( !forced_global_mouse_grab );
1372 forced_global_mouse_grab =
true;
1373 if( active_client != NULL )
1374 active_client->updateMouseGrab();
1378 void Workspace::removeTabBoxGrab()
1380 XUngrabKeyboard(tqt_xdisplay(), GET_QT_X_TIME());
1381 assert( forced_global_mouse_grab );
1382 forced_global_mouse_grab =
false;
1383 if( active_client != NULL )
1384 active_client->updateMouseGrab();
1389 #include "tabbox.moc"