Merge lp:~osomon/unity-2d/panel-hover-fixes into lp:unity-2d/3.0

Proposed by Olivier Tilloy
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 583
Merged at revision: 584
Proposed branch: lp:~osomon/unity-2d/panel-hover-fixes
Merge into: lp:unity-2d/3.0
Diff against target: 58 lines (+7/-21)
2 files modified
panel/applets/appname/appnameapplet.cpp (+5/-19)
panel/applets/appname/appnameapplet.h (+2/-2)
To merge this branch: bzr merge lp:~osomon/unity-2d/panel-hover-fixes
Reviewer Review Type Date Requested Status
Aurélien Gâteau (community) Needs Fixing
Review via email: mp+63528@code.launchpad.net

Commit message

[panel] Show the current window’s menu only when the mouse cursor hovers over the appname applet, not the whole panel.

Description of the change

This merge request fixes bug #793403 and bug #793406. Both of them are low importance bugs, but they are a blocker for an OEM project based on Unity-2d, so a review of the fix would be very welcome. Thanks!

To post a comment you must log in.
Revision history for this message
Aurélien Gâteau (agateau) wrote :

Looks good, only suggestion would be to simplify the code checking whether the mouse is over the panel. This line:

  && (geometry().contains(window()->mapFromGlobal(QCursor::pos()))

Can be replaced with:

  && (rect().contains(mapFromGlobal(QCursor::pos()))

Feel free to approve and get it merged after this change is done.

review: Needs Fixing
583. By Olivier Tilloy

Simplified the code.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'panel/applets/appname/appnameapplet.cpp'
2--- panel/applets/appname/appnameapplet.cpp 2011-04-26 15:20:08 +0000
3+++ panel/applets/appname/appnameapplet.cpp 2011-06-06 13:12:38 +0000
4@@ -221,7 +221,7 @@
5 bool isUserVisibleApp = app ? app->user_visible() : false;
6 bool isOnSameScreen = d->m_windowHelper->isMostlyOnScreen(QApplication::desktop()->screenNumber(this));
7 bool showMenu = (!d->m_menuBarWidget->isEmpty() && isUserVisibleApp && isOnSameScreen)
8- && (window()->geometry().contains(QCursor::pos())
9+ && (rect().contains(mapFromGlobal(QCursor::pos()))
10 || KeyboardModifiersMonitor::instance()->keyboardModifiers() == Qt::AltModifier
11 || d->m_menuBarWidget->isOpened()
12 );
13@@ -258,26 +258,12 @@
14 d->m_menuBarWidget->setVisible(showMenu);
15 }
16
17-bool AppNameApplet::event(QEvent* event)
18-{
19- if (event->type() == QEvent::ParentChange) {
20- // Install an event filter on the panel to detect mouse over
21- window()->installEventFilter(this);
22- }
23- return Applet::event(event);
24+void AppNameApplet::enterEvent(QEvent*) {
25+ updateWidgets();
26 }
27
28-bool AppNameApplet::eventFilter(QObject*, QEvent* event)
29-{
30- switch (event->type()) {
31- case QEvent::HoverEnter:
32- case QEvent::HoverLeave:
33- updateWidgets();
34- break;
35- default:
36- break;
37- }
38- return false;
39+void AppNameApplet::leaveEvent(QEvent*) {
40+ updateWidgets();
41 }
42
43 } // namespace
44
45=== modified file 'panel/applets/appname/appnameapplet.h'
46--- panel/applets/appname/appnameapplet.h 2011-01-15 01:41:03 +0000
47+++ panel/applets/appname/appnameapplet.h 2011-06-06 13:12:38 +0000
48@@ -41,8 +41,8 @@
49 ~AppNameApplet();
50
51 protected:
52- bool event(QEvent*); // reimp
53- bool eventFilter(QObject*, QEvent*); // reimp
54+ void enterEvent(QEvent*);
55+ void leaveEvent(QEvent*);
56
57 private Q_SLOTS:
58 void updateWidgets();

Subscribers

People subscribed via source and target branches