Merge lp:~3v1n0/unity/secondary-activate-support into lp:unity

Proposed by Marco Trevisan (Treviño) on 2011-07-19
Status: Merged
Approved by: Mirco Müller on 2011-07-21
Approved revision: no longer in the source branch.
Merged at revision: 1316
Proposed branch: lp:~3v1n0/unity/secondary-activate-support
Merge into: lp:unity
Diff against target: 290 lines (+91/-6)
12 files modified
UnityCore/DBusIndicators.cpp (+16/-0)
UnityCore/DBusIndicators.h (+2/-0)
UnityCore/Indicator.cpp (+7/-0)
UnityCore/Indicator.h (+2/-0)
UnityCore/IndicatorEntry.cpp (+5/-0)
UnityCore/IndicatorEntry.h (+2/-0)
UnityCore/Indicators.cpp (+1/-0)
UnityCore/Indicators.h (+2/-0)
plugins/unityshell/src/PanelIndicatorObjectEntryView.cpp (+19/-4)
services/panel-main.c (+16/-0)
services/panel-service.c (+15/-2)
services/panel-service.h (+4/-0)
To merge this branch: bzr merge lp:~3v1n0/unity/secondary-activate-support
Reviewer Review Type Date Requested Status
Mirco Müller (community) 2011-07-19 Approve on 2011-07-21
Review via email: mp+68394@code.launchpad.net

Description of the change

Add support to "secondary-activate" event on middle-click, needed both by bug #609860 and bug #812933. See the second for more informations.

This needs the merge of lp:~3v1n0/libindicator/secondary-activate-support

To post a comment you must log in.
Mirco Müller (macslow) wrote :

All good seen from here. Approved.

review: Approve
Mirco Müller (macslow) wrote :

I've not merged this yet to trunk as it needs some stuff to move into libindicator first. Locally I tried this and it works ok.

Marco Trevisan (Treviño) (3v1n0) wrote :

Yes, it just needs support from the low-level, I just hope that the fact of exporting the X/Y mouse position (that I did for following the StatusNotifierItem specs) is accepted by ted :P.

1272. By Marco Trevisan (Treviño) on 2011-07-21

Merging with Upstream

1273. By Marco Trevisan (Treviño) on 2011-07-21

Merging with Upstream

1274. By Marco Trevisan (Treviño) on 2011-07-21

Indicator: Don't use anymore the x,y position on secondary-activation

All the tree is updated to use the new signal.

1275. By Marco Trevisan (Treviño) on 2011-07-21

Merging branches (upstream and local)

Marco Trevisan (Treviño) (3v1n0) wrote :

I've changed the branch to sync with the change of libindicator that doesn't support the x,y mouse position when sending a secondary-activate signal.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UnityCore/DBusIndicators.cpp'
2--- UnityCore/DBusIndicators.cpp 2011-07-21 14:59:25 +0000
3+++ UnityCore/DBusIndicators.cpp 2011-07-21 20:27:23 +0000
4@@ -122,6 +122,8 @@
5 virtual void OnEntryScroll(std::string const& entry_id, int delta);
6 virtual void OnEntryShowMenu(std::string const& entry_id,
7 int x, int y, int timestamp, int button);
8+ virtual void OnEntrySecondaryActivate(std::string const& entry_id,
9+ unsigned int timestamp);
10
11 std::string name() const;
12 std::string owner_name() const;
13@@ -226,6 +228,14 @@
14 g_timeout_add(0, (GSourceFunc)send_show_entry, data);
15 }
16
17+void DBusIndicators::Impl::OnEntrySecondaryActivate(std::string const& entry_id,
18+ unsigned int timestamp)
19+{
20+ g_dbus_proxy_call(proxy_, "SecondaryActivateEntry",
21+ g_variant_new("(su)", entry_id.c_str(), timestamp),
22+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
23+}
24+
25 void DBusIndicators::Impl::OnEntryScroll(std::string const& entry_id, int delta)
26 {
27 g_dbus_proxy_call(proxy_, "ScrollEntry",
28@@ -474,6 +484,12 @@
29 pimpl->OnEntryShowMenu(entry_id, x, y, timestamp, button);
30 }
31
32+void DBusIndicators::OnEntrySecondaryActivate(std::string const& entry_id,
33+ unsigned int timestamp)
34+{
35+ pimpl->OnEntrySecondaryActivate(entry_id, timestamp);
36+}
37+
38 std::string DBusIndicators::name() const
39 {
40 return pimpl->name();
41
42=== modified file 'UnityCore/DBusIndicators.h'
43--- UnityCore/DBusIndicators.h 2011-07-21 14:59:25 +0000
44+++ UnityCore/DBusIndicators.h 2011-07-21 20:27:23 +0000
45@@ -44,6 +44,8 @@
46 virtual void OnEntryScroll(std::string const& entry_id, int delta);
47 virtual void OnEntryShowMenu(std::string const& entry_id,
48 int x, int y, int timestamp, int button);
49+ virtual void OnEntrySecondaryActivate(std::string const& entry_id,
50+ unsigned int timestamp);
51
52 std::string name() const;
53 std::string owner_name() const;
54
55=== modified file 'UnityCore/Indicator.cpp'
56--- UnityCore/Indicator.cpp 2011-07-21 14:59:25 +0000
57+++ UnityCore/Indicator.cpp 2011-07-21 20:27:23 +0000
58@@ -56,6 +56,7 @@
59 Entry::Ptr new_entry = new_entries[new_index];
60 entries_.push_back(new_entry);
61 new_entry->on_show_menu.connect(sigc::mem_fun(this, &Indicator::OnEntryShowMenu));
62+ new_entry->on_secondary_activate.connect(sigc::mem_fun(this, &Indicator::OnEntrySecondaryActivate));
63 new_entry->on_scroll.connect(sigc::mem_fun(this, &Indicator::OnEntryScroll));
64 on_entry_added.emit(new_entry);
65 }
66@@ -86,6 +87,12 @@
67 on_show_menu.emit(entry_id, x, y, timestamp, button);
68 }
69
70+void Indicator::OnEntrySecondaryActivate(std::string const& entry_id,
71+ unsigned int timestamp)
72+{
73+ on_secondary_activate.emit(entry_id, timestamp);
74+}
75+
76 void Indicator::OnEntryScroll(std::string const& entry_id, int delta)
77 {
78 on_scroll.emit(entry_id, delta);
79
80=== modified file 'UnityCore/Indicator.h'
81--- UnityCore/Indicator.h 2011-07-21 14:59:25 +0000
82+++ UnityCore/Indicator.h 2011-07-21 20:27:23 +0000
83@@ -45,11 +45,13 @@
84 Entry::Ptr GetEntry(std::string const& entry_id) const;
85
86 void OnEntryShowMenu(std::string const& entry_id, int x, int y, int timestamp, int button);
87+ void OnEntrySecondaryActivate(std::string const& entry_id, unsigned int timestamp);
88 void OnEntryScroll(std::string const& entry_id, int delta);
89
90 // Signals
91 sigc::signal<void, Entry::Ptr const&> on_entry_added;
92 sigc::signal<void, std::string const&, int, int, int, int> on_show_menu;
93+ sigc::signal<void, std::string const&, unsigned int> on_secondary_activate;
94 sigc::signal<void, std::string const&, int> on_scroll;
95
96 private:
97
98=== modified file 'UnityCore/IndicatorEntry.cpp'
99--- UnityCore/IndicatorEntry.cpp 2011-07-21 14:59:25 +0000
100+++ UnityCore/IndicatorEntry.cpp 2011-07-21 20:27:23 +0000
101@@ -157,6 +157,11 @@
102 on_show_menu.emit(id_, x, y, timestamp, button);
103 }
104
105+void Entry::SecondaryActivate(unsigned int timestamp)
106+{
107+ on_secondary_activate.emit(id_, timestamp);
108+}
109+
110 void Entry::Scroll(int delta)
111 {
112 on_scroll.emit(id_, delta);
113
114=== modified file 'UnityCore/IndicatorEntry.h'
115--- UnityCore/IndicatorEntry.h 2011-07-21 14:59:25 +0000
116+++ UnityCore/IndicatorEntry.h 2011-07-21 20:27:23 +0000
117@@ -80,6 +80,7 @@
118 bool IsUnused() const;
119
120 void ShowMenu(int x, int y, int timestamp, int button);
121+ void SecondaryActivate(unsigned int timestamp);
122 void Scroll(int delta);
123
124 // Signals
125@@ -88,6 +89,7 @@
126 sigc::signal<void, bool> show_now_changed;
127
128 sigc::signal<void, std::string const&, int, int, int, int> on_show_menu;
129+ sigc::signal<void, std::string const&, unsigned int> on_secondary_activate;
130 sigc::signal<void, std::string const&, int> on_scroll;
131
132 private:
133
134=== modified file 'UnityCore/Indicators.cpp'
135--- UnityCore/Indicators.cpp 2011-07-21 14:59:25 +0000
136+++ UnityCore/Indicators.cpp 2011-07-21 20:27:23 +0000
137@@ -108,6 +108,7 @@
138 Indicator::Ptr indicator(new Indicator(name));
139 // The owner Indicators class is interested in the other events.
140 indicator->on_show_menu.connect(sigc::mem_fun(owner_, &Indicators::OnEntryShowMenu));
141+ indicator->on_secondary_activate.connect(sigc::mem_fun(owner_, &Indicators::OnEntrySecondaryActivate));
142 indicator->on_scroll.connect(sigc::mem_fun(owner_, &Indicators::OnEntryScroll));
143 indicators_[name] = indicator;
144 owner_->on_object_added.emit(indicator);
145
146=== modified file 'UnityCore/Indicators.h'
147--- UnityCore/Indicators.h 2011-07-21 14:59:25 +0000
148+++ UnityCore/Indicators.h 2011-07-21 20:27:23 +0000
149@@ -56,6 +56,8 @@
150 */
151 virtual void OnEntryShowMenu(std::string const& entry_id,
152 int x, int y, int timestamp, int button) = 0;
153+ virtual void OnEntrySecondaryActivate(std::string const& entry_id,
154+ unsigned int timestamp) = 0;
155
156 // Signals
157 sigc::signal<void, Indicator::Ptr const&> on_object_added;
158
159=== modified file 'plugins/unityshell/src/PanelIndicatorObjectEntryView.cpp'
160--- plugins/unityshell/src/PanelIndicatorObjectEntryView.cpp 2011-07-21 14:59:25 +0000
161+++ plugins/unityshell/src/PanelIndicatorObjectEntryView.cpp 2011-07-21 20:27:23 +0000
162@@ -91,11 +91,12 @@
163 if (proxy_->active())
164 return;
165
166- if ((proxy_->label_visible() && proxy_->label_sensitive()) ||
167- (proxy_->image_visible() && proxy_->image_sensitive()))
168+ if (((proxy_->label_visible() && proxy_->label_sensitive()) ||
169+ (proxy_->image_visible() && proxy_->image_sensitive())) &&
170+ nux::GetEventButton(button_flags) != 2)
171 {
172- proxy_->ShowMenu(GetAbsoluteGeometry().x + 1, //cairo translation
173- GetAbsoluteGeometry().y + PANEL_HEIGHT,
174+ proxy_->ShowMenu(GetAbsoluteX() + 1, //cairo translation
175+ GetAbsoluteY() + PANEL_HEIGHT,
176 time(NULL),
177 nux::GetEventButton(button_flags));
178 }
179@@ -107,6 +108,20 @@
180
181 void PanelIndicatorObjectEntryView::OnMouseUp(int x, int y, long button_flags, long key_flags)
182 {
183+ if (proxy_->active())
184+ return;
185+
186+ nux::Geometry geo = GetAbsoluteGeometry();
187+ int px = geo.x + x;
188+ int py = geo.y + y;
189+
190+ if (((proxy_->label_visible() && proxy_->label_sensitive()) ||
191+ (proxy_->image_visible() && proxy_->image_sensitive())) &&
192+ geo.IsPointInside(px, py) && nux::GetEventButton(button_flags) == 2)
193+ {
194+ proxy_->SecondaryActivate(time(NULL));
195+ }
196+
197 Refresh();
198 }
199
200
201=== modified file 'services/panel-main.c'
202--- services/panel-main.c 2011-03-29 14:18:06 +0000
203+++ services/panel-main.c 2011-07-21 20:27:23 +0000
204@@ -67,6 +67,11 @@
205 " <arg type='i' name='button' direction='in'/>"
206 " </method>"
207 ""
208+ " <method name='SecondaryActivateEntry'>"
209+ " <arg type='s' name='entry_id' direction='in'/>"
210+ " <arg type='u' name='timestamp' direction='in'/>"
211+ " </method>"
212+ ""
213 " <method name='ScrollEntry'>"
214 " <arg type='s' name='entry_id' direction='in'/>"
215 " <arg type='i' name='delta' direction='in'/>"
216@@ -186,6 +191,17 @@
217 g_dbus_method_invocation_return_value (invocation, NULL);
218 g_free (entry_id);
219 }
220+ else if (g_strcmp0 (method_name, "SecondaryActivateEntry") == 0)
221+ {
222+ gchar *entry_id;
223+ guint32 timestamp;
224+ g_variant_get (parameters, "(su)", &entry_id, &timestamp, NULL);
225+
226+ panel_service_secondary_activate_entry (service, entry_id, timestamp);
227+
228+ g_dbus_method_invocation_return_value (invocation, NULL);
229+ g_free (entry_id);
230+ }
231 else if (g_strcmp0 (method_name, "ScrollEntry") == 0)
232 {
233 gchar *entry_id;
234
235=== modified file 'services/panel-service.c'
236--- services/panel-service.c 2011-07-21 09:50:30 +0000
237+++ services/panel-service.c 2011-07-21 20:27:23 +0000
238@@ -236,7 +236,7 @@
239 {
240 XIDeviceEvent *event = cookie->data;
241
242- if (event->evtype == XI_ButtonRelease &&
243+ if (event && event->evtype == XI_ButtonRelease &&
244 priv->last_menu_button != 0) //FocusChange
245 {
246 if (event->root_x < priv->last_left ||
247@@ -249,7 +249,7 @@
248
249 priv->last_menu_button = 0;
250 }
251- else if (event->evtype == XI_Motion)
252+ else if (event && event->evtype == XI_Motion)
253 {
254 priv->last_menu_x = event->root_x;
255 priv->last_menu_y = event->root_y;
256@@ -1159,6 +1159,19 @@
257 }
258
259 void
260+panel_service_secondary_activate_entry (PanelService *self,
261+ const gchar *entry_id,
262+ guint32 timestamp)
263+{
264+ PanelServicePrivate *priv = self->priv;
265+ IndicatorObjectEntry *entry = g_hash_table_lookup (priv->id2entry_hash, entry_id);
266+ IndicatorObject *object = g_hash_table_lookup (priv->entry2indicator_hash, entry);
267+
268+ g_signal_emit_by_name(object, INDICATOR_OBJECT_SIGNAL_SECONDARY_ACTIVATE, entry,
269+ timestamp);
270+}
271+
272+void
273 panel_service_scroll_entry (PanelService *self,
274 const gchar *entry_id,
275 gint32 delta)
276
277=== modified file 'services/panel-service.h'
278--- services/panel-service.h 2011-03-01 15:39:36 +0000
279+++ services/panel-service.h 2011-07-21 20:27:23 +0000
280@@ -95,6 +95,10 @@
281 gint32 y,
282 gint32 button);
283
284+void panel_service_secondary_activate_entry (PanelService *self,
285+ const gchar *entry_id,
286+ guint32 timestamp);
287+
288 void panel_service_scroll_entry (PanelService *self,
289 const gchar *entry_id,
290 gint32 delta);