From a00c06c71a1d08aed006110e26c5219f43476362 Mon Sep 17 00:00:00 2001 From: Lucas Murray Date: Mon, 14 Dec 2009 12:29:48 +0000 Subject: [PATCH] If two windows cannot be on the same desktop then don't allow them to be grouped. BUG: 217434 svn path=/trunk/KDE/kdebase/workspace/; revision=1062353 --- clientgroup.cpp | 17 +++++++++++++---- workspace.cpp | 1 - 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/clientgroup.cpp b/clientgroup.cpp index d7e1d14b06..bec3a9c629 100644 --- a/clientgroup.cpp +++ b/clientgroup.cpp @@ -52,8 +52,12 @@ void ClientGroup::add( Client* c, int before, bool becomeVisible ) if( contains( c ) || !c->workspace()->decorationSupportsClientGrouping() ) return; - // Client must not already be grouped - assert( !c->clientGroup() || c->clientGroup()->clients().size() == 1 ); + // If it's not possible to move both windows on to the same desktop then ungroup them + // We do this here as the ungroup code in updateStates() cannot be called until add() completes + if( c->desktop() != clients_[visible_]->desktop() ) + c->setDesktop( clients_[visible_]->desktop() ); + if( c->desktop() != clients_[visible_]->desktop() ) + return; // Tabbed windows MUST have a decoration if( c->noBorder() ) @@ -66,8 +70,9 @@ void ClientGroup::add( Client* c, int before, bool becomeVisible ) static_cast(effects)->clientGroupItemAdded( c->effectWindow(), clients_[visible_]->effectWindow() ); - // Delete old group and update - delete c->clientGroup(); // Delete old group as it's now empty + // Remove from old group and update + if( c->clientGroup() ) + c->clientGroup()->remove( c ); c->setClientGroup( this ); // Let the client know which group it belongs to // Actually add to new group @@ -236,6 +241,10 @@ void ClientGroup::updateStates( Client* main, Client* only ) (*i)->setKeepAbove( main->keepAbove() ); if( (*i)->keepBelow() != main->keepBelow() ) (*i)->setKeepBelow( main->keepBelow() ); + + // If it's not possible to move both windows on to the same desktop then ungroup them + if( (*i)->desktop() != main->desktop() ) + remove( *i ); } } diff --git a/workspace.cpp b/workspace.cpp index 428289cc9d..84c960f589 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -2874,7 +2874,6 @@ void Workspace::moveItemToClientGroup( ClientGroup* oldGroup, int oldIndex, ClientGroup* group, int index ) { Client* c = oldGroup->clients().at( oldIndex ); - oldGroup->remove( c ); group->add( c, index, true ); }