diff --git a/useractions.cpp b/useractions.cpp index c8cff30552..a50178256f 100755 --- a/useractions.cpp +++ b/useractions.cpp @@ -214,6 +214,7 @@ void Workspace::discardPopup() delete popup; popup = NULL; desk_popup = NULL; + screen_popup = NULL; activity_popup = NULL; switch_to_tab_popup = NULL; add_tabs_popup = NULL; @@ -251,6 +252,12 @@ void Workspace::clientPopupAboutToShow() } else { initDesktopPopup(); } + if (numScreens() == 1 || (!active_popup_client->isMovable() && !active_popup_client->isMovableAcrossScreens())) { + delete screen_popup; + screen_popup = NULL; + } else { + initScreenPopup(); + } #ifdef KWIN_BUILD_ACTIVITIES updateActivityList(true, false, "showHideActivityMenu"); #endif @@ -407,6 +414,23 @@ void Workspace::initDesktopPopup() action->setText(i18n("Move To &Desktop")); } +void Workspace::initScreenPopup() +{ + if (screen_popup) { + return; + } + + screen_popup = new QMenu(popup); + screen_popup->setFont(KGlobalSettings::menuFont()); + connect(screen_popup, SIGNAL(triggered(QAction*)), SLOT(slotSendToScreen(QAction*))); + connect(screen_popup, SIGNAL(aboutToShow()), SLOT(screenPopupAboutToShow())); + + QAction *action = screen_popup->menuAction(); + // set it as the first item after desktop + popup->insertAction(activity_popup ? activity_popup->menuAction() : mMinimizeOpAction, action); + action->setText(i18n("Move To &Screen")); +} + /*! Creates activity popup. I'm going with checkable ones instead of "copy to" and "move to" menus; I *think* it's an easier way. @@ -474,6 +498,33 @@ void Workspace::desktopPopupAboutToShow() action->setEnabled(false); } +/*! + Adjusts the screen popup to the current values and the location of + the popup client. + */ +void Workspace::screenPopupAboutToShow() +{ + if (!screen_popup) { + return; + } + + screen_popup->clear(); + QActionGroup *group = new QActionGroup(screen_popup); + + for (int i = 0; iaddAction(i18nc("@item:inmenu List of all Screens to send a window to", + "Screen &%1", (i+1))); + action->setData(i); + action->setCheckable(true); + if (active_popup_client && i == active_popup_client->screen()) { + action->setChecked(true); + } + group->addAction(action); + } +} + /*! Adjusts the activity popup to the current values and the location of the popup client. @@ -1403,6 +1454,24 @@ void Workspace::slotSendToDesktop(QAction *action) } +/*! + Sends the popup client to screen \a screen + + Internal slot for the window operation menu + */ +void Workspace::slotSendToScreen(QAction *action) +{ + const int screen = action->data().toInt(); + if (!active_popup_client) { + return; + } + if (screen >= numScreens()) { + return; + } + + sendClientToScreen(active_popup_client, screen); +} + /*! Toggles whether the popup client is on the \a activity diff --git a/workspace.cpp b/workspace.cpp index a0cef15807..cf3f308a86 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -131,6 +131,7 @@ Workspace::Workspace(bool restore) , popup(0) , advanced_popup(0) , desk_popup(0) + , screen_popup(NULL) , activity_popup(0) , add_tabs_popup(0) , switch_to_tab_popup(0) diff --git a/workspace.h b/workspace.h index a21c7f8313..16630f7569 100644 --- a/workspace.h +++ b/workspace.h @@ -633,9 +633,11 @@ private slots: void entabPopupClient(QAction*); void selectPopupClientTab(QAction*); void desktopPopupAboutToShow(); + void screenPopupAboutToShow(); void activityPopupAboutToShow(); void clientPopupAboutToShow(); void slotSendToDesktop(QAction*); + void slotSendToScreen(QAction*); void slotToggleOnActivity(QAction*); void clientPopupActivated(QAction*); void configureWM(); @@ -716,6 +718,7 @@ private: void init(); void initShortcuts(); void initDesktopPopup(); + void initScreenPopup(); void initActivityPopup(); void initTabbingPopups(); void restartKWin(const QString &reason); @@ -843,6 +846,7 @@ private: QMenu* popup; QMenu* advanced_popup; QMenu* desk_popup; + QMenu* screen_popup; QMenu* activity_popup; QMenu* add_tabs_popup; // Menu to add the group to other group QMenu* switch_to_tab_popup; // Menu to change tab