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

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Mirco Müller
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) Approve
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.
Revision history for this message
Mirco Müller (macslow) wrote :

All good seen from here. Approved.

review: Approve
Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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
=== modified file 'UnityCore/DBusIndicators.cpp'
--- UnityCore/DBusIndicators.cpp 2011-07-21 14:59:25 +0000
+++ UnityCore/DBusIndicators.cpp 2011-07-21 20:27:23 +0000
@@ -122,6 +122,8 @@
122 virtual void OnEntryScroll(std::string const& entry_id, int delta);122 virtual void OnEntryScroll(std::string const& entry_id, int delta);
123 virtual void OnEntryShowMenu(std::string const& entry_id,123 virtual void OnEntryShowMenu(std::string const& entry_id,
124 int x, int y, int timestamp, int button);124 int x, int y, int timestamp, int button);
125 virtual void OnEntrySecondaryActivate(std::string const& entry_id,
126 unsigned int timestamp);
125127
126 std::string name() const;128 std::string name() const;
127 std::string owner_name() const;129 std::string owner_name() const;
@@ -226,6 +228,14 @@
226 g_timeout_add(0, (GSourceFunc)send_show_entry, data);228 g_timeout_add(0, (GSourceFunc)send_show_entry, data);
227}229}
228230
231void DBusIndicators::Impl::OnEntrySecondaryActivate(std::string const& entry_id,
232 unsigned int timestamp)
233{
234 g_dbus_proxy_call(proxy_, "SecondaryActivateEntry",
235 g_variant_new("(su)", entry_id.c_str(), timestamp),
236 G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
237}
238
229void DBusIndicators::Impl::OnEntryScroll(std::string const& entry_id, int delta)239void DBusIndicators::Impl::OnEntryScroll(std::string const& entry_id, int delta)
230{240{
231 g_dbus_proxy_call(proxy_, "ScrollEntry",241 g_dbus_proxy_call(proxy_, "ScrollEntry",
@@ -474,6 +484,12 @@
474 pimpl->OnEntryShowMenu(entry_id, x, y, timestamp, button);484 pimpl->OnEntryShowMenu(entry_id, x, y, timestamp, button);
475}485}
476486
487void DBusIndicators::OnEntrySecondaryActivate(std::string const& entry_id,
488 unsigned int timestamp)
489{
490 pimpl->OnEntrySecondaryActivate(entry_id, timestamp);
491}
492
477std::string DBusIndicators::name() const493std::string DBusIndicators::name() const
478{494{
479 return pimpl->name();495 return pimpl->name();
480496
=== modified file 'UnityCore/DBusIndicators.h'
--- UnityCore/DBusIndicators.h 2011-07-21 14:59:25 +0000
+++ UnityCore/DBusIndicators.h 2011-07-21 20:27:23 +0000
@@ -44,6 +44,8 @@
44 virtual void OnEntryScroll(std::string const& entry_id, int delta);44 virtual void OnEntryScroll(std::string const& entry_id, int delta);
45 virtual void OnEntryShowMenu(std::string const& entry_id,45 virtual void OnEntryShowMenu(std::string const& entry_id,
46 int x, int y, int timestamp, int button);46 int x, int y, int timestamp, int button);
47 virtual void OnEntrySecondaryActivate(std::string const& entry_id,
48 unsigned int timestamp);
4749
48 std::string name() const;50 std::string name() const;
49 std::string owner_name() const;51 std::string owner_name() const;
5052
=== modified file 'UnityCore/Indicator.cpp'
--- UnityCore/Indicator.cpp 2011-07-21 14:59:25 +0000
+++ UnityCore/Indicator.cpp 2011-07-21 20:27:23 +0000
@@ -56,6 +56,7 @@
56 Entry::Ptr new_entry = new_entries[new_index];56 Entry::Ptr new_entry = new_entries[new_index];
57 entries_.push_back(new_entry);57 entries_.push_back(new_entry);
58 new_entry->on_show_menu.connect(sigc::mem_fun(this, &Indicator::OnEntryShowMenu));58 new_entry->on_show_menu.connect(sigc::mem_fun(this, &Indicator::OnEntryShowMenu));
59 new_entry->on_secondary_activate.connect(sigc::mem_fun(this, &Indicator::OnEntrySecondaryActivate));
59 new_entry->on_scroll.connect(sigc::mem_fun(this, &Indicator::OnEntryScroll));60 new_entry->on_scroll.connect(sigc::mem_fun(this, &Indicator::OnEntryScroll));
60 on_entry_added.emit(new_entry);61 on_entry_added.emit(new_entry);
61 }62 }
@@ -86,6 +87,12 @@
86 on_show_menu.emit(entry_id, x, y, timestamp, button);87 on_show_menu.emit(entry_id, x, y, timestamp, button);
87}88}
8889
90void Indicator::OnEntrySecondaryActivate(std::string const& entry_id,
91 unsigned int timestamp)
92{
93 on_secondary_activate.emit(entry_id, timestamp);
94}
95
89void Indicator::OnEntryScroll(std::string const& entry_id, int delta)96void Indicator::OnEntryScroll(std::string const& entry_id, int delta)
90{97{
91 on_scroll.emit(entry_id, delta);98 on_scroll.emit(entry_id, delta);
9299
=== modified file 'UnityCore/Indicator.h'
--- UnityCore/Indicator.h 2011-07-21 14:59:25 +0000
+++ UnityCore/Indicator.h 2011-07-21 20:27:23 +0000
@@ -45,11 +45,13 @@
45 Entry::Ptr GetEntry(std::string const& entry_id) const;45 Entry::Ptr GetEntry(std::string const& entry_id) const;
4646
47 void OnEntryShowMenu(std::string const& entry_id, int x, int y, int timestamp, int button);47 void OnEntryShowMenu(std::string const& entry_id, int x, int y, int timestamp, int button);
48 void OnEntrySecondaryActivate(std::string const& entry_id, unsigned int timestamp);
48 void OnEntryScroll(std::string const& entry_id, int delta);49 void OnEntryScroll(std::string const& entry_id, int delta);
4950
50 // Signals51 // Signals
51 sigc::signal<void, Entry::Ptr const&> on_entry_added;52 sigc::signal<void, Entry::Ptr const&> on_entry_added;
52 sigc::signal<void, std::string const&, int, int, int, int> on_show_menu;53 sigc::signal<void, std::string const&, int, int, int, int> on_show_menu;
54 sigc::signal<void, std::string const&, unsigned int> on_secondary_activate;
53 sigc::signal<void, std::string const&, int> on_scroll;55 sigc::signal<void, std::string const&, int> on_scroll;
5456
55private:57private:
5658
=== modified file 'UnityCore/IndicatorEntry.cpp'
--- UnityCore/IndicatorEntry.cpp 2011-07-21 14:59:25 +0000
+++ UnityCore/IndicatorEntry.cpp 2011-07-21 20:27:23 +0000
@@ -157,6 +157,11 @@
157 on_show_menu.emit(id_, x, y, timestamp, button);157 on_show_menu.emit(id_, x, y, timestamp, button);
158}158}
159159
160void Entry::SecondaryActivate(unsigned int timestamp)
161{
162 on_secondary_activate.emit(id_, timestamp);
163}
164
160void Entry::Scroll(int delta)165void Entry::Scroll(int delta)
161{166{
162 on_scroll.emit(id_, delta);167 on_scroll.emit(id_, delta);
163168
=== modified file 'UnityCore/IndicatorEntry.h'
--- UnityCore/IndicatorEntry.h 2011-07-21 14:59:25 +0000
+++ UnityCore/IndicatorEntry.h 2011-07-21 20:27:23 +0000
@@ -80,6 +80,7 @@
80 bool IsUnused() const;80 bool IsUnused() const;
8181
82 void ShowMenu(int x, int y, int timestamp, int button);82 void ShowMenu(int x, int y, int timestamp, int button);
83 void SecondaryActivate(unsigned int timestamp);
83 void Scroll(int delta);84 void Scroll(int delta);
8485
85 // Signals86 // Signals
@@ -88,6 +89,7 @@
88 sigc::signal<void, bool> show_now_changed;89 sigc::signal<void, bool> show_now_changed;
8990
90 sigc::signal<void, std::string const&, int, int, int, int> on_show_menu;91 sigc::signal<void, std::string const&, int, int, int, int> on_show_menu;
92 sigc::signal<void, std::string const&, unsigned int> on_secondary_activate;
91 sigc::signal<void, std::string const&, int> on_scroll;93 sigc::signal<void, std::string const&, int> on_scroll;
9294
93private:95private:
9496
=== modified file 'UnityCore/Indicators.cpp'
--- UnityCore/Indicators.cpp 2011-07-21 14:59:25 +0000
+++ UnityCore/Indicators.cpp 2011-07-21 20:27:23 +0000
@@ -108,6 +108,7 @@
108 Indicator::Ptr indicator(new Indicator(name));108 Indicator::Ptr indicator(new Indicator(name));
109 // The owner Indicators class is interested in the other events.109 // The owner Indicators class is interested in the other events.
110 indicator->on_show_menu.connect(sigc::mem_fun(owner_, &Indicators::OnEntryShowMenu));110 indicator->on_show_menu.connect(sigc::mem_fun(owner_, &Indicators::OnEntryShowMenu));
111 indicator->on_secondary_activate.connect(sigc::mem_fun(owner_, &Indicators::OnEntrySecondaryActivate));
111 indicator->on_scroll.connect(sigc::mem_fun(owner_, &Indicators::OnEntryScroll));112 indicator->on_scroll.connect(sigc::mem_fun(owner_, &Indicators::OnEntryScroll));
112 indicators_[name] = indicator;113 indicators_[name] = indicator;
113 owner_->on_object_added.emit(indicator);114 owner_->on_object_added.emit(indicator);
114115
=== modified file 'UnityCore/Indicators.h'
--- UnityCore/Indicators.h 2011-07-21 14:59:25 +0000
+++ UnityCore/Indicators.h 2011-07-21 20:27:23 +0000
@@ -56,6 +56,8 @@
56 */56 */
57 virtual void OnEntryShowMenu(std::string const& entry_id,57 virtual void OnEntryShowMenu(std::string const& entry_id,
58 int x, int y, int timestamp, int button) = 0;58 int x, int y, int timestamp, int button) = 0;
59 virtual void OnEntrySecondaryActivate(std::string const& entry_id,
60 unsigned int timestamp) = 0;
5961
60 // Signals62 // Signals
61 sigc::signal<void, Indicator::Ptr const&> on_object_added;63 sigc::signal<void, Indicator::Ptr const&> on_object_added;
6264
=== modified file 'plugins/unityshell/src/PanelIndicatorObjectEntryView.cpp'
--- plugins/unityshell/src/PanelIndicatorObjectEntryView.cpp 2011-07-21 14:59:25 +0000
+++ plugins/unityshell/src/PanelIndicatorObjectEntryView.cpp 2011-07-21 20:27:23 +0000
@@ -91,11 +91,12 @@
91 if (proxy_->active())91 if (proxy_->active())
92 return;92 return;
9393
94 if ((proxy_->label_visible() && proxy_->label_sensitive()) ||94 if (((proxy_->label_visible() && proxy_->label_sensitive()) ||
95 (proxy_->image_visible() && proxy_->image_sensitive()))95 (proxy_->image_visible() && proxy_->image_sensitive())) &&
96 nux::GetEventButton(button_flags) != 2)
96 {97 {
97 proxy_->ShowMenu(GetAbsoluteGeometry().x + 1, //cairo translation98 proxy_->ShowMenu(GetAbsoluteX() + 1, //cairo translation
98 GetAbsoluteGeometry().y + PANEL_HEIGHT,99 GetAbsoluteY() + PANEL_HEIGHT,
99 time(NULL),100 time(NULL),
100 nux::GetEventButton(button_flags));101 nux::GetEventButton(button_flags));
101 }102 }
@@ -107,6 +108,20 @@
107108
108void PanelIndicatorObjectEntryView::OnMouseUp(int x, int y, long button_flags, long key_flags)109void PanelIndicatorObjectEntryView::OnMouseUp(int x, int y, long button_flags, long key_flags)
109{110{
111 if (proxy_->active())
112 return;
113
114 nux::Geometry geo = GetAbsoluteGeometry();
115 int px = geo.x + x;
116 int py = geo.y + y;
117
118 if (((proxy_->label_visible() && proxy_->label_sensitive()) ||
119 (proxy_->image_visible() && proxy_->image_sensitive())) &&
120 geo.IsPointInside(px, py) && nux::GetEventButton(button_flags) == 2)
121 {
122 proxy_->SecondaryActivate(time(NULL));
123 }
124
110 Refresh();125 Refresh();
111}126}
112127
113128
=== modified file 'services/panel-main.c'
--- services/panel-main.c 2011-03-29 14:18:06 +0000
+++ services/panel-main.c 2011-07-21 20:27:23 +0000
@@ -67,6 +67,11 @@
67 " <arg type='i' name='button' direction='in'/>"67 " <arg type='i' name='button' direction='in'/>"
68 " </method>"68 " </method>"
69 ""69 ""
70 " <method name='SecondaryActivateEntry'>"
71 " <arg type='s' name='entry_id' direction='in'/>"
72 " <arg type='u' name='timestamp' direction='in'/>"
73 " </method>"
74 ""
70 " <method name='ScrollEntry'>"75 " <method name='ScrollEntry'>"
71 " <arg type='s' name='entry_id' direction='in'/>"76 " <arg type='s' name='entry_id' direction='in'/>"
72 " <arg type='i' name='delta' direction='in'/>"77 " <arg type='i' name='delta' direction='in'/>"
@@ -186,6 +191,17 @@
186 g_dbus_method_invocation_return_value (invocation, NULL);191 g_dbus_method_invocation_return_value (invocation, NULL);
187 g_free (entry_id);192 g_free (entry_id);
188 }193 }
194 else if (g_strcmp0 (method_name, "SecondaryActivateEntry") == 0)
195 {
196 gchar *entry_id;
197 guint32 timestamp;
198 g_variant_get (parameters, "(su)", &entry_id, &timestamp, NULL);
199
200 panel_service_secondary_activate_entry (service, entry_id, timestamp);
201
202 g_dbus_method_invocation_return_value (invocation, NULL);
203 g_free (entry_id);
204 }
189 else if (g_strcmp0 (method_name, "ScrollEntry") == 0)205 else if (g_strcmp0 (method_name, "ScrollEntry") == 0)
190 {206 {
191 gchar *entry_id;207 gchar *entry_id;
192208
=== modified file 'services/panel-service.c'
--- services/panel-service.c 2011-07-21 09:50:30 +0000
+++ services/panel-service.c 2011-07-21 20:27:23 +0000
@@ -236,7 +236,7 @@
236 {236 {
237 XIDeviceEvent *event = cookie->data;237 XIDeviceEvent *event = cookie->data;
238 238
239 if (event->evtype == XI_ButtonRelease &&239 if (event && event->evtype == XI_ButtonRelease &&
240 priv->last_menu_button != 0) //FocusChange240 priv->last_menu_button != 0) //FocusChange
241 {241 {
242 if (event->root_x < priv->last_left ||242 if (event->root_x < priv->last_left ||
@@ -249,7 +249,7 @@
249249
250 priv->last_menu_button = 0;250 priv->last_menu_button = 0;
251 }251 }
252 else if (event->evtype == XI_Motion)252 else if (event && event->evtype == XI_Motion)
253 {253 {
254 priv->last_menu_x = event->root_x;254 priv->last_menu_x = event->root_x;
255 priv->last_menu_y = event->root_y;255 priv->last_menu_y = event->root_y;
@@ -1159,6 +1159,19 @@
1159}1159}
11601160
1161void1161void
1162panel_service_secondary_activate_entry (PanelService *self,
1163 const gchar *entry_id,
1164 guint32 timestamp)
1165{
1166 PanelServicePrivate *priv = self->priv;
1167 IndicatorObjectEntry *entry = g_hash_table_lookup (priv->id2entry_hash, entry_id);
1168 IndicatorObject *object = g_hash_table_lookup (priv->entry2indicator_hash, entry);
1169
1170 g_signal_emit_by_name(object, INDICATOR_OBJECT_SIGNAL_SECONDARY_ACTIVATE, entry,
1171 timestamp);
1172}
1173
1174void
1162panel_service_scroll_entry (PanelService *self,1175panel_service_scroll_entry (PanelService *self,
1163 const gchar *entry_id,1176 const gchar *entry_id,
1164 gint32 delta)1177 gint32 delta)
11651178
=== modified file 'services/panel-service.h'
--- services/panel-service.h 2011-03-01 15:39:36 +0000
+++ services/panel-service.h 2011-07-21 20:27:23 +0000
@@ -95,6 +95,10 @@
95 gint32 y,95 gint32 y,
96 gint32 button);96 gint32 button);
9797
98void panel_service_secondary_activate_entry (PanelService *self,
99 const gchar *entry_id,
100 guint32 timestamp);
101
98void panel_service_scroll_entry (PanelService *self,102void panel_service_scroll_entry (PanelService *self,
99 const gchar *entry_id,103 const gchar *entry_id,
100 gint32 delta);104 gint32 delta);