move the "To Desktop" menu to the right place again

instead of just appending it

svn path=/trunk/KDE/kdebase/workspace/; revision=657251
This commit is contained in:
Dirk Mueller 2007-04-23 16:49:41 +00:00
parent fc27b480d8
commit e218e7e01d
3 changed files with 400 additions and 565 deletions

View file

@ -19,12 +19,11 @@ License. See the file "COPYING" for the exact licensing terms.
#include "client.h"
#include "workspace.h"
#include "effects.h"
#include <fixx11h.h>
#include <QPushButton>
#include <QSlider>
#include <QToolTip>
#include <kglobalsettings.h>
#include <kiconloader.h>
#include <klocale.h>
@ -61,7 +60,7 @@ QMenu* Workspace::clientPopup()
advanced_popup->setFont(KGlobalSettings::menuFont());
mKeepAboveOpAction = advanced_popup->addAction( i18n("Keep &Above Others") );
mKeepAboveOpAction->setIcon( KIcon( "up" ) );
mKeepAboveOpAction->setIcon( KIcon( "go-up" ) );
KAction *kaction = qobject_cast<KAction*>( keys->action("Window Above Other Windows") );
if ( kaction!=0 )
mKeepAboveOpAction->setShortcut( kaction->globalShortcut().primary() );
@ -69,7 +68,7 @@ QMenu* Workspace::clientPopup()
mKeepAboveOpAction->setData( Options::KeepAboveOp );
mKeepBelowOpAction = advanced_popup->addAction( i18n("Keep &Below Others") );
mKeepBelowOpAction->setIcon( KIcon( "down" ) );
mKeepBelowOpAction->setIcon( KIcon( "go-down" ) );
kaction = qobject_cast<KAction*>( keys->action("Window Below Other Windows") );
if ( kaction!=0 )
mKeepBelowOpAction->setShortcut( kaction->globalShortcut().primary() );
@ -77,7 +76,7 @@ QMenu* Workspace::clientPopup()
mKeepBelowOpAction->setData( Options::KeepBelowOp );
mFullScreenOpAction = advanced_popup->addAction( i18n("&Fullscreen") );
mFullScreenOpAction->setIcon( KIcon( "window_fullscreen" ) );
mFullScreenOpAction->setIcon( KIcon( "view-fullscreen" ) );
kaction = qobject_cast<KAction*>( keys->action("Window Fullscreen") );
if ( kaction!=0 )
mFullScreenOpAction->setShortcut( kaction->globalShortcut().primary() );
@ -109,21 +108,23 @@ QMenu* Workspace::clientPopup()
action = popup->addMenu( advanced_popup );
action->setText( i18n("Ad&vanced") );
desk_popup_index = popup->actions().count();
if (options->useTranslucency){
trans_popup = new QMenu( popup );
trans_popup->setFont(KGlobalSettings::menuFont());
connect( trans_popup, SIGNAL( triggered(QAction*) ), this, SLOT( setPopupClientOpacity(QAction*)));
const int levels[] = { 100, 90, 75, 50, 25, 10 };
for( unsigned int i = 0;
i < sizeof( levels ) / sizeof( levels[ 0 ] );
++i )
{
action = trans_popup->addAction( QString::number( levels[ i ] ) + "%" );
action->setCheckable( true );
action->setData( levels[ i ] );
}
QMenu *trans_popup = new QMenu( popup );
QVBoxLayout *transLayout = new QVBoxLayout(trans_popup);
trans_popup->setLayout( transLayout );
transButton = new QPushButton(trans_popup);
transButton->setObjectName("transButton");
transButton->setToolTip( i18n("Reset opacity to default value"));
transSlider = new QSlider(trans_popup);
transSlider->setObjectName( "transSlider" );
transSlider->setRange( 0, 100 );
transSlider->setValue( 100 );
transSlider->setOrientation( Qt::Vertical );
transSlider->setToolTip( i18n("Slide this to set the window's opacity"));
connect(transButton, SIGNAL(clicked()), SLOT(resetClientOpacity()));
connect(transButton, SIGNAL(clicked()), trans_popup, SLOT(hide()));
connect(transSlider, SIGNAL(valueChanged(int)), SLOT(setTransButtonText(int)));
connect(transSlider, SIGNAL(valueChanged(int)), this, SLOT(setPopupClientOpacity(int)));
action = popup->addMenu( trans_popup );
action->setText( i18n("&Opacity") );
}
@ -173,7 +174,7 @@ QMenu* Workspace::clientPopup()
}
mCloseOpAction = popup->addAction( i18n("&Close") );
mCloseOpAction->setIcon( KIcon( "fileclose" ) );
mCloseOpAction->setIcon( KIcon( "window-close" ) );
kaction = qobject_cast<KAction*>( keys->action("Window Close") );
if ( kaction!=0 )
mCloseOpAction->setShortcut( kaction->globalShortcut().primary() );
@ -182,14 +183,31 @@ QMenu* Workspace::clientPopup()
return popup;
}
void Workspace::setPopupClientOpacity( QAction* action )
//sets the transparency of the client to given value(given by slider)
void Workspace::setPopupClientOpacity(int value)
{
if( active_popup_client == NULL )
return;
int level = action->data().toInt();
active_popup_client->setOpacity( level / 100.0 );
// TODO
}
void Workspace::setTransButtonText(int value)
{
value = 100 - value;
if(value < 0)
transButton->setText("000 %");
else if (value >= 100 )
transButton->setText("100 %");
else if(value < 10)
transButton->setText("00"+QString::number(value)+" %");
else if(value < 100)
transButton->setText('0'+QString::number(value)+" %");
}
void Workspace::resetClientOpacity()
{
// TODO
}
/*!
The client popup menu will become visible soon.
@ -224,16 +242,6 @@ void Workspace::clientPopupAboutToShow()
mNoBorderOpAction->setChecked( active_popup_client->noBorder() );
mMinimizeOpAction->setEnabled( active_popup_client->isMinimizable() );
mCloseOpAction->setEnabled( active_popup_client->isCloseable() );
if (options->useTranslucency)
{
foreach( QAction* action, trans_popup->actions())
{
if( action->data().toInt() == qRound( active_popup_client->opacity() * 100 ))
action->setChecked( true );
else
action->setChecked( false );
}
}
}
@ -249,9 +257,9 @@ void Workspace::initDesktopPopup()
connect( desk_popup, SIGNAL( aboutToShow() ),
this, SLOT( desktopPopupAboutToShow() ) );
QAction *action = popup->addMenu( desk_popup );
QAction *action = desk_popup->menuAction();
popup->insertAction(mMoveOpAction, action);
action->setText( i18n("To &Desktop") );
action->setData( desk_popup_index );
}
/*!
@ -450,16 +458,16 @@ void Workspace::performWindowOperation( Client* c, Options::WindowOperation op )
switch ( op )
{
case Options::MoveOp:
c->performMouseCommand( Options::MouseMove, cursorPos() );
c->performMouseCommand( Options::MouseMove, QCursor::pos() );
break;
case Options::UnrestrictedMoveOp:
c->performMouseCommand( Options::MouseUnrestrictedMove, cursorPos() );
c->performMouseCommand( Options::MouseUnrestrictedMove, QCursor::pos() );
break;
case Options::ResizeOp:
c->performMouseCommand( Options::MouseResize, cursorPos() );
c->performMouseCommand( Options::MouseResize, QCursor::pos() );
break;
case Options::UnrestrictedResizeOp:
c->performMouseCommand( Options::MouseUnrestrictedResize, cursorPos() );
c->performMouseCommand( Options::MouseUnrestrictedResize, QCursor::pos() );
break;
case Options::CloseOp:
c->closeWindow();
@ -481,7 +489,7 @@ void Workspace::performWindowOperation( Client* c, Options::WindowOperation op )
c->minimize();
break;
case Options::ShadeOp:
c->performMouseCommand( Options::MouseShade, cursorPos());
c->performMouseCommand( Options::MouseShade, QCursor::pos());
break;
case Options::OnAllDesktopsOp:
c->setOnAllDesktops( !c->isOnAllDesktops() );
@ -511,7 +519,7 @@ void Workspace::performWindowOperation( Client* c, Options::WindowOperation op )
break;
}
case Options::OperationsOp:
c->performMouseCommand( Options::MouseShade, cursorPos());
c->performMouseCommand( Options::MouseShade, QCursor::pos());
break;
case Options::WindowRulesOp:
editWindowRules( c, false );
@ -676,10 +684,10 @@ bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPo
workspace()->windowToNextDesktop( this );
break;
case Options::MouseOpacityMore:
setOpacity( qMin( opacity() + 0.1, 1.0 ));
// TODO
break;
case Options::MouseOpacityLess:
setOpacity( qMax( opacity() - 0.1, 0.0 ));
// TODO
break;
case Options::MouseNothing:
replay = true;
@ -694,24 +702,6 @@ void Workspace::showWindowMenuAt( unsigned long, int, int )
slotWindowOperations();
}
void Workspace::loadEffect( const QString& name )
{
if( effects )
static_cast<EffectsHandlerImpl*>(effects)->loadEffect( name );
}
void Workspace::toggleEffect( const QString& name )
{
if( effects )
static_cast<EffectsHandlerImpl*>(effects)->toggleEffect( name );
}
void Workspace::unloadEffect( const QString& name )
{
if( effects )
static_cast<EffectsHandlerImpl*>(effects)->unloadEffect( name );
}
void Workspace::slotActivateAttentionWindow()
{
if( attention_chain.count() > 0 )

File diff suppressed because it is too large Load diff

View file

@ -18,8 +18,6 @@ License. See the file "COPYING" for the exact licensing terms.
#include <QCursor>
#include <netwm.h>
#include <kxmessages.h>
#include <qdatetime.h>
#include <kmanagerselection.h>
#include "utils.h"
#include "kdecoration.h"
@ -36,6 +34,7 @@ class KStartupInfoId;
class KStartupInfoData;
class QSlider;
class QPushButton;
class K3Process;
namespace KWin
{
@ -80,7 +79,6 @@ class Workspace : public QObject, public KDecorationDefines
static Workspace * self() { return _self; }
bool workspaceEvent( XEvent * );
bool workspaceEvent( QEvent * );
KDecoration* createDecoration( KDecorationBridge* bridge );
@ -89,9 +87,6 @@ class Workspace : public QObject, public KDecorationDefines
template< typename T > Client* findClient( T predicate );
template< typename T1, typename T2 > void forEachClient( T1 procedure, T2 predicate );
template< typename T > void forEachClient( T procedure );
template< typename T > Unmanaged* findUnmanaged( T predicate );
template< typename T1, typename T2 > void forEachUnmanaged( T1 procedure, T2 predicate );
template< typename T > void forEachUnmanaged( T procedure );
QRect clientArea( clientAreaOption, const QPoint& p, int desktop ) const;
QRect clientArea( clientAreaOption, const Client* c ) const;
@ -155,10 +150,7 @@ class Workspace : public QObject, public KDecorationDefines
void clientHidden( Client* );
void clientAttentionChanged( Client* c, bool set );
void checkElectricBorder(const QPoint &pos, Time time);
void reserveElectricBorder( ElectricBorder border );
void unreserveElectricBorder( ElectricBorder border );
void reserveElectricBorderSwitching( bool reserve );
void clientMoved(const QPoint &pos, Time time);
/**
* Returns the current virtual desktop of this workspace
@ -169,27 +161,16 @@ class Workspace : public QObject, public KDecorationDefines
*/
int numberOfDesktops() const;
void setNumberOfDesktops( int n );
void calcDesktopLayout(int* x, int* y, Qt::Orientation* orientation) const;
QWidget* desktopWidget();
// for TabBox
Client* currentTabBoxClient() const;
ClientList currentTabBoxClientList() const;
int currentTabBoxDesktop() const;
QList< int > currentTabBoxDesktopList() const;
void setTabBoxClient(Client*);
void setTabBoxDesktop(int);
Client* nextClientFocusChain(Client*) const;
Client* previousClientFocusChain(Client*) const;
Client* nextClientStatic(Client*) const;
Client* previousClientStatic(Client*) const;
Client* nextFocusChainClient(Client*) const;
Client* previousFocusChainClient(Client*) const;
Client* nextStaticClient(Client*) const;
Client* previousStaticClient(Client*) const;
int nextDesktopFocusChain( int iDesktop ) const;
int previousDesktopFocusChain( int iDesktop ) const;
int nextDesktopStatic( int iDesktop ) const;
int previousDesktopStatic( int iDesktop ) const;
void refTabBox();
void unrefTabBox();
void closeTabBox();
/**
@ -200,7 +181,7 @@ class Workspace : public QObject, public KDecorationDefines
ClientList ensureStackingOrder( const ClientList& clients ) const;
Client* topClientOnDesktop( int desktop, bool unconstrained = false ) const;
Client* topClientOnDesktop( int desktop, bool unconstrained = false, bool only_normal = true ) const;
Client* findDesktop( bool topmost, int desktop ) const;
void sendClientToDesktop( Client* c, int desktop, bool dont_activate );
void windowToPreviousDesktop( Client* c );
@ -209,11 +190,6 @@ class Workspace : public QObject, public KDecorationDefines
// KDE4 remove me - and it's also in the DCOP interface :(
void showWindowMenuAt( unsigned long id, int x, int y );
void loadEffect( const QString& name );
void toggleEffect( const QString& name );
void unloadEffect( const QString& name );
/**
* Shows the menu operations menu for the client and makes it active if
* it's not already.
@ -237,6 +213,8 @@ class Workspace : public QObject, public KDecorationDefines
WindowRules findWindowRules( const Client*, bool );
void rulesUpdated();
void discardUsedWindowRules( Client* c, bool withdraw );
void disableRulesUpdates( bool disable );
bool rulesUpdatesDisabled() const;
// dcop interface
void cascadeDesktop();
@ -248,7 +226,7 @@ class Workspace : public QObject, public KDecorationDefines
void circulateDesktopApplications();
QString desktopName( int desk ) const;
void setDesktopLayout(int o, int x, int y);
void setDesktopLayout(NET::Orientation o, int x, int y, NET::DesktopLayoutCorner c);
void setShowingDesktop( bool showing );
void resetShowingDesktop( bool keep_hidden );
bool showingDesktop() const;
@ -258,17 +236,14 @@ class Workspace : public QObject, public KDecorationDefines
void sendPingToWindow( Window w, Time timestamp ); // called from Client::pingWindow()
void sendTakeActivity( Client* c, Time timestamp, long flags ); // called from Client::takeActivity()
void removeClient( Client*, allowed_t ); // only called from Client::destroyClient() or Client::releaseWindow()
// only called from Client::destroyClient() or Client::releaseWindow()
void removeClient( Client*, allowed_t );
void setActiveClient( Client*, allowed_t );
Group* findGroup( Window leader ) const;
void addGroup( Group* group, allowed_t );
void removeGroup( Group* group, allowed_t );
Group* findClientLeaderGroup( const Client* c ) const;
void removeUnmanaged( Unmanaged*, allowed_t ); // only called from Unmanaged::release()
void removeDeleted( Deleted*, allowed_t );
void addDeleted( Deleted*, allowed_t );
bool checkStartupNotification( Window w, KStartupInfoId& id, KStartupInfoData& data );
void focusToNull(); // SELI public?
@ -281,7 +256,6 @@ class Workspace : public QObject, public KDecorationDefines
bool globalShortcutsDisabled() const;
void disableGlobalShortcuts( bool disable );
void disableGlobalShortcutsForClient( bool disable );
QPoint cursorPos();
void sessionSaveStarted();
void sessionSaveDone();
@ -305,19 +279,6 @@ class Workspace : public QObject, public KDecorationDefines
void toggleTopDockShadows(bool on);
// when adding repaints caused by a window, you probably want to use
// either Toplevel::addRepaint() or Toplevel::addWorkspaceRepaint()
void addRepaint( const QRect& r );
void addRepaint( int x, int y, int w, int h );
void addRepaintFull();
// creates XComposite overlay window, call initOverlay() afterwards
bool createOverlay();
// init overlay and the destination window in it
void setupOverlay( Window window );
// destroys XComposite overlay window
void destroyOverlay();
Window overlayWindow();
public slots:
void refresh();
// keybindings
@ -447,16 +408,15 @@ class Workspace : public QObject, public KDecorationDefines
void cleanupTemporaryRules();
void writeWindowRules();
void slotBlockShortcuts(int data);
void setPopupClientOpacity( QAction* action );
void setupCompositing();
void performCompositing();
void lostCMSelection();
void updateElectricBorders();
void resetCursorPosTime();
void slotReloadConfig();
// kompmgr
void setPopupClientOpacity(int v);
void resetClientOpacity();
void setTransButtonText(int value);
// end
protected:
bool keyPressMouseEmulation( XKeyEvent& ev );
bool netCheck( XEvent* e );
private:
void init();
@ -464,17 +424,16 @@ class Workspace : public QObject, public KDecorationDefines
void readShortcuts();
void initDesktopPopup();
void setupWindowShortcut( Client* c );
void checkCursorPos();
bool startKDEWalkThroughWindows();
bool startWalkThroughDesktops( TabBoxMode mode ); // TabBoxDesktopMode | TabBoxDesktopListMode
bool startWalkThroughDesktops( int mode ); // TabBox::Mode::DesktopMode | DesktopListMode
bool startWalkThroughDesktops();
bool startWalkThroughDesktopList();
void KDEWalkThroughWindows( bool forward );
void CDEWalkThroughWindows( bool forward );
void walkThroughDesktops( bool forward );
void KDEOneStepThroughWindows( bool forward );
void oneStepThroughDesktops( bool forward, TabBoxMode mode ); // TabBoxDesktopMode | TabBoxDesktopListMode
void oneStepThroughDesktops( bool forward, int mode ); // TabBox::Mode::DesktopMode | DesktopListMode
void oneStepThroughDesktops( bool forward );
void oneStepThroughDesktopList( bool forward );
bool establishTabBoxGrab();
@ -501,8 +460,6 @@ class Workspace : public QObject, public KDecorationDefines
// this is the right way to create a new client
Client* createClient( Window w, bool is_mapped );
void addClient( Client* c, allowed_t );
Unmanaged* createUnmanaged( Window w );
void addUnmanaged( Unmanaged* c, allowed_t );
Window findSpecialEventWindow( XEvent* e );
@ -528,22 +485,23 @@ class Workspace : public QObject, public KDecorationDefines
void tabBoxKeyRelease( const XKeyEvent& ev );
// electric borders
void destroyElectricBorders();
bool electricBorderEvent(XEvent * e);
void electricBorderSwitchDesktop( ElectricBorder border, const QPoint& pos );
void checkElectricBorders( bool force = false );
void createBorderWindows();
void destroyBorderWindows();
bool electricBorder(XEvent * e);
void raiseElectricBorders();
// ------------------
void helperDialog( const QString& message, const Client* c );
void calcDesktopLayout(int &x, int &y) const;
QMenu* clientPopup();
void closeActivePopup();
void updateClientArea( bool force );
void finishCompositing();
bool windowRepaintsPending() const;
SystemTrayWindowList systemTrayWins;
int current_desktop;
@ -563,6 +521,7 @@ class Workspace : public QObject, public KDecorationDefines
QList<Rules*> rules;
KXMessages temporaryRulesMessages;
QTimer rulesUpdatedTimer;
bool rules_updates_disabled;
static const char* windowTypeToTxt( NET::WindowType type );
static NET::WindowType txtToWindowType( const char* txt );
static bool sessionInfoWindowTypeMatch( Client* c, SessionInfo* info );
@ -579,12 +538,10 @@ class Workspace : public QObject, public KDecorationDefines
ClientList clients;
ClientList desktops;
UnmanagedList unmanaged;
DeletedList deleted;
ClientList unconstrained_stacking_order;
ClientList stacking_order;
QVector< ClientList > focus_chain;
ClientList unconstrained_stacking_order; // topmost last
ClientList stacking_order; // topmost last
QVector< ClientList > focus_chain; // currently ative last
ClientList global_focus_chain; // this one is only for things like tabbox's MRU
ClientList should_get_focus; // last is most recent
ClientList attention_chain;
@ -618,9 +575,7 @@ class Workspace : public QObject, public KDecorationDefines
QMenu *popup;
QMenu *advanced_popup;
QMenu *trans_popup;
QMenu *desk_popup;
int desk_popup_index;
KActionCollection *keys;
KActionCollection *client_keys;
@ -665,8 +620,12 @@ class Workspace : public QObject, public KDecorationDefines
KStartupInfo* startup;
ElectricBorder electric_current_border;
Window electric_windows[ ELECTRIC_COUNT ];
bool electric_have_borders;
int electric_current_border;
WId electric_top_border;
WId electric_bottom_border;
WId electric_left_border;
WId electric_right_border;
int electricLeft;
int electricRight;
int electricTop;
@ -674,7 +633,6 @@ class Workspace : public QObject, public KDecorationDefines
Time electric_time_first;
Time electric_time_last;
QPoint electric_push_point;
int electric_reserved[ ELECTRIC_COUNT ]; // corners/edges used by something
Qt::Orientation layoutOrientation;
int layoutX;
@ -699,14 +657,12 @@ class Workspace : public QObject, public KDecorationDefines
bool forced_global_mouse_grab;
friend class StackingUpdatesBlocker;
KSelectionOwner* cm_selection;
QTimer compositeTimer;
QTime lastCompositePaint;
int compositeRate;
QRegion repaints_region;
Window overlay; // XComposite overlay window
//kompmgr
QSlider *transSlider;
QPushButton *transButton;
private:
friend bool performTransiencyCheck();
};
// helper for Workspace::blockStackingUpdates() being called in pairs (true/false)
@ -731,7 +687,6 @@ class RootInfo : public NETRootInfo
protected:
virtual void changeNumberOfDesktops(int n);
virtual void changeCurrentDesktop(int d);
// virtual void changeActiveWindow(Window w); the extended version is used
virtual void changeActiveWindow(Window w,NET::RequestSource src, Time timestamp, Window active_window);
virtual void closeWindow(Window w);
virtual void moveResize(Window w, int x_root, int y_root, unsigned long direction);
@ -849,9 +804,10 @@ inline bool Workspace::globalShortcutsDisabled() const
return global_shortcuts_disabled || global_shortcuts_disabled_for_client;
}
inline Window Workspace::overlayWindow()
inline
bool Workspace::rulesUpdatesDisabled() const
{
return overlay;
return rules_updates_disabled;
}
template< typename T >
@ -881,27 +837,7 @@ inline void Workspace::forEachClient( T procedure )
return forEachClient( procedure, TruePredicate());
}
template< typename T >
inline Unmanaged* Workspace::findUnmanaged( T predicate )
{
return findUnmanagedInList( unmanaged, predicate );
}
template< typename T1, typename T2 >
inline void Workspace::forEachUnmanaged( T1 procedure, T2 predicate )
{
for ( UnmanagedList::ConstIterator it = unmanaged.begin(); it != unmanaged.end(); ++it)
if ( predicate( const_cast< const Unmanaged* >( *it)))
procedure( *it );
}
template< typename T >
inline void Workspace::forEachUnmanaged( T procedure )
{
return forEachUnmanaged( procedure, TruePredicate());
}
KWIN_COMPARE_PREDICATE( ClientMatchPredicate, Client, const Client*, cl == value );
KWIN_COMPARE_PREDICATE( ClientMatchPredicate, const Client*, cl == value );
inline bool Workspace::hasClient( const Client* c )
{
return findClient( ClientMatchPredicate( c ));