summaryrefslogtreecommitdiff
blob: 65a336d64bcd11e7eb6dc4bbe20f7968555ed91d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
qt-bugs@ issue : 20185
applied: no
author: Lubos Lunak <l.lunak@kde.org>

Original version rejected (it looked a bit scary ;) ), I got no reply for
this one yet.

--- src/widgets/qmenubar.cpp.sav	2003-03-04 16:05:44.000000000 +0100
+++ src/widgets/qmenubar.cpp	2003-05-06 17:09:18.000000000 +0200
@@ -1029,12 +1029,18 @@ QRect QMenuBar::itemRect( int index )
   it is a separator item.
 */
 
-int QMenuBar::itemAtPos( const QPoint &pos )
+int QMenuBar::itemAtPos( const QPoint &pos_ )
 {
     calculateRects();
     if ( !irects )
 	return -1;
     int i = 0;
+    QPoint pos = pos_;
+    // Fitts' Law for edges - compensate for the extra margin
+    // added in calculateRects()
+    const int margin = 2;
+    pos.setX( QMAX( margin, QMIN( width() - margin, pos.x())));
+    pos.setY( QMAX( margin, QMIN( height() - margin, pos.y())));
     while ( i < (int)mitems->count() ) {
 	if ( !irects[i].isEmpty() && irects[i].contains( pos ) ) {
 	    QMenuItem *mi = mitems->at(i);