|
|
106311 |
qt-bugs@ issue : none
|
|
|
106311 |
bugs.kde.org number : none
|
|
|
106311 |
applied: no
|
|
|
106311 |
author: Lubos Lunak <l.lunak@kde.org>
|
|
|
106311 |
Makes QPopupMenu aware of Xinerama (see e.g. https://bugzilla.novell.com/show_bug.cgi?id=216235).
|
|
|
106311 |
|
|
|
106311 |
|
|
|
106311 |
--- src/widgets/qpopupmenu.cpp
|
|
|
106311 |
+++ src/widgets/qpopupmenu.cpp
|
|
|
106311 |
@@ -454,6 +454,15 @@ void QPopupMenu::frameChanged()
|
|
|
106311 |
menuContentsChanged();
|
|
|
106311 |
}
|
|
|
106311 |
|
|
|
106311 |
+QRect QPopupMenu::screenRect( const QPoint& pos )
|
|
|
106311 |
+{
|
|
|
106311 |
+ int screen_num = QApplication::desktop()->screenNumber( pos );
|
|
|
106311 |
+#ifdef Q_WS_MAC
|
|
|
106311 |
+ return QApplication::desktop()->availableGeometry( screen_num );
|
|
|
106311 |
+#else
|
|
|
106311 |
+ return QApplication::desktop()->screenGeometry( screen_num );
|
|
|
106311 |
+#endif
|
|
|
106311 |
+}
|
|
|
106311 |
/*!
|
|
|
106311 |
Displays the popup menu so that the item number \a indexAtPoint
|
|
|
106311 |
will be at the specified \e global position \a pos. To translate a
|
|
|
106311 |
@@ -498,6 +507,15 @@ void QPopupMenu::popup( const QPoint &po
|
|
|
106311 |
// point.
|
|
|
106311 |
#endif
|
|
|
106311 |
|
|
|
106311 |
+ QRect screen = screenRect( geometry().center());
|
|
|
106311 |
+ QRect screen2 = screenRect( QApplication::reverseLayout()
|
|
|
106311 |
+ ? pos+QPoint(width(),0) : pos );
|
|
|
106311 |
+ // if the widget is not in the screen given by the position, move it
|
|
|
106311 |
+ // there, so that updateSize() uses the right size of the screen
|
|
|
106311 |
+ if( screen != screen2 ) {
|
|
|
106311 |
+ screen = screen2;
|
|
|
106311 |
+ move( screen.x(), screen.y());
|
|
|
106311 |
+ }
|
|
|
106311 |
if(d->scroll.scrollable) {
|
|
|
106311 |
d->scroll.scrollable = QPopupMenuPrivate::Scroll::ScrollNone;
|
|
|
106311 |
d->scroll.topScrollableIndex = d->scroll.scrollableSize = 0;
|
|
|
106311 |
@@ -517,18 +535,6 @@ void QPopupMenu::popup( const QPoint &po
|
|
|
106311 |
updateSize(TRUE);
|
|
|
106311 |
}
|
|
|
106311 |
|
|
|
106311 |
- int screen_num;
|
|
|
106311 |
- if (QApplication::desktop()->isVirtualDesktop())
|
|
|
106311 |
- screen_num =
|
|
|
106311 |
- QApplication::desktop()->screenNumber( QApplication::reverseLayout() ?
|
|
|
106311 |
- pos+QPoint(width(),0) : pos );
|
|
|
106311 |
- else
|
|
|
106311 |
- screen_num = QApplication::desktop()->screenNumber( this );
|
|
|
106311 |
-#ifdef Q_WS_MAC
|
|
|
106311 |
- QRect screen = QApplication::desktop()->availableGeometry( screen_num );
|
|
|
106311 |
-#else
|
|
|
106311 |
- QRect screen = QApplication::desktop()->screenGeometry( screen_num );
|
|
|
106311 |
-#endif
|
|
|
106311 |
int sw = screen.width(); // screen width
|
|
|
106311 |
int sh = screen.height(); // screen height
|
|
|
106311 |
int sx = screen.x(); // screen pos
|
|
|
106311 |
@@ -1056,7 +1062,7 @@ QSize QPopupMenu::updateSize(bool force_
|
|
|
106311 |
mi->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 4 );
|
|
|
106311 |
}
|
|
|
106311 |
|
|
|
106311 |
- int dh = QApplication::desktop()->height();
|
|
|
106311 |
+ int dh = screenRect( geometry().center()).height();
|
|
|
106311 |
ncols = 1;
|
|
|
106311 |
|
|
|
106311 |
for ( QMenuItemListIt it2( *mitems ); it2.current(); ++it2 ) {
|
|
|
106311 |
@@ -2297,9 +2303,9 @@ void QPopupMenu::subMenuTimer() {
|
|
|
106311 |
bool right = FALSE;
|
|
|
106311 |
if ( ( parentMenu && parentMenu->isPopupMenu &&
|
|
|
106311 |
((QPopupMenu*)parentMenu)->geometry().x() < geometry().x() ) ||
|
|
|
106311 |
- p.x() < 0 )
|
|
|
106311 |
+ p.x() < screenRect( p ).left())
|
|
|
106311 |
right = TRUE;
|
|
|
106311 |
- if ( right && (ps.width() > QApplication::desktop()->width() - mapToGlobal( r.topRight() ).x() ) )
|
|
|
106311 |
+ if ( right && (ps.width() > screenRect( p ).right() - mapToGlobal( r.topRight() ).x() ) )
|
|
|
106311 |
right = FALSE;
|
|
|
106311 |
if ( right )
|
|
|
106311 |
p.setX( mapToGlobal( r.topRight() ).x() );
|
|
|
106311 |
@@ -2310,7 +2316,7 @@ void QPopupMenu::subMenuTimer() {
|
|
|
106311 |
bool left = FALSE;
|
|
|
106311 |
if ( ( parentMenu && parentMenu->isPopupMenu &&
|
|
|
106311 |
((QPopupMenu*)parentMenu)->geometry().x() > geometry().x() ) ||
|
|
|
106311 |
- p.x() + ps.width() > QApplication::desktop()->width() )
|
|
|
106311 |
+ p.x() + ps.width() > screenRect( p ).right() )
|
|
|
106311 |
left = TRUE;
|
|
|
106311 |
if ( left && (ps.width() > mapToGlobal( r.topLeft() ).x() ) )
|
|
|
106311 |
left = FALSE;
|
|
|
106311 |
@@ -2318,8 +2324,8 @@ void QPopupMenu::subMenuTimer() {
|
|
|
106311 |
p.setX( mapToGlobal( r.topLeft() ).x() - ps.width() );
|
|
|
106311 |
}
|
|
|
106311 |
QRect pr = popup->itemGeometry(popup->count() - 1);
|
|
|
106311 |
- if (p.y() + ps.height() > QApplication::desktop()->height() &&
|
|
|
106311 |
- p.y() - ps.height() + (QCOORD) pr.height() >= 0)
|
|
|
106311 |
+ if (p.y() + ps.height() > screenRect( p ).bottom() &&
|
|
|
106311 |
+ p.y() - ps.height() + (QCOORD) pr.height() >= screenRect( p ).top())
|
|
|
106311 |
p.setY( p.y() - ps.height() + (QCOORD) pr.height());
|
|
|
106311 |
|
|
|
106311 |
if ( style().styleHint(QStyle::SH_PopupMenu_SloppySubMenus, this )) {
|
|
|
106311 |
Index: src/widgets/qpopupmenu.h
|
|
|
106311 |
===================================================================
|
|
|
106311 |
--- src/widgets/qpopupmenu.h (revision 636368)
|
|
|
106311 |
+++ src/widgets/qpopupmenu.h (working copy)
|
|
|
106311 |
@@ -152,6 +152,7 @@ private:
|
|
|
106311 |
|
|
|
106311 |
QSize updateSize(bool force_recalc=FALSE, bool do_resize=TRUE);
|
|
|
106311 |
void updateRow( int row );
|
|
|
106311 |
+ QRect screenRect(const QPoint& pos);
|
|
|
106311 |
#ifndef QT_NO_ACCEL
|
|
|
106311 |
void updateAccel( QWidget * );
|
|
|
106311 |
void enableAccel( bool );
|