summaryrefslogtreecommitdiff
path: root/UnityCore
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2012-12-04 01:33:18 +0100
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2012-12-04 01:33:18 +0100
commit64ba7093b2074d7f3aca9c628c21c603f65a6a1d (patch)
treea51418fa1ee500384c837f99fea89bda4537277c /UnityCore
parent21baaad30ea59fae0b30d18542cb613204a60c82 (diff)
UnityCore, Tests and Panel: update against the new DBus API, remove the timestamps around
(bzr r2919.2.2)
Diffstat (limited to 'UnityCore')
-rw-r--r--UnityCore/AppmenuIndicator.cpp4
-rw-r--r--UnityCore/AppmenuIndicator.h4
-rw-r--r--UnityCore/DBusIndicators.cpp122
-rw-r--r--UnityCore/DBusIndicators.h12
-rw-r--r--UnityCore/Indicator.cpp11
-rw-r--r--UnityCore/Indicator.h8
-rw-r--r--UnityCore/IndicatorEntry.cpp12
-rw-r--r--UnityCore/IndicatorEntry.h10
-rw-r--r--UnityCore/Indicators.h15
9 files changed, 88 insertions, 110 deletions
diff --git a/UnityCore/AppmenuIndicator.cpp b/UnityCore/AppmenuIndicator.cpp
index 5ddbacd8d..ea1ba90cd 100644
--- a/UnityCore/AppmenuIndicator.cpp
+++ b/UnityCore/AppmenuIndicator.cpp
@@ -28,9 +28,9 @@ AppmenuIndicator::AppmenuIndicator(std::string const& name)
: Indicator(name)
{}
-void AppmenuIndicator::ShowAppmenu(unsigned int xid, int x, int y, unsigned int timestamp) const
+void AppmenuIndicator::ShowAppmenu(unsigned int xid, int x, int y) const
{
- on_show_appmenu.emit(xid, x, y, timestamp);
+ on_show_appmenu.emit(xid, x, y);
}
} // namespace indicator
diff --git a/UnityCore/AppmenuIndicator.h b/UnityCore/AppmenuIndicator.h
index 7393c60af..38ec62f17 100644
--- a/UnityCore/AppmenuIndicator.h
+++ b/UnityCore/AppmenuIndicator.h
@@ -34,9 +34,9 @@ public:
virtual bool IsAppmenu() const { return true; }
- void ShowAppmenu(unsigned int xid, int x, int y, unsigned int timestamp) const;
+ void ShowAppmenu(unsigned xid, int x, int y) const;
- sigc::signal<void, unsigned int, int, int, unsigned int> on_show_appmenu;
+ sigc::signal<void, unsigned, int, int> on_show_appmenu;
};
}
diff --git a/UnityCore/DBusIndicators.cpp b/UnityCore/DBusIndicators.cpp
index 8432c7ddb..e9c32b465 100644
--- a/UnityCore/DBusIndicators.cpp
+++ b/UnityCore/DBusIndicators.cpp
@@ -65,12 +65,9 @@ public:
virtual void OnEntryScroll(std::string const& entry_id, int delta);
virtual void OnEntryShowMenu(std::string const& entry_id, unsigned int xid,
- int x, int y, unsigned int button,
- unsigned int timestamp);
- virtual void OnEntrySecondaryActivate(std::string const& entry_id,
- unsigned int timestamp);
- virtual void OnShowAppMenu(unsigned int xid, int x, int y,
- unsigned int timestamp);
+ int x, int y, unsigned int button);
+ virtual void OnEntrySecondaryActivate(std::string const& entry_id);
+ virtual void OnShowAppMenu(unsigned int xid, int x, int y);
DBusIndicators* owner_;
@@ -189,7 +186,7 @@ void DBusIndicators::Impl::OnEntryActivatedRequest(GVariant* parameters)
void DBusIndicators::Impl::OnEntryShowNowChanged(GVariant* parameters)
{
glib::String entry_name;
- gboolean show_now;
+ gboolean show_now;
g_variant_get(parameters, "(sb)", &entry_name, &show_now);
if (entry_name)
@@ -211,43 +208,40 @@ void DBusIndicators::Impl::RequestSyncIndicator(std::string const& name)
void DBusIndicators::Impl::OnEntryShowMenu(std::string const& entry_id,
unsigned int xid, int x, int y,
- unsigned int button,
- unsigned int timestamp)
+ unsigned int button)
{
- owner_->on_entry_show_menu.emit(entry_id, xid, x, y, button, timestamp);
+ owner_->on_entry_show_menu.emit(entry_id, xid, x, y, button);
// We have to do this because on certain systems X won't have time to
// respond to our request for XUngrabPointer and this will cause the
// menu not to show
show_entry_idle_.reset(new glib::Idle(glib::Source::Priority::DEFAULT));
- show_entry_idle_->Run([&, entry_id, xid, x, y, button, timestamp] {
- gproxy_.Call("ShowEntry", g_variant_new("(suiiuu)", entry_id.c_str(), xid,
- x, y, button, timestamp));
+ show_entry_idle_->Run([&, entry_id, xid, x, y, button] {
+ gproxy_.Call("ShowEntry", g_variant_new("(suiiu)", entry_id.c_str(), xid,
+ x, y, button));
return false;
});
}
-void DBusIndicators::Impl::OnShowAppMenu(unsigned int xid, int x, int y,
- unsigned int timestamp)
+void DBusIndicators::Impl::OnShowAppMenu(unsigned int xid, int x, int y)
{
- owner_->on_show_appmenu.emit(xid, x, y, timestamp);
+ owner_->on_show_appmenu.emit(xid, x, y);
// We have to do this because on certain systems X won't have time to
// respond to our request for XUngrabPointer and this will cause the
// menu not to show
show_entry_idle_.reset(new glib::Idle(glib::Source::Priority::DEFAULT));
- show_entry_idle_->Run([&, xid, x, y, timestamp] {
- gproxy_.Call("ShowEntry", g_variant_new("(uiiu)", xid, x, y, timestamp));
+ show_entry_idle_->Run([&, xid, x, y] {
+ gproxy_.Call("ShowEntry", g_variant_new("(uii)", xid, x, y));
return false;
});
}
-void DBusIndicators::Impl::OnEntrySecondaryActivate(std::string const& entry_id,
- unsigned int timestamp)
+void DBusIndicators::Impl::OnEntrySecondaryActivate(std::string const& entry_id)
{
- gproxy_.Call("SecondaryActivateEntry", g_variant_new("(su)", entry_id.c_str(), timestamp));
+ gproxy_.Call("SecondaryActivateEntry", g_variant_new("(s)", entry_id.c_str()));
}
void DBusIndicators::Impl::OnEntryScroll(std::string const& entry_id, int delta)
@@ -257,6 +251,9 @@ void DBusIndicators::Impl::OnEntryScroll(std::string const& entry_id, int delta)
void DBusIndicators::Impl::Sync(GVariant* args)
{
+ if (!args)
+ return;
+
GVariantIter* iter = nullptr;
gchar* name_hint = nullptr;
gchar* indicator_id = nullptr;
@@ -270,13 +267,9 @@ void DBusIndicators::Impl::Sync(GVariant* args)
gboolean image_visible = false;
gint32 priority = -1;
- // sanity check
- if (!args)
- return;
-
std::map<Indicator::Ptr, Indicator::Entries> indicators;
- int wantedIndex = 0;
- bool anyIndexDifferent = false;
+ int wanted_idx = 0;
+ bool any_different_idx = false;
g_variant_get(args, "(a(ssssbbusbbi))", &iter);
while (g_variant_iter_loop(iter, "(ssssbbusbbi)",
@@ -292,8 +285,8 @@ void DBusIndicators::Impl::Sync(GVariant* args)
&image_visible,
&priority))
{
- std::string entry(entry_id);
- std::string indicator_name(indicator_id);
+ std::string entry(G_LIKELY(entry_id) ? entry_id : "");
+ std::string indicator_name(G_LIKELY(indicator_id) ? indicator_id : "");
Indicator::Ptr indicator = owner_->GetIndicator(indicator_name);
if (!indicator)
@@ -307,16 +300,19 @@ void DBusIndicators::Impl::Sync(GVariant* args)
if (entry != "")
{
Entry::Ptr e;
- if (!anyIndexDifferent)
+ if (!any_different_idx)
{
// Indicators can only add or remove entries, so if
// there is a index change we can't reuse the existing ones
// after that index
- int existingEntryIndex = indicator->EntryIndex(entry_id);
- if (wantedIndex == existingEntryIndex)
+ if (indicator->EntryIndex(entry_id) == wanted_idx)
+ {
e = indicator->GetEntry(entry_id);
+ }
else
- anyIndexDifferent = true;
+ {
+ any_different_idx = true;
+ }
}
if (!e)
@@ -333,7 +329,7 @@ void DBusIndicators::Impl::Sync(GVariant* args)
}
entries.push_back(e);
- wantedIndex++;
+ ++wanted_idx;
}
}
g_variant_iter_free(iter);
@@ -350,45 +346,39 @@ void DBusIndicators::Impl::Sync(GVariant* args)
void DBusIndicators::Impl::SyncGeometries(std::string const& name,
EntryLocationMap const& locations)
{
- if (!gproxy_.IsConnected())
+ if (!gproxy_.IsConnected() || G_UNLIKELY(name.empty()))
return;
- GVariantBuilder b;
bool found_changed_locations = false;
- g_variant_builder_init(&b, G_VARIANT_TYPE("(a(ssiiii))"));
- g_variant_builder_open(&b, G_VARIANT_TYPE("a(ssiiii)"));
- EntryLocationMap& cached_loc = cached_locations_[name];
+ EntryLocationMap& cached_locations = cached_locations_[name];
+
+ GVariantBuilder b;
+ g_variant_builder_init(&b, G_VARIANT_TYPE("(sa(siiii))"));
+ g_variant_builder_add(&b, "s", name.c_str());
+
+ g_variant_builder_open(&b, G_VARIANT_TYPE("a(siiii)"));
// Only send to panel service the geometries of items that have changed
- for (auto i = locations.begin(), end = locations.end(); i != end; ++i)
+ for (auto const& location : locations)
{
- auto rect = i->second;
+ auto const& id = location.first;
+ auto const& rect = location.second;
- if (cached_loc[i->first] != rect)
+ if (cached_locations[id] != rect)
{
- g_variant_builder_add(&b, "(ssiiii)",
- name.c_str(),
- i->first.c_str(),
- rect.x,
- rect.y,
- rect.width,
- rect.height);
+ g_variant_builder_add(&b, "(siiii)", id.c_str(), rect.x, rect.y, rect.width, rect.height);
found_changed_locations = true;
}
}
// Inform panel service of the entries that have been removed sending invalid values
- for (auto i = cached_loc.begin(), end = cached_loc.end(); i != end; ++i)
+ for (auto const& location : cached_locations)
{
- if (locations.find(i->first) == locations.end())
+ auto const& id = location.first;
+
+ if (locations.find(id) == locations.end())
{
- g_variant_builder_add(&b, "(ssiiii)",
- name.c_str(),
- i->first.c_str(),
- 0,
- 0,
- -1,
- -1);
+ g_variant_builder_add(&b, "(siiii)", id.c_str(), 0, 0, -1, -1);
found_changed_locations = true;
}
}
@@ -402,7 +392,7 @@ void DBusIndicators::Impl::SyncGeometries(std::string const& name,
g_variant_builder_close(&b);
gproxy_.Call("SyncGeometries", g_variant_builder_end(&b));
- cached_loc = locations;
+ cached_locations = locations;
}
DBusIndicators::DBusIndicators()
@@ -434,21 +424,19 @@ void DBusIndicators::OnEntryScroll(std::string const& entry_id, int delta)
void DBusIndicators::OnEntryShowMenu(std::string const& entry_id,
unsigned int xid, int x, int y,
- unsigned int button, unsigned int timestamp)
+ unsigned int button)
{
- pimpl->OnEntryShowMenu(entry_id, xid, x, y, button, timestamp);
+ pimpl->OnEntryShowMenu(entry_id, xid, x, y, button);
}
-void DBusIndicators::OnEntrySecondaryActivate(std::string const& entry_id,
- unsigned int timestamp)
+void DBusIndicators::OnEntrySecondaryActivate(std::string const& entry_id)
{
- pimpl->OnEntrySecondaryActivate(entry_id, timestamp);
+ pimpl->OnEntrySecondaryActivate(entry_id);
}
-void DBusIndicators::OnShowAppMenu(unsigned int xid, int x, int y,
- unsigned int timestamp)
+void DBusIndicators::OnShowAppMenu(unsigned int xid, int x, int y)
{
- pimpl->OnShowAppMenu(xid, x, y, timestamp);
+ pimpl->OnShowAppMenu(xid, x, y);
}
} // namespace indicator
diff --git a/UnityCore/DBusIndicators.h b/UnityCore/DBusIndicators.h
index 5ac1111c8..fe5dbc178 100644
--- a/UnityCore/DBusIndicators.h
+++ b/UnityCore/DBusIndicators.h
@@ -38,17 +38,13 @@ public:
DBusIndicators();
~DBusIndicators();
- void SyncGeometries(std::string const& name,
- EntryLocationMap const& locations);
+ void SyncGeometries(std::string const& name, EntryLocationMap const& locations);
virtual void OnEntryScroll(std::string const& entry_id, int delta);
virtual void OnEntryShowMenu(std::string const& entry_id, unsigned int xid,
- int x, int y, unsigned int button,
- unsigned int timestamp);
- virtual void OnEntrySecondaryActivate(std::string const& entry_id,
- unsigned int timestamp);
- virtual void OnShowAppMenu(unsigned int xid, int x, int y,
- unsigned int timestamp);
+ int x, int y, unsigned int button);
+ virtual void OnEntrySecondaryActivate(std::string const& entry_id);
+ virtual void OnShowAppMenu(unsigned int xid, int x, int y);
protected:
DBusIndicators(std::string const& dbus_name);
diff --git a/UnityCore/Indicator.cpp b/UnityCore/Indicator.cpp
index 688d3c110..42d8bb675 100644
--- a/UnityCore/Indicator.cpp
+++ b/UnityCore/Indicator.cpp
@@ -130,16 +130,15 @@ int Indicator::EntryIndex(std::string const& entry_id) const
return -1;
}
-void Indicator::OnEntryShowMenu(std::string const& entry_id, unsigned int xid,
- int x, int y, unsigned int button, unsigned int timestamp)
+void Indicator::OnEntryShowMenu(std::string const& entry_id, unsigned xid,
+ int x, int y, unsigned button)
{
- on_show_menu.emit(entry_id, xid, x, y, button, timestamp);
+ on_show_menu.emit(entry_id, xid, x, y, button);
}
-void Indicator::OnEntrySecondaryActivate(std::string const& entry_id,
- unsigned int timestamp)
+void Indicator::OnEntrySecondaryActivate(std::string const& entry_id)
{
- on_secondary_activate.emit(entry_id, timestamp);
+ on_secondary_activate.emit(entry_id);
}
void Indicator::OnEntryScroll(std::string const& entry_id, int delta)
diff --git a/UnityCore/Indicator.h b/UnityCore/Indicator.h
index 23b4bd575..682c4d1e0 100644
--- a/UnityCore/Indicator.h
+++ b/UnityCore/Indicator.h
@@ -54,13 +54,13 @@ public:
// Signals
sigc::signal<void, Entry::Ptr const&> on_entry_added;
sigc::signal<void, std::string const&> on_entry_removed;
- sigc::signal<void, std::string const&, unsigned int, int, int, unsigned int, unsigned int> on_show_menu;
- sigc::signal<void, std::string const&, unsigned int> on_secondary_activate;
+ sigc::signal<void, std::string const&, unsigned, int, int, unsigned> on_show_menu;
+ sigc::signal<void, std::string const&> on_secondary_activate;
sigc::signal<void, std::string const&, int> on_scroll;
protected:
- void OnEntryShowMenu(std::string const& entry_id, unsigned int xid, int x, int y, unsigned int button, unsigned int timestamp);
- void OnEntrySecondaryActivate(std::string const& entry_id, unsigned int timestamp);
+ void OnEntryShowMenu(std::string const& entry_id, unsigned xid, int x, int y, unsigned button);
+ void OnEntrySecondaryActivate(std::string const& entry_id);
void OnEntryScroll(std::string const& entry_id, int delta);
Entries entries_;
diff --git a/UnityCore/IndicatorEntry.cpp b/UnityCore/IndicatorEntry.cpp
index 34784841b..63a7ec415 100644
--- a/UnityCore/IndicatorEntry.cpp
+++ b/UnityCore/IndicatorEntry.cpp
@@ -205,19 +205,19 @@ void Entry::set_show_now(bool show_now)
updated.emit();
}
-void Entry::ShowMenu(int x, int y, unsigned int button, unsigned int timestamp)
+void Entry::ShowMenu(int x, int y, unsigned button)
{
- ShowMenu(0, x, y, button, timestamp);
+ ShowMenu(0, x, y, button);
}
-void Entry::ShowMenu(unsigned int xid, int x, int y, unsigned int button, unsigned int timestamp)
+void Entry::ShowMenu(unsigned int xid, int x, int y, unsigned button)
{
- on_show_menu.emit(id_, xid, x, y, button, timestamp);
+ on_show_menu.emit(id_, xid, x, y, button);
}
-void Entry::SecondaryActivate(unsigned int timestamp)
+void Entry::SecondaryActivate()
{
- on_secondary_activate.emit(id_, timestamp);
+ on_secondary_activate.emit(id_);
}
void Entry::Scroll(int delta)
diff --git a/UnityCore/IndicatorEntry.h b/UnityCore/IndicatorEntry.h
index 73928be8e..ffe1b0414 100644
--- a/UnityCore/IndicatorEntry.h
+++ b/UnityCore/IndicatorEntry.h
@@ -85,9 +85,9 @@ public:
bool show_now() const;
void set_show_now(bool show_now);
- void ShowMenu(int x, int y, unsigned int button, unsigned int timestamp);
- void ShowMenu(unsigned int xid, int x, int y, unsigned int button, unsigned int timestamp);
- void SecondaryActivate(unsigned int timestamp);
+ void ShowMenu(int x, int y, unsigned button);
+ void ShowMenu(unsigned int xid, int x, int y, unsigned button);
+ void SecondaryActivate();
void Scroll(int delta);
void setLabel(std::string const& label, bool sensitive, bool visible);
@@ -100,8 +100,8 @@ public:
sigc::signal<void, nux::Rect const&> geometry_changed;
sigc::signal<void, bool> show_now_changed;
- sigc::signal<void, std::string const&, unsigned int, int, int, unsigned int, unsigned int> on_show_menu;
- sigc::signal<void, std::string const&, unsigned int> on_secondary_activate;
+ sigc::signal<void, std::string const&, unsigned, int, int, unsigned> on_show_menu;
+ sigc::signal<void, std::string const&> on_secondary_activate;
sigc::signal<void, std::string const&, int> on_scroll;
private:
diff --git a/UnityCore/Indicators.h b/UnityCore/Indicators.h
index 024f0c2f6..53b4d004f 100644
--- a/UnityCore/Indicators.h
+++ b/UnityCore/Indicators.h
@@ -59,20 +59,17 @@ public:
* internal
*/
virtual void OnEntryShowMenu(std::string const& entry_id, unsigned int xid,
- int x, int y, unsigned int button,
- unsigned int timestamp) = 0;
+ int x, int y, unsigned int button) = 0;
/**
* internal
*/
- virtual void OnEntrySecondaryActivate(std::string const& entry_id,
- unsigned int timestamp) = 0;
+ virtual void OnEntrySecondaryActivate(std::string const& entry_id) = 0;
/**
* internal
*/
- virtual void OnShowAppMenu(unsigned int xid, int x, int y,
- unsigned int timestamp) = 0;
+ virtual void OnShowAppMenu(unsigned int xid, int x, int y) = 0;
// Signals
sigc::signal<void, Indicator::Ptr const&> on_object_added;
@@ -104,18 +101,16 @@ public:
* @param x coordinate
* @param y coordinate
* @param button pressed button
- * @param timestamp current time
*/
- sigc::signal<void, std::string const&, unsigned int, int, int, unsigned int, unsigned int> on_entry_show_menu;
+ sigc::signal<void, std::string const&, unsigned, int, int, unsigned> on_entry_show_menu;
/**
* The service is about to show an appmenu.
* @param xid window xid
* @param x coordinate
* @param y coordinate
- * @param timestamp current time
*/
- sigc::signal<void, unsigned int, int, int, unsigned int> on_show_appmenu;
+ sigc::signal<void, unsigned, int, int> on_show_appmenu;
protected:
Indicator::Ptr GetIndicator(std::string const& name);