From 40a2bebe67611694b1faa68e8953a6ef53ab23de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sun, 28 Mar 2010 09:02:10 +0000 Subject: [PATCH] Ensure that width*height is not smaller than the number of desktops when setting a new layout. svn path=/trunk/KDE/kdebase/workspace/; revision=1108238 --- desktoplayout.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/desktoplayout.cpp b/desktoplayout.cpp index 89f70aa142..ef87043501 100644 --- a/desktoplayout.cpp +++ b/desktoplayout.cpp @@ -32,7 +32,6 @@ void Workspace::updateDesktopLayout() int height = rootInfo->desktopLayoutColumnsRows().height(); if( width == 0 && height == 0 ) // Not given, set default layout height = 2; - // TODO: Make sure desktopCount_ <= width * height setNETDesktopLayout( rootInfo->desktopLayoutOrientation() == NET::OrientationHorizontal ? Qt::Horizontal : Qt::Vertical, width, height, 0 //rootInfo->desktopLayoutCorner() // Not really worth implementing right now. @@ -50,6 +49,13 @@ void Workspace::setNETDesktopLayout( Qt::Orientation orientation, int width, int width = ( desktopCount_ + height - 1 ) / height; else if(( height <= 0 ) && ( width > 0 )) height = ( desktopCount_ + width - 1 ) / width; + while( width * height < desktopCount_ ) + { + if( orientation == Qt::Horizontal ) + ++width; + else + ++height; + } // Set private variables delete[] desktopGrid_;