Merge lp:~3v1n0/unity/panelmenu-on-mousegrab-fixes into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 1771
Proposed branch: lp:~3v1n0/unity/panelmenu-on-mousegrab-fixes
Merge into: lp:unity
Diff against target: 167 lines (+70/-15)
6 files modified
manual-tests/PanelIndicators.txt (+27/-0)
plugins/unityshell/src/PanelIndicatorsView.cpp (+9/-8)
plugins/unityshell/src/PanelIndicatorsView.h (+2/-2)
plugins/unityshell/src/PanelMenuView.cpp (+20/-1)
plugins/unityshell/src/PanelMenuView.h (+2/-0)
plugins/unityshell/src/PanelView.cpp (+10/-4)
To merge this branch: bzr merge lp:~3v1n0/unity/panelmenu-on-mousegrab-fixes
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+83099@code.launchpad.net

Description of the change

Fixing bug #888650 and bug #890970 which caused the global menubar to not correctly react to mouse events when an indicator menu is open.

Since compiz can't get the mouse position when the unity-panel-service grabs the mouse, we need to manually update the mouse position and send it to the menubar to make it correctly draw also when the Nux events aren't emitted.

Tests for this code will come as soon as possible (i.e when the autopilot will be completed).

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Code looks good to me.

One point, can you use the new "nullptr" from the C++11 standard instead of "NULL" please.

Perhaps this will be best tested with autopilot?

Marking as needs fixing until we can find a test for this.

review: Needs Fixing
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Code updated.

Yes, I hope to test this with autopilot.

Revision history for this message
Tim Penhey (thumper) wrote :

Add a manual test, and look to land this.

review: Needs Fixing
Revision history for this message
Tim Penhey (thumper) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'manual-tests/PanelIndicators.txt'
--- manual-tests/PanelIndicators.txt 1970-01-01 00:00:00 +0000
+++ manual-tests/PanelIndicators.txt 2011-12-08 04:53:24 +0000
@@ -0,0 +1,27 @@
1Menus and Active Indicators
2---------------------------
3This test shows the interaction between the global menu and open indicators.
4
5#. Start on a clean screen
6#. Open an application that has menus (i.e a gnome-terminal)
7#. Open an indicator Menu (i.e. indicator sound)
8#. Move the mouse pointer on the PanelMenuGrabArea (i.e the area between the
9 indicators and the global menu)
10
11Outcome
12 The menu should appear. This was happening only when going over the menus,
13 not over the empty panel area.
14
15
16Window Buttons and Active Indicators
17------------------------------------
18This test shows the interaction between the window buttons and open indicators.
19
20#. Start on a clean screen
21#. Open an application that has menus (i.e a gnome-terminal)
22#. Maximize it
23#. Open an indicator Menu (i.e. indicator sound)
24#. Move the mouse pointer on the top-left corner of the screen
25
26Outcome
27 Window buttons should appear.
028
=== modified file 'plugins/unityshell/src/PanelIndicatorsView.cpp'
--- plugins/unityshell/src/PanelIndicatorsView.cpp 2011-10-11 18:18:13 +0000
+++ plugins/unityshell/src/PanelIndicatorsView.cpp 2011-12-08 04:53:24 +0000
@@ -121,19 +121,20 @@
121 entry.second->QueueDraw();121 entry.second->QueueDraw();
122}122}
123123
124bool124PanelIndicatorEntryView*
125PanelIndicatorsView::ActivateEntry(std::string const& entry_id)125PanelIndicatorsView::ActivateEntry(std::string const& entry_id)
126{126{
127 auto entry = entries_.find(entry_id);127 auto entry = entries_.find(entry_id);
128128
129 if (entry != entries_.end() && entry->second->IsEntryValid())129 if (entry != entries_.end() && entry->second->IsEntryValid())
130 {130 {
131 PanelIndicatorEntryView* view = entry->second;
131 LOG_DEBUG(logger) << "Activating: " << entry_id;132 LOG_DEBUG(logger) << "Activating: " << entry_id;
132 entry->second->Activate();133 view->Activate();
133 return true;134 return view;
134 }135 }
135136
136 return false;137 return nullptr;
137}138}
138139
139bool140bool
@@ -163,10 +164,10 @@
163 entry.second->GetGeometryForSync(locations);164 entry.second->GetGeometryForSync(locations);
164}165}
165166
166bool167PanelIndicatorEntryView*
167PanelIndicatorsView::OnPointerMoved(int x, int y)168PanelIndicatorsView::ActivateEntryAt(int x, int y)
168{169{
169 PanelIndicatorEntryView* target = NULL;170 PanelIndicatorEntryView* target = nullptr;
170 bool found_old_active = false;171 bool found_old_active = false;
171172
172 //173 //
@@ -207,7 +208,7 @@
207 }208 }
208 }209 }
209210
210 return (target != NULL);211 return target;
211}212}
212213
213void214void
214215
=== modified file 'plugins/unityshell/src/PanelIndicatorsView.h'
--- plugins/unityshell/src/PanelIndicatorsView.h 2011-11-28 21:27:17 +0000
+++ plugins/unityshell/src/PanelIndicatorsView.h 2011-12-08 04:53:24 +0000
@@ -56,8 +56,8 @@
56 IndicatorEntryType type = IndicatorEntryType::INDICATOR);56 IndicatorEntryType type = IndicatorEntryType::INDICATOR);
57 void RemoveEntry(std::string const& entry_id);57 void RemoveEntry(std::string const& entry_id);
5858
59 bool OnPointerMoved(int x, int y);59 PanelIndicatorEntryView* ActivateEntryAt(int x, int y);
60 bool ActivateEntry(std::string const& entry_id);60 PanelIndicatorEntryView* ActivateEntry(std::string const& entry_id);
61 bool ActivateIfSensitive();61 bool ActivateIfSensitive();
62 void GetGeometryForSync(indicator::EntryLocationMap& locations);62 void GetGeometryForSync(indicator::EntryLocationMap& locations);
6363
6464
=== modified file 'plugins/unityshell/src/PanelMenuView.cpp'
--- plugins/unityshell/src/PanelMenuView.cpp 2011-12-05 14:53:17 +0000
+++ plugins/unityshell/src/PanelMenuView.cpp 2011-12-08 04:53:24 +0000
@@ -1485,5 +1485,24 @@
1485void PanelMenuView::OnPanelViewMouseMove(int x, int y, int dx, int dy, unsigned long mouse_button_state, unsigned long special_keys_state)1485void PanelMenuView::OnPanelViewMouseMove(int x, int y, int dx, int dy, unsigned long mouse_button_state, unsigned long special_keys_state)
1486{}1486{}
14871487
14881488void PanelMenuView::SetMousePosition(int x, int y)
1489{
1490 if (_last_active_view ||
1491 (x >= 0 && y >= 0 && GetAbsoluteGeometry().IsPointInside(x, y)))
1492 {
1493 if (!_is_inside)
1494 {
1495 _is_inside = true;
1496 FullRedraw();
1497 }
1498 }
1499 else
1500 {
1501 if (_is_inside)
1502 {
1503 _is_inside = false;
1504 FullRedraw();
1505 }
1506 }
1507}
1489} // namespace unity1508} // namespace unity
14901509
=== modified file 'plugins/unityshell/src/PanelMenuView.h'
--- plugins/unityshell/src/PanelMenuView.h 2011-11-28 21:27:17 +0000
+++ plugins/unityshell/src/PanelMenuView.h 2011-12-08 04:53:24 +0000
@@ -60,6 +60,8 @@
60 virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);60 virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
61 virtual long PostLayoutManagement(long LayoutResult);61 virtual long PostLayoutManagement(long LayoutResult);
6262
63 void SetMousePosition(int x, int y);
64
63 void OnActiveChanged(PanelIndicatorEntryView* view, bool is_active);65 void OnActiveChanged(PanelIndicatorEntryView* view, bool is_active);
64 void OnActiveWindowChanged(BamfView* old_view, BamfView* new_view);66 void OnActiveWindowChanged(BamfView* old_view, BamfView* new_view);
65 void OnNameChanged(gchar* new_name, gchar* old_name);67 void OnNameChanged(gchar* new_name, gchar* old_name);
6668
=== modified file 'plugins/unityshell/src/PanelView.cpp'
--- plugins/unityshell/src/PanelView.cpp 2011-10-25 16:08:30 +0000
+++ plugins/unityshell/src/PanelView.cpp 2011-12-08 04:53:24 +0000
@@ -465,12 +465,18 @@
465465
466 if (geo.IsPointInside(x, y))466 if (geo.IsPointInside(x, y))
467 {467 {
468 bool ret = false;468 PanelIndicatorEntryView* view = nullptr;
469469
470 if (!_menu_view->HasOurWindowFocused())470 if (!_menu_view->HasOurWindowFocused())
471 ret = _menu_view->OnPointerMoved(x, y);471 view = _menu_view->ActivateEntryAt(x, y);
472472
473 if (!ret) _indicators->OnPointerMoved(x, y);473 if (!view) _indicators->ActivateEntryAt(x, y);
474
475 _menu_view->SetMousePosition(x, y);
476 }
477 else
478 {
479 _menu_view->SetMousePosition(-1, -1);
474 }480 }
475}481}
476482