diff --git a/widgets/widget.cpp b/widgets/widget.cpp index fc352fb36..64cc268a9 100644 --- a/widgets/widget.cpp +++ b/widgets/widget.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include @@ -581,8 +582,14 @@ QPoint Widget::popupPosition(const QSize s) const } } - if (pos.rx() + s.width() > view()->width()) { - pos.rx() -= ((pos.rx() + s.width()) - view()->width()); + //are we out of screen? + QRect screenRect = QApplication::desktop()->screenGeometry(pv->containment()->screen()); + + if (pos.rx() + s.width() > screenRect.width()) { + pos.rx() -= ((pos.rx() + s.width()) - screenRect.width()); + } + if (pos.ry() + s.height() > screenRect.height()) { + pos.ry() -= ((pos.ry() + s.height()) - screenRect.height()); } return pos;