Shortcuts for moving a window to left/right/up/down.

CCMAIL: 87411-done@bugs.kde.org

svn path=/trunk/kdebase/kwin/; revision=348524
icc-effect-5.14.5
Luboš Luňák 2004-09-22 16:49:41 +00:00
parent 4e52fbebdc
commit 43e7580cf0
4 changed files with 218 additions and 110 deletions

View File

@ -99,6 +99,10 @@
DEF( I18N_NOOP("Window to Desktop 20"), 0, 0, slotWindowToDesktop(int) );
DEF( I18N_NOOP("Window to Next Desktop"), 0, 0, slotWindowToNextDesktop() );
DEF( I18N_NOOP("Window to Previous Desktop"), 0, 0, slotWindowToPreviousDesktop() );
DEF( I18N_NOOP("Window One Desktop to the Right"), 0, 0, slotWindowToDesktopRight() );
DEF( I18N_NOOP("Window One Desktop to the Left"), 0, 0, slotWindowToDesktopLeft() );
DEF( I18N_NOOP("Window One Desktop Up"), 0, 0, slotWindowToDesktopUp() );
DEF( I18N_NOOP("Window One Desktop Down"), 0, 0, slotWindowToDesktopDown() );
keys->insert( "Group:Desktop Switching", i18n("Desktop Switching") );
DEF( I18N_NOOP("Switch to Desktop 1"), CTRL+Qt::Key_F1, WIN+Qt::Key_F1, slotSwitchToDesktop(int) );

View File

@ -457,129 +457,37 @@ void Workspace::slotSwitchDesktopPrevious()
void Workspace::slotSwitchDesktopRight()
{
int x,y;
calcDesktopLayout(x,y);
int dt = currentDesktop()-1;
if (layoutOrientation == Qt::Vertical)
{
dt += y;
if ( dt >= numberOfDesktops() )
{
if ( options->rollOverDesktops )
dt -= numberOfDesktops();
else
return;
}
}
else
{
int d = (dt % x) + 1;
if ( d >= x )
{
if ( options->rollOverDesktops )
d -= x;
else
return;
}
dt = dt - (dt % x) + d;
}
setCurrentDesktop(dt+1);
int desktop = desktopToRight( currentDesktop());
if( desktop == currentDesktop())
return;
setCurrentDesktop( desktop );
popupinfo->showInfo( desktopName(currentDesktop()) );
}
void Workspace::slotSwitchDesktopLeft()
{
int x,y;
calcDesktopLayout(x,y);
int dt = currentDesktop()-1;
if (layoutOrientation == Qt::Vertical)
{
dt -= y;
if ( dt < 0 )
{
if ( options->rollOverDesktops )
dt += numberOfDesktops();
else
return;
}
}
else
{
int d = (dt % x) - 1;
if ( d < 0 )
{
if ( options->rollOverDesktops )
d += x;
else
return;
}
dt = dt - (dt % x) + d;
}
setCurrentDesktop(dt+1);
int desktop = desktopToLeft( currentDesktop());
if( desktop == currentDesktop())
return;
setCurrentDesktop( desktop );
popupinfo->showInfo( desktopName(currentDesktop()) );
}
void Workspace::slotSwitchDesktopUp()
{
int x,y;
calcDesktopLayout(x,y);
int dt = currentDesktop()-1;
if (layoutOrientation == Qt::Horizontal)
{
dt -= x;
if ( dt < 0 )
{
if ( options->rollOverDesktops )
dt += numberOfDesktops();
else
return;
}
}
else
{
int d = (dt % y) - 1;
if ( d < 0 )
{
if ( options->rollOverDesktops )
d += y;
else
return;
}
dt = dt - (dt % y) + d;
}
setCurrentDesktop(dt+1);
int desktop = desktopUp( currentDesktop());
if( desktop == currentDesktop())
return;
setCurrentDesktop( desktop );
popupinfo->showInfo( desktopName(currentDesktop()) );
}
void Workspace::slotSwitchDesktopDown()
{
int x,y;
calcDesktopLayout(x,y);
int dt = currentDesktop()-1;
if (layoutOrientation == Qt::Horizontal)
{
dt += x;
if ( dt >= numberOfDesktops() )
{
if ( options->rollOverDesktops )
dt -= numberOfDesktops();
else
return;
}
}
else
{
int d = (dt % y) + 1;
if ( d >= y )
{
if ( options->rollOverDesktops )
d -= y;
else
return;
}
dt = dt - (dt % y) + d;
}
setCurrentDesktop(dt+1);
int desktop = desktopDown( currentDesktop());
if( desktop == currentDesktop())
return;
setCurrentDesktop( desktop );
popupinfo->showInfo( desktopName(currentDesktop()) );
}
@ -736,6 +644,67 @@ void Workspace::slotWindowToPreviousDesktop()
}
}
void Workspace::slotWindowToDesktopRight()
{
int d = desktopToRight( currentDesktop());
if( d == currentDesktop())
return;
if (active_client && !active_client->isDesktop()
&& !active_client->isDock() && !active_client->isTopMenu())
{
setClientIsMoving( active_client );
setCurrentDesktop( d );
setClientIsMoving( NULL );
popupinfo->showInfo( desktopName(currentDesktop()) );
}
}
void Workspace::slotWindowToDesktopLeft()
{
int d = desktopToLeft( currentDesktop());
if( d == currentDesktop())
return;
if (active_client && !active_client->isDesktop()
&& !active_client->isDock() && !active_client->isTopMenu())
{
setClientIsMoving( active_client );
setCurrentDesktop( d );
setClientIsMoving( NULL );
popupinfo->showInfo( desktopName(currentDesktop()) );
}
}
void Workspace::slotWindowToDesktopUp()
{
int d = desktopUp( currentDesktop());
if( d == currentDesktop())
return;
if (active_client && !active_client->isDesktop()
&& !active_client->isDock() && !active_client->isTopMenu())
{
setClientIsMoving( active_client );
setCurrentDesktop( d );
setClientIsMoving( NULL );
popupinfo->showInfo( desktopName(currentDesktop()) );
}
}
void Workspace::slotWindowToDesktopDown()
{
int d = desktopDown( currentDesktop());
if( d == currentDesktop())
return;
if (active_client && !active_client->isDesktop()
&& !active_client->isDock() && !active_client->isTopMenu())
{
setClientIsMoving( active_client );
setCurrentDesktop( d );
setClientIsMoving( NULL );
popupinfo->showInfo( desktopName(currentDesktop()) );
}
}
/*!
Kill Window feature, similar to xkill
*/

View File

@ -1129,6 +1129,7 @@ bool Workspace::setCurrentDesktop( int new_desktop )
return true;
}
// called only from DCOP
void Workspace::nextDesktop()
{
int desktop = currentDesktop() + 1;
@ -1136,6 +1137,7 @@ void Workspace::nextDesktop()
popupinfo->showInfo( desktopName(currentDesktop()) );
}
// called only from DCOP
void Workspace::previousDesktop()
{
int desktop = currentDesktop() - 1;
@ -1143,6 +1145,131 @@ void Workspace::previousDesktop()
popupinfo->showInfo( desktopName(currentDesktop()) );
}
int Workspace::desktopToRight( int desktop ) const
{
int x,y;
calcDesktopLayout(x,y);
int dt = desktop-1;
if (layoutOrientation == Qt::Vertical)
{
dt += y;
if ( dt >= numberOfDesktops() )
{
if ( options->rollOverDesktops )
dt -= numberOfDesktops();
else
return desktop;
}
}
else
{
int d = (dt % x) + 1;
if ( d >= x )
{
if ( options->rollOverDesktops )
d -= x;
else
return desktop;
}
dt = dt - (dt % x) + d;
}
return dt+1;
}
int Workspace::desktopToLeft( int desktop ) const
{
int x,y;
calcDesktopLayout(x,y);
int dt = desktop-1;
if (layoutOrientation == Qt::Vertical)
{
dt -= y;
if ( dt < 0 )
{
if ( options->rollOverDesktops )
dt += numberOfDesktops();
else
return desktop;
}
}
else
{
int d = (dt % x) - 1;
if ( d < 0 )
{
if ( options->rollOverDesktops )
d += x;
else
return desktop;
}
dt = dt - (dt % x) + d;
}
return dt+1;
}
int Workspace::desktopUp( int desktop ) const
{
int x,y;
calcDesktopLayout(x,y);
int dt = desktop-1;
if (layoutOrientation == Qt::Horizontal)
{
dt -= x;
if ( dt < 0 )
{
if ( options->rollOverDesktops )
dt += numberOfDesktops();
else
return desktop;
}
}
else
{
int d = (dt % y) - 1;
if ( d < 0 )
{
if ( options->rollOverDesktops )
d += y;
else
return desktop;
}
dt = dt - (dt % y) + d;
}
return dt+1;
}
int Workspace::desktopDown( int desktop ) const
{
int x,y;
calcDesktopLayout(x,y);
int dt = desktop-1;
if (layoutOrientation == Qt::Horizontal)
{
dt += x;
if ( dt >= numberOfDesktops() )
{
if ( options->rollOverDesktops )
dt -= numberOfDesktops();
else
return desktop;
}
}
else
{
int d = (dt % y) + 1;
if ( d >= y )
{
if ( options->rollOverDesktops )
d -= y;
else
return desktop;
}
dt = dt - (dt % y) + d;
}
return dt+1;
}
/*!
Sets the number of virtual desktops to \a n
*/
@ -1241,7 +1368,7 @@ void Workspace::setDesktopLayout(int o, int x, int y)
layoutY = y;
}
void Workspace::calcDesktopLayout(int &x, int &y)
void Workspace::calcDesktopLayout(int &x, int &y) const
{
x = layoutX;
y = layoutY;

View File

@ -309,6 +309,10 @@ class Workspace : public QObject, public KWinInterface, public KDecorationDefine
void slotWindowToNextDesktop();
void slotWindowToPreviousDesktop();
void slotWindowToDesktopRight();
void slotWindowToDesktopLeft();
void slotWindowToDesktopUp();
void slotWindowToDesktopDown();
void slotMouseEmulation();
@ -361,6 +365,10 @@ class Workspace : public QObject, public KWinInterface, public KDecorationDefine
void oneStepThroughDesktopList( bool forward );
bool establishTabBoxGrab();
void removeTabBoxGrab();
int desktopToRight( int desktop ) const;
int desktopToLeft( int desktop ) const;
int desktopUp( int desktop ) const;
int desktopDown( int desktop ) const;
void updateStackingOrder( bool propagate_new_clients = false );
void propagateClients( bool propagate_new_clients ); // called only from updateStackingOrder
@ -414,7 +422,7 @@ class Workspace : public QObject, public KWinInterface, public KDecorationDefine
void helperDialog( const QString& message, const Client* c );
void calcDesktopLayout(int &x, int &y);
void calcDesktopLayout(int &x, int &y) const;
QPopupMenu* clientPopup();