From 612864aed24695bb3765a33b91309d2d4b4d9fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 24 May 2010 08:00:59 +0000 Subject: [PATCH] An tabbox item may never be bigger than the screen. BUG: 235143 svn path=/trunk/KDE/kdebase/workspace/; revision=1130011 --- tabbox/clientitemdelegate.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tabbox/clientitemdelegate.cpp b/tabbox/clientitemdelegate.cpp index e6de1244ec..7b062e6725 100644 --- a/tabbox/clientitemdelegate.cpp +++ b/tabbox/clientitemdelegate.cpp @@ -25,6 +25,7 @@ along with this program. If not, see . // Qt #include // KDE +#include #include #include #include @@ -58,7 +59,6 @@ void ClientItemDelegate::setConfig(const KWin::TabBox::ItemLayoutConfig& config) QSize ClientItemDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const { - Q_UNUSED( option ) if( !index.isValid() ) return QSize( 0, 0 ); @@ -97,6 +97,18 @@ QSize ClientItemDelegate::sizeHint( const QStyleOptionViewItem& option, const QM height = qMax( height, element.iconSize().height() ); } } + if (!option.rect.isValid()) + { + // item may not be bigger than the screen geometry + const QRect screenRect = Kephal::ScreenUtils::screenGeometry( tabBox->activeScreen() ); + width = qMin( width, qreal(screenRect.width()) ); + height = qMin( height, qreal(screenRect.height()) ); + } + else + { + width = qMin( width, qreal(option.rect.width()) ); + height = qMin( height, qreal(option.rect.height()) ); + } return QSize( width + left + right, height + top + bottom ); }