diff --git a/workspace.cpp b/workspace.cpp index 29b77ca450..dadf2c6b55 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -1614,14 +1614,6 @@ QPopupMenu* Workspace::clientPopup( Client* c ) // PluginMenu *deco = new PluginMenu(mgr, popup); // deco->setFont(KGlobalSettings::menuFont()); - desk_popup = new QPopupMenu( popup ); - desk_popup->setCheckable( TRUE ); - desk_popup->setFont(KGlobalSettings::menuFont()); - connect( desk_popup, SIGNAL( activated(int) ), - this, SLOT( sendToDesktop(int) ) ); - connect( desk_popup, SIGNAL( aboutToShow() ), - this, SLOT( desktopPopupAboutToShow() ) ); - popup->insertItem( SmallIconSet( "move" ), i18n("&Move")+'\t'+keys->shortcut("Window Move").toString(), Options::MoveOp ); popup->insertItem( i18n("&Size")+'\t'+keys->shortcut("Window Resize").toString(), Options::ResizeOp ); popup->insertItem( i18n("Mi&nimize")+'\t'+keys->shortcut("Window Minimize").toString(), Options::IconifyOp ); @@ -1633,7 +1625,6 @@ QPopupMenu* Workspace::clientPopup( Client* c ) popup->insertSeparator(); popup->insertItem(SmallIconSet( "configure" ), i18n("Configur&e..."), this, SLOT( configureWM() )); - popup->insertItem(i18n("&To Desktop"), desk_popup ); popup->insertSeparator(); @@ -1642,6 +1633,22 @@ QPopupMenu* Workspace::clientPopup( Client* c ) return popup; } +void Workspace::initDesktopPopup() +{ + if (desk_popup) + return; + + desk_popup = new QPopupMenu( popup ); + desk_popup->setCheckable( TRUE ); + desk_popup->setFont(KGlobalSettings::menuFont()); + connect( desk_popup, SIGNAL( activated(int) ), + this, SLOT( sendToDesktop(int) ) ); + connect( desk_popup, SIGNAL( aboutToShow() ), + this, SLOT( desktopPopupAboutToShow() ) ); + + popup->insertItem(i18n("To &Desktop"), desk_popup, -1, 8 ); +} + void Workspace::showWindowMenuAt( unsigned long id, int x, int y ) { Client *target = findClient( id ); @@ -3121,6 +3128,7 @@ void Workspace::desktopPopupAboutToShow() { if ( !desk_popup ) return; + desk_popup->clear(); desk_popup->insertItem( i18n("&All Desktops"), 0 ); if ( popup_client && popup_client->isSticky() ) @@ -3155,6 +3163,17 @@ void Workspace::clientPopupAboutToShow() { if ( !popup_client || !popup ) return; + + if ( numberOfDesktops() == 1 ) + { + delete desk_popup; + desk_popup = 0; + } + else + { + initDesktopPopup(); + } + popup->setItemEnabled( Options::ResizeOp, popup_client->isResizable() ); popup->setItemEnabled( Options::MoveOp, popup_client->isMovable() ); popup->setItemEnabled( Options::MaximizeOp, popup_client->isMaximizable() ); diff --git a/workspace.h b/workspace.h index b3256b4b02..80f159cc6d 100644 --- a/workspace.h +++ b/workspace.h @@ -300,6 +300,7 @@ private: void init(); void initShortcuts(); void readShortcuts(); + void initDesktopPopup(); bool startKDEWalkThroughWindows(); bool startWalkThroughDesktops( int mode ); // TabBox::Mode::DesktopMode | DesktopListMode