Commit 18c201cf authored by Will Stephenson's avatar Will Stephenson

Fix drag and drop from taskbar to activity pager

The code to handle a window drag from the taskbar to drop on the
Activity Pager to add the window to an Activity was broken,
because the test to see if the drop location is a running activity
still treated the itemId as an integer indexing into an array of running
activity indices, rather than an id string that could be a member of the
list of running activities.

It is not clear whether this is a bug fix or
a new feature.  The drop handler in PagerModel.cpp I amended is not used
when DnDing windows within the pager, but may have been used for that at
one point.

This also allows the familiar file manager semantics of ctrl+drag = copy,
drag = move to be used when dragging and dropping windows between
activities using the taskbar and the activity pager applet.
parent b7ee203d
......@@ -398,7 +398,7 @@ MouseArea {
onDrop: {
pagerModel.drop(event.mimeData, desktop.desktopId);
pagerModel.drop(event.mimeData, event.modifiers, desktop.desktopId);
root.dragSwitchDesktopIndex = -1;
......@@ -574,7 +574,7 @@ void PagerModel::changePage(int page)
void PagerModel::drop(QMimeData *mimeData, const QVariant &itemId)
void PagerModel::drop(QMimeData *mimeData, int modifiers, const QVariant &itemId)
if (!mimeData) {
......@@ -595,23 +595,27 @@ void PagerModel::drop(QMimeData *mimeData, const QVariant &itemId)
KWindowSystem::setOnDesktop(id, itemId.toInt());
} else {
QString newActivity;
QString newActivity = itemId.toString();
const QStringList &runningActivities = d->activityInfo->runningActivities();
if (itemId < runningActivities.length()) {
newActivity = itemId.toString();
if (newActivity.isEmpty()) {
if (!runningActivities.contains(newActivity)) {
for (const auto &id : ids) {
QStringList activities = KWindowInfo(id, NET::Properties(), NET::WM2Activities).activities();
if (!activities.contains(newActivity)) {
KWindowSystem::setOnActivities(id, activities << newActivity);
if (modifiers & Qt::ControlModifier) { // 'copy' => add to activity
if (!activities.contains(newActivity))
activities << newActivity;
} else { // 'move' to activity
// if on only one activity, set it to only the new activity
// if on >1 activity, remove it from the current activity and add it to the new activity
const QString currentActivity = d->activityInfo->currentActivity();
activities << newActivity;
KWindowSystem::setOnActivities(id, activities);
......@@ -103,7 +103,7 @@ public:
Q_INVOKABLE void moveWindow(int window, double x, double y, const QVariant &targetItemId, const QVariant &sourceItemId,
qreal widthScaleFactor, qreal heightScaleFactor);
Q_INVOKABLE void changePage(int page);
Q_INVOKABLE void drop(QMimeData *mimeData, const QVariant &itemId);
Q_INVOKABLE void drop(QMimeData *mimeData, int modifiers, const QVariant &itemId);
Q_INVOKABLE void addDesktop();
Q_INVOKABLE void removeDesktop();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment