LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File 0059-qpopup_has_mouse.patch of Package qt3 (Project openSUSE:Factory)

qt-bugs@ issue : 49417
bugs.kde.org number : 58719
applied: no
author: Lubos Lunak <l.lunak@kde.org>

Hello,

 please consider applying the two attached QPopupMenu patches fixing KDE bugs 
 #58719 and #74778 (http://bugs.kde.org/show_bug.cgi?id=58719, 
 http://bugs.kde.org/show_bug.cgi?id=74778), which complain about keyboard 
 navigation in popup menus being very uncomfortable because of being affected 
 by mouse position despite mouse not being used at all.
 
 - hasmouse.patch - (#58719) - use keyboard to open and navigate in any popup 
 menu and "accidentally" hit your mouse. Depending on the mouse cursor 
 position either no popup entry is selected or the random popup entry 
 happening to be at the cursor position becomes highlighted. The patch 
 basically copies the 'hasmouse' code from QMenuBar which prevents the mouse 
 having any effect on the popup if it's outside the popup geometry.

 [ ... #74778 ... ] 
 
================================================================================
--- src/widgets/qpopupmenu.cpp
+++ src/widgets/qpopupmenu.cpp
@@ -253,6 +253,7 @@
     } scroll;
     QSize calcSize;
     QRegion mouseMoveBuffer;
+    uint hasmouse : 1;
 };
 
 static QPopupMenu* active_popup_menu = 0;
@@ -272,6 +273,7 @@
     d->scroll.scrollableSize = d->scroll.topScrollableIndex = 0;
     d->scroll.scrollable = QPopupMenuPrivate::Scroll::ScrollNone;
     d->scroll.scrolltimer = 0;
+    d->hasmouse = 0;
     isPopupMenu	  = TRUE;
 #ifndef QT_NO_ACCEL
     autoaccel	  = 0;
@@ -1741,6 +1743,11 @@
 
     int	 item = itemAtPos( e->pos() );
     if ( item == -1 ) {				// no valid item
+        if( !d->hasmouse ) {
+            tryMenuBar( e );
+            return;
+        }
+        d->hasmouse = 0;
 	int lastActItem = actItem;
 	actItem = -1;
 	if ( lastActItem >= 0 )
@@ -1752,6 +1759,7 @@
 	}
     } else {					// mouse on valid item
 	// but did not register mouse press
+        d->hasmouse = 1;
 	if ( (e->state() & Qt::MouseButtonMask) && !mouseBtDn )
 	    mouseBtDn = TRUE; // so mouseReleaseEvent will pop down
 
@@ -2160,6 +2168,7 @@
 */
 void QPopupMenu::leaveEvent( QEvent * )
 {
+    d->hasmouse = 0;
     if ( testWFlags( WStyle_Tool ) && style().styleHint(QStyle::SH_PopupMenu_MouseTracking, this) ) {
 	int lastActItem = actItem;
 	actItem = -1;