Merge lp:~3v1n0/unity/panel-shared-dbus-model into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 3290
Proposed branch: lp:~3v1n0/unity/panel-shared-dbus-model
Merge into: lp:unity
Diff against target: 116 lines (+19/-8)
6 files modified
panel/PanelController.cpp (+4/-3)
panel/PanelIndicatorsView.cpp (+3/-0)
panel/PanelView.cpp (+5/-2)
panel/PanelView.h (+1/-1)
panel/StandalonePanel.cpp (+5/-1)
tests/test_panel_view.cpp (+1/-1)
To merge this branch: bzr merge lp:~3v1n0/unity/panel-shared-dbus-model
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Brandon Schaefer (community) Approve
Review via email: mp+157780@code.launchpad.net

Commit message

PanelController: create only one instance of DBusIndicators and share it between Views.

We can just have one dbus-model for indicators, and use it for all our panels.
This saves some unneeded allocations in multi-monitor environments.

Description of the change

In the past I already updated DBusIndicators to be multi-monitor friendly, but I've never shared it between panels.

We can safely do it, having just one DBusProxy that monitors our panel service to update indicators (and to callback it).

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'panel/PanelController.cpp'
--- panel/PanelController.cpp 2013-03-05 14:29:18 +0000
+++ panel/PanelController.cpp 2013-04-09 02:13:24 +0000
@@ -79,6 +79,7 @@
79 int menus_discovery_;79 int menus_discovery_;
80 int menus_discovery_fadein_;80 int menus_discovery_fadein_;
81 int menus_discovery_fadeout_;81 int menus_discovery_fadeout_;
82 indicator::DBusIndicators::Ptr dbus_indicators_;
82};83};
8384
8485
@@ -90,8 +91,8 @@
90 , menus_discovery_(0)91 , menus_discovery_(0)
91 , menus_discovery_fadein_(0)92 , menus_discovery_fadein_(0)
92 , menus_discovery_fadeout_(0)93 , menus_discovery_fadeout_(0)
93{94 , dbus_indicators_(std::make_shared<indicator::DBusIndicators>())
94}95{}
9596
96std::vector<Window> Controller::Impl::GetTrayXids() const97std::vector<Window> Controller::Impl::GetTrayXids() const
97{98{
@@ -243,7 +244,7 @@
243 {244 {
244 nux::HLayout* layout = new nux::HLayout(NUX_TRACKER_LOCATION);245 nux::HLayout* layout = new nux::HLayout(NUX_TRACKER_LOCATION);
245246
246 PanelView* view = new PanelView();247 PanelView* view = new PanelView(dbus_indicators_);
247 view->SetMaximumHeight(panel::Style::Instance().panel_height);248 view->SetMaximumHeight(panel::Style::Instance().panel_height);
248 view->SetOpacity(opacity_);249 view->SetOpacity(opacity_);
249 view->SetOpacityMaximizedToggle(opacity_maximized_toggle_);250 view->SetOpacityMaximizedToggle(opacity_maximized_toggle_);
250251
=== modified file 'panel/PanelIndicatorsView.cpp'
--- panel/PanelIndicatorsView.cpp 2012-12-13 20:06:11 +0000
+++ panel/PanelIndicatorsView.cpp 2013-04-09 02:13:24 +0000
@@ -65,6 +65,9 @@
6565
66 std::vector<sigc::connection> connections;66 std::vector<sigc::connection> connections;
6767
68 for (auto const& entry : indicator->GetEntries())
69 AddEntry(entry);
70
68 auto entry_added_conn = indicator->on_entry_added.connect(sigc::mem_fun(this, &PanelIndicatorsView::OnEntryAdded));71 auto entry_added_conn = indicator->on_entry_added.connect(sigc::mem_fun(this, &PanelIndicatorsView::OnEntryAdded));
69 connections.push_back(entry_added_conn);72 connections.push_back(entry_added_conn);
7073
7174
=== modified file 'panel/PanelView.cpp'
--- panel/PanelView.cpp 2013-03-19 18:47:01 +0000
+++ panel/PanelView.cpp 2013-04-09 02:13:24 +0000
@@ -55,8 +55,9 @@
5555
56NUX_IMPLEMENT_OBJECT_TYPE(PanelView);56NUX_IMPLEMENT_OBJECT_TYPE(PanelView);
5757
58PanelView::PanelView(NUX_FILE_LINE_DECL)58PanelView::PanelView(indicator::DBusIndicators::Ptr const& remote, NUX_FILE_LINE_DECL)
59 : View(NUX_FILE_LINE_PARAM)59 : View(NUX_FILE_LINE_PARAM)
60 , remote_(remote)
60 , is_dirty_(true)61 , is_dirty_(true)
61 , opacity_maximized_toggle_(false)62 , opacity_maximized_toggle_(false)
62 , needs_geo_sync_(false)63 , needs_geo_sync_(false)
@@ -105,7 +106,9 @@
105 indicators_ = new PanelIndicatorsView();106 indicators_ = new PanelIndicatorsView();
106 AddPanelView(indicators_, 0);107 AddPanelView(indicators_, 0);
107108
108 remote_ = indicator::DBusIndicators::Ptr(new indicator::DBusIndicators());109 for (auto const& object : remote_->GetIndicators())
110 OnObjectAdded(object);
111
109 remote_->on_object_added.connect(sigc::mem_fun(this, &PanelView::OnObjectAdded));112 remote_->on_object_added.connect(sigc::mem_fun(this, &PanelView::OnObjectAdded));
110 remote_->on_object_removed.connect(sigc::mem_fun(this, &PanelView::OnObjectRemoved));113 remote_->on_object_removed.connect(sigc::mem_fun(this, &PanelView::OnObjectRemoved));
111 remote_->on_entry_activate_request.connect(sigc::mem_fun(this, &PanelView::OnEntryActivateRequest));114 remote_->on_entry_activate_request.connect(sigc::mem_fun(this, &PanelView::OnEntryActivateRequest));
112115
=== modified file 'panel/PanelView.h'
--- panel/PanelView.h 2013-03-04 23:56:40 +0000
+++ panel/PanelView.h 2013-04-09 02:13:24 +0000
@@ -46,7 +46,7 @@
46{46{
47 NUX_DECLARE_OBJECT_TYPE(PanelView, nux::View);47 NUX_DECLARE_OBJECT_TYPE(PanelView, nux::View);
48public:48public:
49 PanelView(NUX_FILE_LINE_PROTO);49 PanelView(indicator::DBusIndicators::Ptr const&, NUX_FILE_LINE_PROTO);
50 ~PanelView();50 ~PanelView();
5151
52 void SetPrimary(bool primary);52 void SetPrimary(bool primary);
5353
=== modified file 'panel/StandalonePanel.cpp'
--- panel/StandalonePanel.cpp 2012-12-12 17:30:20 +0000
+++ panel/StandalonePanel.cpp 2013-04-09 02:13:24 +0000
@@ -47,9 +47,13 @@
47 }47 }
4848
49private:49private:
50 class StandalonePanelView : public PanelView50 struct StandalonePanelView : public PanelView
51 {51 {
52 // Used to sync menu geometries52 // Used to sync menu geometries
53 StandalonePanelView()
54 : PanelView(std::make_shared<indicator::DBusIndicators>())
55 {}
56
53 std::string GetName() const { return "StandalonePanel"; }57 std::string GetName() const { return "StandalonePanel"; }
54 };58 };
5559
5660
=== modified file 'tests/test_panel_view.cpp'
--- tests/test_panel_view.cpp 2013-03-04 23:09:52 +0000
+++ tests/test_panel_view.cpp 2013-04-09 02:13:24 +0000
@@ -39,7 +39,7 @@
39 nux::ObjectPtr<unity::PanelView> panel_view_;39 nux::ObjectPtr<unity::PanelView> panel_view_;
4040
41 TestPanelView()41 TestPanelView()
42 : panel_view_(new unity::PanelView())42 : panel_view_(new unity::PanelView(std::make_shared<unity::indicator::DBusIndicators>()))
43 {}43 {}
4444
45};45};