14 #include "workspace.h"
16 #include <tqpainter.h>
18 #include <tqdrawutil.h>
24 #include <tqapplication.h>
25 #include <tqdesktopwidget.h>
26 #include <kstringhandler.h>
29 #include <kglobalaccel.h>
30 #include <kkeynative.h>
31 #include <kglobalsettings.h>
32 #include <kiconeffect.h>
33 #include <X11/keysym.h>
34 #include <X11/keysymdef.h>
38 namespace KWinInternal
41 extern TQPixmap* kwin_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);
52 no_tasks = i18n(
"*** No Windows ***");
56 connect(&delayedShowTimer, TQT_SIGNAL(timeout()),
this, TQT_SLOT(show()));
58 XSetWindowAttributes attr;
59 attr.override_redirect = 1;
60 outline_left = XCreateWindow( qt_xdisplay(), qt_xrootwin(), 0, 0, 1, 1, 0,
61 CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attr );
62 outline_right = XCreateWindow( qt_xdisplay(), qt_xrootwin(), 0, 0, 1, 1, 0,
63 CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attr );
64 outline_top = XCreateWindow( qt_xdisplay(), qt_xrootwin(), 0, 0, 1, 1, 0,
65 CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attr );
66 outline_bottom = XCreateWindow( qt_xdisplay(), qt_xrootwin(), 0, 0, 1, 1, 0,
67 CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attr );
72 XDestroyWindow( qt_xdisplay(), outline_left );
73 XDestroyWindow( qt_xdisplay(), outline_right );
74 XDestroyWindow( qt_xdisplay(), outline_top );
75 XDestroyWindow( qt_xdisplay(), outline_bottom );
84 void TabBox::setMode( Mode mode )
93 void TabBox::createClientList(ClientList &list,
int desktop , Client *c,
bool chain)
95 ClientList::size_type idx = 0;
102 c = workspace()->nextFocusChainClient(c);
104 c = workspace()->stackingOrder().first();
111 if ( ((desktop == -1) || c->isOnDesktop(desktop))
112 && c->wantsTabFocus() )
114 Client* modal = c->findModal();
115 if( modal == NULL || modal == c )
117 else if( !list.contains( modal ))
125 if( options->separateScreenFocus && options->xineramaEnabled )
127 if( c->screen() != workspace()->activeScreen())
143 c = workspace()->nextFocusChainClient( c );
146 if ( idx >= (workspace()->stackingOrder().size()-1) )
149 c = workspace()->stackingOrder()[++idx];
164 int w, h, cw = 0, wmax = 0;
166 TQRect r = workspace()->screenGeometry( workspace()->activeScreen());
170 lineHeight = QMAX(fontMetrics().height() + 2, 32 + 4);
172 if ( mode() == WindowsMode )
174 setCurrentClient( workspace()->activeClient());
177 createClientList(clients, options_traverse_all ? -1 : workspace()->currentDesktop(), current_client,
true);
180 cw = fontMetrics().width(no_tasks)+20;
181 for (ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it)
183 cw = fontMetrics().width( (*it)->caption() );
184 if ( cw > wmax ) wmax = cw;
188 if ( clients.count() == 0 )
192 f.setPointSize( 14 );
194 h = TQFontMetrics(f).height()*4;
198 showMiniIcon =
false;
199 h = clients.count() * lineHeight;
201 if ( h > (r.height()-(2*frameWidth())) )
205 lineHeight = QMAX(fontMetrics().height() + 2, 16 + 2);
207 h = clients.count() * lineHeight;
209 if ( h > (r.height()-(2*frameWidth())) )
212 int howMany = (h - (r.height()-(2*frameWidth())))/lineHeight;
213 for (; howMany; howMany--)
214 clients.remove(clients.last());
216 h = clients.count() * lineHeight;
223 showMiniIcon =
false;
224 desk = workspace()->currentDesktop();
226 for (
int i = 1; i <= workspace()->numberOfDesktops(); i++ )
228 cw = fontMetrics().width( workspace()->desktopName(i) );
229 if ( cw > wmax ) wmax = cw;
233 h = workspace()->numberOfDesktops() * lineHeight;
237 h += 2 * frameWidth();
238 w = 2*frameWidth() + 5*2 + ( showMiniIcon ? 16 : 32 ) + 8 + wmax;
239 w = kClamp( w, r.width()/3 , r.width() * 4 / 5 );
241 setGeometry( (r.width()-w)/2 + r.x(),
242 (r.height()-h)/2+ r.y(),
250 void TabBox::nextPrev(
bool next)
252 if ( mode() == WindowsMode )
254 Client* firstClient = NULL;
255 Client* client = current_client;
259 client = workspace()->nextFocusChainClient(client);
261 client = workspace()->previousFocusChainClient(client);
266 firstClient = client;
268 else if (client == firstClient)
274 }
while ( client && !clients.contains( client ));
275 setCurrentClient( client );
277 else if( mode() == DesktopMode )
280 desk = workspace()->nextDesktopFocusChain( desk );
282 desk = workspace()->previousDesktopFocusChain( desk );
289 if ( desk > workspace()->numberOfDesktops() )
296 desk = workspace()->numberOfDesktops();
309 Client* TabBox::currentClient()
311 if ( mode() != WindowsMode )
313 if (!workspace()->hasClient( current_client ))
315 return current_client;
318 void TabBox::setCurrentClient( Client* c )
320 if( current_client != c )
332 int TabBox::currentDesktop()
334 if ( mode() == DesktopListMode || mode() == DesktopMode )
344 void TabBox::showEvent( TQShowEvent* )
347 XRaiseWindow( qt_xdisplay(), outline_left );
348 XRaiseWindow( qt_xdisplay(), outline_right );
349 XRaiseWindow( qt_xdisplay(), outline_top );
350 XRaiseWindow( qt_xdisplay(), outline_bottom );
358 void TabBox::hideEvent( TQHideEvent* )
360 XUnmapWindow( qt_xdisplay(), outline_left );
361 XUnmapWindow( qt_xdisplay(), outline_right );
362 XUnmapWindow( qt_xdisplay(), outline_top );
363 XUnmapWindow( qt_xdisplay(), outline_bottom );
369 void TabBox::drawContents( TQPainter * )
371 TQRect r(contentsRect());
372 TQPixmap pix(r.size());
373 pix.fill(
this, 0, 0);
378 TQPixmap* menu_pix = kwin_get_menu_pix_hack();
380 int iconWidth = showMiniIcon ? 16 : 32;
384 if ( mode () == WindowsMode )
386 if ( !currentClient() )
390 f.setPointSize( 14 );
393 p.drawText( r, AlignCenter, no_tasks);
397 for (ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it)
399 if ( workspace()->hasClient( *it ) )
402 if ( (*it) == current_client )
403 p.fillRect(x, y, r.width(), lineHeight, colorGroup().highlight());
409 if ( !(*it)->miniIcon().isNull() )
410 icon = (*it)->miniIcon();
413 if ( !(*it)->icon().isNull() )
414 icon = (*it)->icon();
420 if( (*it)->isMinimized())
421 KIconEffect::semiTransparent( icon );
422 p.drawPixmap( x+5, y + (lineHeight - iconWidth)/2, icon );
428 if ( !(*it)->isOnDesktop(workspace()->currentDesktop()) )
429 s = workspace()->desktopName((*it)->desktop()) +
": ";
431 if ( (*it)->isMinimized() )
432 s += TQString(
"(") + (*it)->caption() +
")";
434 s += (*it)->caption();
436 s = KStringHandler::cPixelSqueeze(s, fontMetrics(), r.width() - 5 - iconWidth - 8);
439 if ( (*it) == current_client )
440 p.setPen(colorGroup().highlightedText());
441 else if( (*it)->isMinimized())
443 TQColor c1 = colorGroup().text();
444 TQColor c2 = colorGroup().background();
449 c1.rgb( &r1, &g1, &b1 );
450 c2.rgb( &r2, &g2, &b2 );
452 r1 += (int) ( .5 * ( r2 - r1 ) );
453 g1 += (int) ( .5 * ( g2 - g1 ) );
454 b1 += (int) ( .5 * ( b2 - b1 ) );
456 p.setPen(TQColor( r1, g1, b1 ));
459 p.setPen(colorGroup().text());
461 p.drawText(x+5 + iconWidth + 8, y, r.width() - 5 - iconWidth - 8, lineHeight,
462 Qt::AlignLeft | Qt::AlignVCenter | TQt::SingleLine, s);
466 if ( y >= r.height() )
break;
472 int iconHeight = iconWidth;
477 f.setPixelSize(iconHeight - 4);
481 for (
int i = 1; i <= workspace()->numberOfDesktops(); i++ )
483 wmax = QMAX(wmax, fontMetrics().width(workspace()->desktopName(i)));
486 TQString num = TQString::number(i);
487 iconWidth = QMAX(iconWidth - 4, fm.boundingRect(num).width()) + 4;
492 int iDesktop = (mode() == DesktopMode) ? workspace()->currentDesktop() : 1;
493 for (
int i = 1; i <= workspace()->numberOfDesktops(); i++ )
496 if ( iDesktop == desk )
497 p.fillRect(x, y, r.width(), lineHeight, colorGroup().highlight());
502 p.fillRect(x+5, y+2, iconWidth, iconHeight, colorGroup().base());
503 p.setPen(colorGroup().text());
504 p.drawRect(x+5, y+2, iconWidth, iconHeight);
508 TQString num = TQString::number(iDesktop);
509 p.drawText(x+5, y+2, iconWidth, iconHeight, Qt::AlignCenter, num);
514 if ( iDesktop == desk )
515 p.setPen(colorGroup().highlightedText());
517 p.setPen(colorGroup().text());
519 p.drawText(x+5 + iconWidth + 8, y, r.width() - 5 - iconWidth - 8, lineHeight,
520 Qt::AlignLeft | Qt::AlignVCenter | TQt::SingleLine,
521 workspace()->desktopName(iDesktop));
524 int x1 = x + 5 + iconWidth + 8 + wmax + 5;
527 createClientList(list, iDesktop, 0,
false);
529 for (ClientList::ConstIterator it = list.fromLast(); it != list.end(); --it)
531 if ( !(*it)->miniIcon().isNull() )
533 if ( x1+18 >= x+r.width() )
536 p.drawPixmap( x1, y + (lineHeight - 16)/2, (*it)->miniIcon() );
543 if ( y >= r.height() )
break;
545 if( mode() == DesktopMode )
546 iDesktop = workspace()->nextDesktopFocusChain( iDesktop );
552 bitBlt(
this, r.x(), r.y(), &pix);
555 void TabBox::updateOutline()
557 Client* c = currentClient();
558 if( !options->tabboxOutline || c == NULL || this->isHidden() || !c->isShown(
true ) || !c->isOnCurrentDesktop())
560 XUnmapWindow( qt_xdisplay(), outline_left );
561 XUnmapWindow( qt_xdisplay(), outline_right );
562 XUnmapWindow( qt_xdisplay(), outline_top );
563 XUnmapWindow( qt_xdisplay(), outline_bottom );
567 XMoveResizeWindow( qt_xdisplay(), outline_left, c->x(), c->y() + 5, 5, c->height() - 10 );
568 XMoveResizeWindow( qt_xdisplay(), outline_right, c->x() + c->width() - 5, c->y() + 5, 5, c->height() - 10 );
569 XMoveResizeWindow( qt_xdisplay(), outline_top, c->x(), c->y(), c->width(), 5 );
570 XMoveResizeWindow( qt_xdisplay(), outline_bottom, c->x(), c->y() + c->height() - 5, c->width(), 5 );
572 TQPixmap pix( 5, c->height() - 10 );
575 p.drawLine( 0, 0, 0, pix.height() - 1 );
576 p.drawLine( 4, 0, 4, pix.height() - 1 );
578 p.drawLine( 1, 0, 1, pix.height() - 1 );
579 p.drawLine( 3, 0, 3, pix.height() - 1 );
581 p.drawLine( 2, 0, 2, pix.height() - 1 );
583 XSetWindowBackgroundPixmap( qt_xdisplay(), outline_left, pix.handle());
584 XSetWindowBackgroundPixmap( qt_xdisplay(), outline_right, pix.handle());
587 TQPixmap pix( c->width(), 5 );
590 p.drawLine( 0, 0, pix.width() - 1 - 0, 0 );
591 p.drawLine( 4, 4, pix.width() - 1 - 4, 4 );
592 p.drawLine( 0, 0, 0, 4 );
593 p.drawLine( pix.width() - 1 - 0, 0, pix.width() - 1 - 0, 4 );
595 p.drawLine( 1, 1, pix.width() - 1 - 1, 1 );
596 p.drawLine( 3, 3, pix.width() - 1 - 3, 3 );
597 p.drawLine( 1, 1, 1, 4 );
598 p.drawLine( 3, 3, 3, 4 );
599 p.drawLine( pix.width() - 1 - 1, 1, pix.width() - 1 - 1, 4 );
600 p.drawLine( pix.width() - 1 - 3, 3, pix.width() - 1 - 3, 4 );
602 p.drawLine( 2, 2, pix.width() - 1 - 2, 2 );
603 p.drawLine( 2, 2, 2, 4 );
604 p.drawLine( pix.width() - 1 - 2, 2, pix.width() - 1 - 2, 4 );
606 XSetWindowBackgroundPixmap( qt_xdisplay(), outline_top, pix.handle());
609 TQPixmap pix( c->width(), 5 );
612 p.drawLine( 4, 0, pix.width() - 1 - 4, 0 );
613 p.drawLine( 0, 4, pix.width() - 1 - 0, 4 );
614 p.drawLine( 0, 4, 0, 0 );
615 p.drawLine( pix.width() - 1 - 0, 4, pix.width() - 1 - 0, 0 );
617 p.drawLine( 3, 1, pix.width() - 1 - 3, 1 );
618 p.drawLine( 1, 3, pix.width() - 1 - 1, 3 );
619 p.drawLine( 3, 1, 3, 0 );
620 p.drawLine( 1, 3, 1, 0 );
621 p.drawLine( pix.width() - 1 - 3, 1, pix.width() - 1 - 3, 0 );
622 p.drawLine( pix.width() - 1 - 1, 3, pix.width() - 1 - 1, 0 );
624 p.drawLine( 2, 2, pix.width() - 1 - 2, 2 );
625 p.drawLine( 2, 0, 2, 2 );
626 p.drawLine( pix.width() - 1 - 2, 0, pix.width() - 1 - 2, 2 );
628 XSetWindowBackgroundPixmap( qt_xdisplay(), outline_bottom, pix.handle());
630 XClearWindow( qt_xdisplay(), outline_left );
631 XClearWindow( qt_xdisplay(), outline_right );
632 XClearWindow( qt_xdisplay(), outline_top );
633 XClearWindow( qt_xdisplay(), outline_bottom );
634 XMapWindow( qt_xdisplay(), outline_left );
635 XMapWindow( qt_xdisplay(), outline_right );
636 XMapWindow( qt_xdisplay(), outline_top );
637 XMapWindow( qt_xdisplay(), outline_bottom );
642 delayedShowTimer.stop();
644 TQApplication::syncX();
646 while (XCheckTypedEvent (qt_xdisplay(), EnterNotify, &otherEvent ) )
651 void TabBox::reconfigure()
653 KConfig * c(KGlobal::config());
654 c->setGroup(
"TabBox");
655 options_traverse_all = c->readBoolEntry(
"TraverseAll",
false );
676 void TabBox::delayedShow()
678 KConfig * c(KGlobal::config());
679 c->setGroup(
"TabBox");
680 bool delay = c->readBoolEntry(
"ShowDelay",
true);
688 int delayTime = c->readNumEntry(
"DelayTime", 90);
689 delayedShowTimer.start(delayTime,
true);
693 void TabBox::handleMouseEvent( XEvent* e )
695 XAllowEvents( qt_xdisplay(), AsyncPointer, GET_QT_X_TIME() );
696 if( e->type != ButtonPress )
698 TQPoint pos( e->xbutton.x_root, e->xbutton.y_root );
699 if( !geometry().contains( pos ))
701 workspace()->closeTabBox();
706 int num = (pos.y()-frameWidth()) / lineHeight;
708 if( mode() == WindowsMode )
710 for( ClientList::ConstIterator it = clients.begin();
714 if( workspace()->hasClient( *it ) && (num == 0) )
716 setCurrentClient( *it );
724 int iDesktop = (mode() == DesktopMode) ? workspace()->currentDesktop() : 1;
726 i <= workspace()->numberOfDesktops();
735 if( mode() == DesktopMode )
736 iDesktop = workspace()->nextDesktopFocusChain( iDesktop );
754 bool areKeySymXsDepressed(
bool bAll,
const uint keySyms[],
int nKeySyms )
758 kdDebug(125) <<
"areKeySymXsDepressed: " << (bAll ?
"all of " :
"any of ") << nKeySyms << endl;
760 XQueryKeymap( qt_xdisplay(), keymap );
762 for(
int iKeySym = 0; iKeySym < nKeySyms; iKeySym++ )
764 uint keySymX = keySyms[ iKeySym ];
765 uchar keyCodeX = XKeysymToKeycode( qt_xdisplay(), keySymX );
766 int i = keyCodeX / 8;
767 char mask = 1 << (keyCodeX - (i * 8));
769 kdDebug(125) << iKeySym <<
": keySymX=0x" << TQString::number( keySymX, 16 )
770 <<
" i=" << i <<
" mask=0x" << TQString::number( mask, 16 )
771 <<
" keymap[i]=0x" << TQString::number( keymap[i], 16 ) << endl;
774 if( i < 0 || i >= 32 )
780 if( (keymap[i] & mask) == 0 )
786 if( keymap[i] & mask )
796 static bool areModKeysDepressed(
const KKeySequence& seq )
802 int mod = seq.key(seq.count()-1).modFlags();
804 if ( mod & KKey::SHIFT )
806 rgKeySyms[nKeySyms++] = XK_Shift_L;
807 rgKeySyms[nKeySyms++] = XK_Shift_R;
809 if ( mod & KKey::CTRL )
811 rgKeySyms[nKeySyms++] = XK_Control_L;
812 rgKeySyms[nKeySyms++] = XK_Control_R;
814 if( mod & KKey::ALT )
816 rgKeySyms[nKeySyms++] = XK_Alt_L;
817 rgKeySyms[nKeySyms++] = XK_Alt_R;
819 if( mod & KKey::WIN )
824 rgKeySyms[nKeySyms++] = XK_Super_L;
825 rgKeySyms[nKeySyms++] = XK_Super_R;
826 rgKeySyms[nKeySyms++] = XK_Meta_L;
827 rgKeySyms[nKeySyms++] = XK_Meta_R;
830 return areKeySymXsDepressed(
false, rgKeySyms, nKeySyms );
833 static bool areModKeysDepressed(
const KShortcut& cut )
835 for(
unsigned int i = 0;
839 if( areModKeysDepressed( cut.seq( i )))
845 void Workspace::slotWalkThroughWindows()
847 if ( root != qt_xrootwin() )
849 if ( tab_grab || control_grab )
851 if ( options->altTabStyle == Options::CDE || !options->focusPolicyIsReasonable())
855 CDEWalkThroughWindows(
true );
859 if ( areModKeysDepressed( cutWalkThroughWindows ) )
861 if ( startKDEWalkThroughWindows() )
862 KDEWalkThroughWindows(
true );
867 KDEOneStepThroughWindows(
true );
871 void Workspace::slotWalkBackThroughWindows()
873 if ( root != qt_xrootwin() )
875 if( tab_grab || control_grab )
877 if ( options->altTabStyle == Options::CDE || !options->focusPolicyIsReasonable())
880 CDEWalkThroughWindows(
false );
884 if ( areModKeysDepressed( cutWalkThroughWindowsReverse ) )
886 if ( startKDEWalkThroughWindows() )
887 KDEWalkThroughWindows(
false );
891 KDEOneStepThroughWindows(
false );
896 void Workspace::slotWalkThroughDesktops()
898 if ( root != qt_xrootwin() )
900 if( tab_grab || control_grab )
902 if ( areModKeysDepressed( cutWalkThroughDesktops ) )
904 if ( startWalkThroughDesktops() )
905 walkThroughDesktops(
true );
909 oneStepThroughDesktops(
true );
913 void Workspace::slotWalkBackThroughDesktops()
915 if ( root != qt_xrootwin() )
917 if( tab_grab || control_grab )
919 if ( areModKeysDepressed( cutWalkThroughDesktopsReverse ) )
921 if ( startWalkThroughDesktops() )
922 walkThroughDesktops(
false );
926 oneStepThroughDesktops(
false );
930 void Workspace::slotWalkThroughDesktopList()
932 if ( root != qt_xrootwin() )
934 if( tab_grab || control_grab )
936 if ( areModKeysDepressed( cutWalkThroughDesktopList ) )
938 if ( startWalkThroughDesktopList() )
939 walkThroughDesktops(
true );
943 oneStepThroughDesktopList(
true );
947 void Workspace::slotWalkBackThroughDesktopList()
949 if ( root != qt_xrootwin() )
951 if( tab_grab || control_grab )
953 if ( areModKeysDepressed( cutWalkThroughDesktopListReverse ) )
955 if ( startWalkThroughDesktopList() )
956 walkThroughDesktops(
false );
960 oneStepThroughDesktopList(
false );
964 bool Workspace::startKDEWalkThroughWindows()
966 if( !establishTabBoxGrab())
969 keys->suspend(
true );
970 disable_shortcuts_keys->suspend(
true );
971 client_keys->suspend(
true );
972 tab_box->setMode( TabBox::WindowsMode );
977 bool Workspace::startWalkThroughDesktops(
int mode )
979 if( !establishTabBoxGrab())
982 keys->suspend(
true );
983 disable_shortcuts_keys->suspend(
true );
984 client_keys->suspend(
true );
985 tab_box->setMode( (TabBox::Mode) mode );
990 bool Workspace::startWalkThroughDesktops()
992 return startWalkThroughDesktops( TabBox::DesktopMode );
995 bool Workspace::startWalkThroughDesktopList()
997 return startWalkThroughDesktops( TabBox::DesktopListMode );
1000 void Workspace::KDEWalkThroughWindows(
bool forward )
1002 tab_box->nextPrev( forward );
1003 tab_box->delayedShow();
1006 void Workspace::walkThroughDesktops(
bool forward )
1008 tab_box->nextPrev( forward );
1009 tab_box->delayedShow();
1012 void Workspace::CDEWalkThroughWindows(
bool forward )
1018 Q_ASSERT( block_stacking_updates == 0 );
1019 for( ClientList::ConstIterator it = stacking_order.fromLast();
1020 it != stacking_order.end();
1023 if ( (*it)->isOnCurrentDesktop() && !(*it)->isSpecialWindow()
1024 && (*it)->isShown(
false ) && (*it)->wantsTabFocus()
1025 && !(*it)->keepAbove() && !(*it)->keepBelow())
1032 bool options_traverse_all;
1034 KConfigGroupSaver saver( KGlobal::config(),
"TabBox" );
1035 options_traverse_all = KGlobal::config()->readBoolEntry(
"TraverseAll",
false );
1038 Client* firstClient = 0;
1041 nc = forward ? nextStaticClient(nc) : previousStaticClient(nc);
1048 else if (nc == firstClient)
1054 }
while (nc && nc != c &&
1055 (( !options_traverse_all && !nc->isOnDesktop(currentDesktop())) ||
1056 nc->isMinimized() || !nc->wantsTabFocus() || nc->keepAbove() || nc->keepBelow() ) );
1061 if ( options->focusPolicyIsReasonable() )
1063 activateClient( nc );
1064 if( nc->isShade() && options->shadeHover )
1065 nc->setShade( ShadeActivated );
1069 if( !nc->isOnDesktop( currentDesktop()))
1070 setCurrentDesktop( nc->desktop());
1076 void Workspace::KDEOneStepThroughWindows(
bool forward )
1078 tab_box->setMode( TabBox::WindowsMode );
1080 tab_box->nextPrev( forward );
1081 if( Client* c = tab_box->currentClient() )
1083 activateClient( c );
1084 if( c->isShade() && options->shadeHover )
1085 c->setShade( ShadeActivated );
1089 void Workspace::oneStepThroughDesktops(
bool forward,
int mode )
1091 tab_box->setMode( (TabBox::Mode) mode );
1093 tab_box->nextPrev( forward );
1094 if ( tab_box->currentDesktop() != -1 )
1095 setCurrentDesktop( tab_box->currentDesktop() );
1098 void Workspace::oneStepThroughDesktops(
bool forward )
1100 oneStepThroughDesktops( forward, TabBox::DesktopMode );
1103 void Workspace::oneStepThroughDesktopList(
bool forward )
1105 oneStepThroughDesktops( forward, TabBox::DesktopListMode );
1111 void Workspace::tabBoxKeyPress(
const KKeyNative& keyX )
1113 bool forward =
false;
1114 bool backward =
false;
1118 forward = cutWalkThroughWindows.contains( keyX );
1119 backward = cutWalkThroughWindowsReverse.contains( keyX );
1120 if (forward || backward)
1122 kdDebug(125) <<
"== " << cutWalkThroughWindows.toStringInternal()
1123 <<
" or " << cutWalkThroughWindowsReverse.toStringInternal() << endl;
1124 KDEWalkThroughWindows( forward );
1127 else if (control_grab)
1129 forward = cutWalkThroughDesktops.contains( keyX ) ||
1130 cutWalkThroughDesktopList.contains( keyX );
1131 backward = cutWalkThroughDesktopsReverse.contains( keyX ) ||
1132 cutWalkThroughDesktopListReverse.contains( keyX );
1133 if (forward || backward)
1134 walkThroughDesktops(forward);
1137 if (control_grab || tab_grab)
1139 uint keyQt = keyX.keyCodeQt();
1140 if ( ((keyQt & 0xffff) == Qt::Key_Escape)
1141 && !(forward || backward) )
1148 void Workspace::closeTabBox()
1152 keys->suspend(
false );
1153 disable_shortcuts_keys->suspend(
false );
1154 client_keys->suspend(
false );
1156 control_grab = FALSE;
1162 void Workspace::tabBoxKeyRelease(
const XKeyEvent& ev )
1164 unsigned int mk = ev.state &
1165 (KKeyNative::modX(KKey::SHIFT) |
1166 KKeyNative::modX(KKey::CTRL) |
1167 KKeyNative::modX(KKey::ALT) |
1168 KKeyNative::modX(KKey::WIN));
1174 for(
int i = ShiftMapIndex;
1177 if(( mk & ( 1 << i )) != 0 )
1179 if( mod_index >= 0 )
1183 bool release =
false;
1184 if( mod_index == -1 )
1188 XModifierKeymap* xmk = XGetModifierMapping(qt_xdisplay());
1189 for (
int i=0; i<xmk->max_keypermod; i++)
1190 if (xmk->modifiermap[xmk->max_keypermod * mod_index + i]
1193 XFreeModifiermap(xmk);
1201 keys->suspend(
false );
1202 disable_shortcuts_keys->suspend(
false );
1203 client_keys->suspend(
false );
1205 if( Client* c = tab_box->currentClient())
1207 activateClient( c );
1208 if( c->isShade() && options->shadeHover )
1209 c->setShade( ShadeActivated );
1216 keys->suspend(
false );
1217 disable_shortcuts_keys->suspend(
false );
1218 client_keys->suspend(
false );
1219 control_grab = False;
1220 if ( tab_box->currentDesktop() != -1 )
1222 setCurrentDesktop( tab_box->currentDesktop() );
1228 int Workspace::nextDesktopFocusChain(
int iDesktop )
const
1230 int i = desktop_focus_chain.find( iDesktop );
1231 if( i >= 0 && i+1 < (
int)desktop_focus_chain.size() )
1232 return desktop_focus_chain[i+1];
1233 else if( desktop_focus_chain.size() > 0 )
1234 return desktop_focus_chain[ 0 ];
1239 int Workspace::previousDesktopFocusChain(
int iDesktop )
const
1241 int i = desktop_focus_chain.find( iDesktop );
1243 return desktop_focus_chain[i-1];
1244 else if( desktop_focus_chain.size() > 0 )
1245 return desktop_focus_chain[desktop_focus_chain.size()-1];
1247 return numberOfDesktops();
1254 Client* Workspace::nextFocusChainClient( Client* c )
const
1256 if ( global_focus_chain.isEmpty() )
1258 ClientList::ConstIterator it = global_focus_chain.find( c );
1259 if ( it == global_focus_chain.end() )
1260 return global_focus_chain.last();
1261 if ( it == global_focus_chain.begin() )
1262 return global_focus_chain.last();
1271 Client* Workspace::previousFocusChainClient( Client* c )
const
1273 if ( global_focus_chain.isEmpty() )
1275 ClientList::ConstIterator it = global_focus_chain.find( c );
1276 if ( it == global_focus_chain.end() )
1277 return global_focus_chain.first();
1279 if ( it == global_focus_chain.end() )
1280 return global_focus_chain.first();
1288 Client* Workspace::nextStaticClient( Client* c )
const
1290 if ( !c || clients.isEmpty() )
1292 ClientList::ConstIterator it = clients.find( c );
1293 if ( it == clients.end() )
1294 return clients.first();
1296 if ( it == clients.end() )
1297 return clients.first();
1304 Client* Workspace::previousStaticClient( Client* c )
const
1306 if ( !c || clients.isEmpty() )
1308 ClientList::ConstIterator it = clients.find( c );
1309 if ( it == clients.end() )
1310 return clients.last();
1311 if ( it == clients.begin() )
1312 return clients.last();
1317 bool Workspace::establishTabBoxGrab()
1319 if( XGrabKeyboard( qt_xdisplay(), root, FALSE,
1320 GrabModeAsync, GrabModeAsync, GET_QT_X_TIME()) != GrabSuccess )
1327 assert( !forced_global_mouse_grab );
1328 forced_global_mouse_grab =
true;
1329 if( active_client != NULL )
1330 active_client->updateMouseGrab();
1334 void Workspace::removeTabBoxGrab()
1336 XUngrabKeyboard(qt_xdisplay(), GET_QT_X_TIME());
1337 assert( forced_global_mouse_grab );
1338 forced_global_mouse_grab =
false;
1339 if( active_client != NULL )
1340 active_client->updateMouseGrab();
1345 #include "tabbox.moc"