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 ); }