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

Proposed by Marco Trevisan (Treviño) on 2011-11-23
Status: Merged
Approved by: Tim Penhey on 2011-12-08
Approved revision: 1743
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) 2011-11-23 Approve on 2011-12-08
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.
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
Marco Trevisan (Treviño) (3v1n0) wrote :

Code updated.

Yes, I hope to test this with autopilot.

1741. By Marco Trevisan (Treviño) on 2011-11-24

PanelView and PanelIndicatorsView: Using C++11 nullptr instead of NULL

Tim Penhey (thumper) wrote :

Add a manual test, and look to land this.

review: Needs Fixing
1742. By Marco Trevisan (Treviño) on 2011-12-08

Merging with upstream.

1743. By Marco Trevisan (Treviño) on 2011-12-08

Manual Tests: added manual test for testing the PanelMenuView on mouse grabbed by indicators

Tim Penhey (thumper) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'manual-tests/PanelIndicators.txt'
2--- manual-tests/PanelIndicators.txt 1970-01-01 00:00:00 +0000
3+++ manual-tests/PanelIndicators.txt 2011-12-08 04:53:24 +0000
4@@ -0,0 +1,27 @@
5+Menus and Active Indicators
6+---------------------------
7+This test shows the interaction between the global menu and open indicators.
8+
9+#. Start on a clean screen
10+#. Open an application that has menus (i.e a gnome-terminal)
11+#. Open an indicator Menu (i.e. indicator sound)
12+#. Move the mouse pointer on the PanelMenuGrabArea (i.e the area between the
13+ indicators and the global menu)
14+
15+Outcome
16+ The menu should appear. This was happening only when going over the menus,
17+ not over the empty panel area.
18+
19+
20+Window Buttons and Active Indicators
21+------------------------------------
22+This test shows the interaction between the window buttons and open indicators.
23+
24+#. Start on a clean screen
25+#. Open an application that has menus (i.e a gnome-terminal)
26+#. Maximize it
27+#. Open an indicator Menu (i.e. indicator sound)
28+#. Move the mouse pointer on the top-left corner of the screen
29+
30+Outcome
31+ Window buttons should appear.
32
33=== modified file 'plugins/unityshell/src/PanelIndicatorsView.cpp'
34--- plugins/unityshell/src/PanelIndicatorsView.cpp 2011-10-11 18:18:13 +0000
35+++ plugins/unityshell/src/PanelIndicatorsView.cpp 2011-12-08 04:53:24 +0000
36@@ -121,19 +121,20 @@
37 entry.second->QueueDraw();
38 }
39
40-bool
41+PanelIndicatorEntryView*
42 PanelIndicatorsView::ActivateEntry(std::string const& entry_id)
43 {
44 auto entry = entries_.find(entry_id);
45
46 if (entry != entries_.end() && entry->second->IsEntryValid())
47 {
48+ PanelIndicatorEntryView* view = entry->second;
49 LOG_DEBUG(logger) << "Activating: " << entry_id;
50- entry->second->Activate();
51- return true;
52+ view->Activate();
53+ return view;
54 }
55
56- return false;
57+ return nullptr;
58 }
59
60 bool
61@@ -163,10 +164,10 @@
62 entry.second->GetGeometryForSync(locations);
63 }
64
65-bool
66-PanelIndicatorsView::OnPointerMoved(int x, int y)
67+PanelIndicatorEntryView*
68+PanelIndicatorsView::ActivateEntryAt(int x, int y)
69 {
70- PanelIndicatorEntryView* target = NULL;
71+ PanelIndicatorEntryView* target = nullptr;
72 bool found_old_active = false;
73
74 //
75@@ -207,7 +208,7 @@
76 }
77 }
78
79- return (target != NULL);
80+ return target;
81 }
82
83 void
84
85=== modified file 'plugins/unityshell/src/PanelIndicatorsView.h'
86--- plugins/unityshell/src/PanelIndicatorsView.h 2011-11-28 21:27:17 +0000
87+++ plugins/unityshell/src/PanelIndicatorsView.h 2011-12-08 04:53:24 +0000
88@@ -56,8 +56,8 @@
89 IndicatorEntryType type = IndicatorEntryType::INDICATOR);
90 void RemoveEntry(std::string const& entry_id);
91
92- bool OnPointerMoved(int x, int y);
93- bool ActivateEntry(std::string const& entry_id);
94+ PanelIndicatorEntryView* ActivateEntryAt(int x, int y);
95+ PanelIndicatorEntryView* ActivateEntry(std::string const& entry_id);
96 bool ActivateIfSensitive();
97 void GetGeometryForSync(indicator::EntryLocationMap& locations);
98
99
100=== modified file 'plugins/unityshell/src/PanelMenuView.cpp'
101--- plugins/unityshell/src/PanelMenuView.cpp 2011-12-05 14:53:17 +0000
102+++ plugins/unityshell/src/PanelMenuView.cpp 2011-12-08 04:53:24 +0000
103@@ -1485,5 +1485,24 @@
104 void PanelMenuView::OnPanelViewMouseMove(int x, int y, int dx, int dy, unsigned long mouse_button_state, unsigned long special_keys_state)
105 {}
106
107-
108+void PanelMenuView::SetMousePosition(int x, int y)
109+{
110+ if (_last_active_view ||
111+ (x >= 0 && y >= 0 && GetAbsoluteGeometry().IsPointInside(x, y)))
112+ {
113+ if (!_is_inside)
114+ {
115+ _is_inside = true;
116+ FullRedraw();
117+ }
118+ }
119+ else
120+ {
121+ if (_is_inside)
122+ {
123+ _is_inside = false;
124+ FullRedraw();
125+ }
126+ }
127+}
128 } // namespace unity
129
130=== modified file 'plugins/unityshell/src/PanelMenuView.h'
131--- plugins/unityshell/src/PanelMenuView.h 2011-11-28 21:27:17 +0000
132+++ plugins/unityshell/src/PanelMenuView.h 2011-12-08 04:53:24 +0000
133@@ -60,6 +60,8 @@
134 virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
135 virtual long PostLayoutManagement(long LayoutResult);
136
137+ void SetMousePosition(int x, int y);
138+
139 void OnActiveChanged(PanelIndicatorEntryView* view, bool is_active);
140 void OnActiveWindowChanged(BamfView* old_view, BamfView* new_view);
141 void OnNameChanged(gchar* new_name, gchar* old_name);
142
143=== modified file 'plugins/unityshell/src/PanelView.cpp'
144--- plugins/unityshell/src/PanelView.cpp 2011-10-25 16:08:30 +0000
145+++ plugins/unityshell/src/PanelView.cpp 2011-12-08 04:53:24 +0000
146@@ -465,12 +465,18 @@
147
148 if (geo.IsPointInside(x, y))
149 {
150- bool ret = false;
151+ PanelIndicatorEntryView* view = nullptr;
152
153 if (!_menu_view->HasOurWindowFocused())
154- ret = _menu_view->OnPointerMoved(x, y);
155-
156- if (!ret) _indicators->OnPointerMoved(x, y);
157+ view = _menu_view->ActivateEntryAt(x, y);
158+
159+ if (!view) _indicators->ActivateEntryAt(x, y);
160+
161+ _menu_view->SetMousePosition(x, y);
162+ }
163+ else
164+ {
165+ _menu_view->SetMousePosition(-1, -1);
166 }
167 }
168