diff options
| -rw-r--r-- | UnityCore/DBusIndicators.cpp | 11 | ||||
| -rw-r--r-- | UnityCore/IndicatorEntry.cpp | 20 | ||||
| -rw-r--r-- | UnityCore/IndicatorEntry.h | 5 | ||||
| -rw-r--r-- | services/panel-service-private.h | 2 | ||||
| -rw-r--r-- | services/panel-service.c | 4 | ||||
| -rw-r--r-- | tests/test_indicator.cpp | 20 | ||||
| -rw-r--r-- | tests/test_indicator_entry.cpp | 31 | ||||
| -rw-r--r-- | tests/test_indicators.cpp | 10 | ||||
| -rw-r--r-- | tests/test_panel_service.cpp | 4 | ||||
| -rw-r--r-- | tests/test_service_panel.cpp | 2 |
10 files changed, 68 insertions, 41 deletions
diff --git a/UnityCore/DBusIndicators.cpp b/UnityCore/DBusIndicators.cpp index cbd968ea4..b40581216 100644 --- a/UnityCore/DBusIndicators.cpp +++ b/UnityCore/DBusIndicators.cpp @@ -322,9 +322,10 @@ void DBusIndicators::Impl::Sync(GVariant* args, glib::Error const& error) return; GVariantIter* iter = nullptr; - gchar* name_hint = nullptr; gchar* indicator_id = nullptr; gchar* entry_id = nullptr; + gchar* name_hint = nullptr; + guint32 parent_window = 0; gchar* label = nullptr; gboolean label_sensitive = false; gboolean label_visible = false; @@ -343,6 +344,7 @@ void DBusIndicators::Impl::Sync(GVariant* args, glib::Error const& error) &indicator_id, &entry_id, &name_hint, + &parent_window, &label, &label_sensitive, &label_visible, @@ -384,9 +386,10 @@ void DBusIndicators::Impl::Sync(GVariant* args, glib::Error const& error) if (!e) { - e = std::make_shared<Entry>(entry, name_hint, label, label_sensitive, - label_visible, image_type, image_data, - image_sensitive, image_visible, priority); + e = std::make_shared<Entry>(entry, name_hint, parent_window, + label, label_sensitive, label_visible, + image_type, image_data, image_sensitive, image_visible, + priority); } else { diff --git a/UnityCore/IndicatorEntry.cpp b/UnityCore/IndicatorEntry.cpp index bd5a5422d..e56611505 100644 --- a/UnityCore/IndicatorEntry.cpp +++ b/UnityCore/IndicatorEntry.cpp @@ -30,6 +30,7 @@ namespace indicator Entry::Entry(std::string const& id, std::string const& name_hint, + uint32_t parent_window, std::string const& label, bool label_sensitive, bool label_visible, @@ -40,6 +41,7 @@ Entry::Entry(std::string const& id, int priority) : id_(id) , name_hint_(name_hint) + , parent_window_(parent_window) , label_(label) , label_visible_(label_visible) , label_sensitive_(label_sensitive) @@ -52,9 +54,10 @@ Entry::Entry(std::string const& id, , active_(false) {} -Entry::Entry(std::string const& id, std::string const& name_hint) +Entry::Entry(std::string const& id, std::string const& name_hint, uint32_t parent_window) : id_(id) , name_hint_(name_hint) + , parent_window_(parent_window) , label_visible_(false) , label_sensitive_(false) , image_type_(0) @@ -65,14 +68,19 @@ Entry::Entry(std::string const& id, std::string const& name_hint) , active_(false) {} +std::string const& Entry::id() const +{ + return id_; +} + std::string const& Entry::name_hint() const { return name_hint_; } -std::string const& Entry::id() const +uint32_t Entry::parent_window() const { - return id_; + return parent_window_; } std::string const& Entry::label() const @@ -199,6 +207,7 @@ Entry& Entry::operator=(Entry const& rhs) id_ = rhs.id_; name_hint_ = rhs.name_hint_; + parent_window_ = rhs.parent_window_; label_ = rhs.label_; label_sensitive_ = rhs.label_sensitive_; label_visible_ = rhs.label_visible_; @@ -258,7 +267,7 @@ std::vector<Entry::Ptr> const& Entry::parents() const void Entry::ShowMenu(int x, int y, unsigned button) { - ShowMenu(0, x, y, button); + ShowMenu(parent_window_, x, y, button); } void Entry::ShowMenu(unsigned int xid, int x, int y, unsigned button) @@ -278,7 +287,8 @@ void Entry::Scroll(int delta) std::ostream& operator<<(std::ostream& out, Entry const& e) { - out << "<indicator::Entry " << e.id() << " hint: '" << e.name_hint() << "' " + out << "<indicator::Entry " << e.id() << " hint: '" << e.name_hint() << "'" + << " parent window: " << e.parent_window() << std::boolalpha << " \"" << e.label() << "\" (" << e.label_sensitive() << ", " << e.label_visible() << ") image (" diff --git a/UnityCore/IndicatorEntry.h b/UnityCore/IndicatorEntry.h index 9e7768623..b00d94ef7 100644 --- a/UnityCore/IndicatorEntry.h +++ b/UnityCore/IndicatorEntry.h @@ -44,9 +44,10 @@ class Entry public: typedef std::shared_ptr<Entry> Ptr; - Entry(std::string const& id, std::string const& name_hint = ""); + Entry(std::string const& id, std::string const& name_hint = "", uint32_t parent_window = 0); Entry(std::string const& id, std::string const& name_hint, + uint32_t parent_window, std::string const& label, bool label_sensitive, bool label_visible, @@ -61,6 +62,7 @@ public: std::string const& id() const; std::string const& name_hint() const; + uint32_t parent_window() const; void set_image(int type, std::string const& data, bool sensitive, bool visible); bool image_visible() const; @@ -114,6 +116,7 @@ public: private: std::string id_; std::string name_hint_; + uint32_t parent_window_; std::string label_; bool label_visible_; diff --git a/services/panel-service-private.h b/services/panel-service-private.h index fe973f06b..00e1d4fd4 100644 --- a/services/panel-service-private.h +++ b/services/panel-service-private.h @@ -33,7 +33,7 @@ extern "C" { #define UPS_PATH "/com/canonical/Unity/Panel/Service" #define UPS_IFACE "com.canonical.Unity.Panel.Service" -#define ENTRY_SIGNATURE "(ssssbbusbbi)" +#define ENTRY_SIGNATURE "(sssusbbusbbi)" #define ENTRY_ARRAY_SIGNATURE "a" ENTRY_SIGNATURE "" #define AltMask Mod1Mask diff --git a/services/panel-service.c b/services/panel-service.c index 393871b7f..1636e0a0e 100644 --- a/services/panel-service.c +++ b/services/panel-service.c @@ -1611,6 +1611,7 @@ indicator_entry_to_variant (IndicatorObjectEntry *entry, indicator_id, id, entry->name_hint ? entry->name_hint : "", + entry->parent_window, is_label ? gtk_label_get_label (entry->label) : "", is_label ? gtk_widget_get_sensitive (GTK_WIDGET (entry->label)) : FALSE, is_label ? gtk_widget_get_visible (GTK_WIDGET (entry->label)) : FALSE, @@ -1631,10 +1632,11 @@ indicator_entry_null_to_variant (const gchar *indicator_id, indicator_id, "", "", + 0, "", FALSE, FALSE, - (guint32) 0, + 0, "", FALSE, FALSE, diff --git a/tests/test_indicator.cpp b/tests/test_indicator.cpp index 5bc3c88f2..47707d46d 100644 --- a/tests/test_indicator.cpp +++ b/tests/test_indicator.cpp @@ -69,17 +69,17 @@ TEST(TestIndicator, Syncing) Indicator indicator("indicator-test"); SigReceiver::Nice sig_receiver(indicator); - entry = new Entry("test-entry-1", "name-hint", "label", true, true, 0, "icon", + entry = new Entry("test-entry-1", "name-hint", 0, "label", true, true, 0, "icon", true, true, -1); Entry::Ptr entry1(entry); sync_data.push_back(entry1); - entry = new Entry("test-entry-2", "name-hint", "label", true, true, 0, "icon", + entry = new Entry("test-entry-2", "name-hint", 0, "label", true, true, 0, "icon", true, true, -1); Entry::Ptr entry2(entry); sync_data.push_back(entry2); - entry = new Entry("test-entry-3", "name-hint", "label", true, true, 0, "icon", + entry = new Entry("test-entry-3", "name-hint", 0, "label", true, true, 0, "icon", true, true, -1); Entry::Ptr entry3(entry); sync_data.push_back(entry3); @@ -113,7 +113,7 @@ TEST(TestIndicator, Syncing) EXPECT_EQ(indicator.EntryIndex("test-entry-2"), -1); // Sync the indicator removing an entry and adding a new one - entry = new Entry("test-entry-4", "name-hint", "label", true, true, 0, "icon", + entry = new Entry("test-entry-4", "name-hint", 0, "label", true, true, 0, "icon", true, true, -1); Entry::Ptr entry4(entry); sync_data.push_back(entry4); @@ -144,13 +144,13 @@ TEST(TestIndicator, Updated) SigReceiver::Nice sig_receiver(indicator); Indicator::Entries sync_data; - auto entry1 = std::make_shared<Entry>("test-entry-1", "name-hint", "label", true, true, 0, "icon", true, true, -1); + auto entry1 = std::make_shared<Entry>("test-entry-1", "name-hint", 0, "label", true, true, 0, "icon", true, true, -1); sync_data.push_back(entry1); - auto entry2 = std::make_shared<Entry>("test-entry-2", "name-hint", "label", true, true, 0, "icon", true, true, -1); + auto entry2 = std::make_shared<Entry>("test-entry-2", "name-hint", 0, "label", true, true, 0, "icon", true, true, -1); sync_data.push_back(entry2); - auto entry3 = std::make_shared<Entry>("test-entry-3", "name-hint", "label", true, true, 0, "icon", true, true, -1); + auto entry3 = std::make_shared<Entry>("test-entry-3", "name-hint", 0, "label", true, true, 0, "icon", true, true, -1); sync_data.push_back(entry3); EXPECT_CALL(sig_receiver, Updated()); @@ -176,7 +176,7 @@ TEST(TestIndicator, ChildrenSignalShowMenu) Indicator indicator("indicator-test"); SigReceiver::Nice sig_receiver(indicator); - auto entry = std::make_shared<Entry>("test-entry-1", "name-hint", "label", true, true, 0, "icon", true, true, -1); + auto entry = std::make_shared<Entry>("test-entry-1", "name-hint", 0, "label", true, true, 0, "icon", true, true, -1); indicator.Sync({entry}); EXPECT_CALL(sig_receiver, ShowMenu(entry->id(), 123456789, 50, 100, 2)); @@ -194,7 +194,7 @@ TEST(TestIndicator, ChildrenSignalSecondaryActivate) Indicator indicator("indicator-test"); SigReceiver::Nice sig_receiver(indicator); - auto entry = std::make_shared<Entry>("test-entry-2", "name-hint", "label", true, true, 0, "icon", true, true, -1); + auto entry = std::make_shared<Entry>("test-entry-2", "name-hint", 0, "label", true, true, 0, "icon", true, true, -1); indicator.Sync({entry}); EXPECT_CALL(sig_receiver, SecondaryActivate(entry->id())); @@ -206,7 +206,7 @@ TEST(TestIndicator, ChildrenSignalScroll) Indicator indicator("indicator-test"); SigReceiver::Nice sig_receiver(indicator); - auto entry = std::make_shared<Entry>("test-entry-2", "name-hint", "label", true, true, 0, "icon", true, true, -1); + auto entry = std::make_shared<Entry>("test-entry-2", "name-hint", 0, "label", true, true, 0, "icon", true, true, -1); indicator.Sync({entry}); EXPECT_CALL(sig_receiver, Scroll(entry->id(), -5)); diff --git a/tests/test_indicator_entry.cpp b/tests/test_indicator_entry.cpp index 098de8dce..1809f0191 100644 --- a/tests/test_indicator_entry.cpp +++ b/tests/test_indicator_entry.cpp @@ -36,11 +36,12 @@ struct SigReceiver : sigc::trackable TEST(TestIndicatorEntry, TestConstruction) { - Entry entry("id", "name_hint", "label", true, true, 1, "some icon", false, true, -1); + Entry entry("id", "name_hint", 12345, "label", true, true, 1, "some icon", false, true, -1); EXPECT_EQ(entry.id(), "id"); - EXPECT_EQ(entry.label(), "label"); EXPECT_EQ(entry.name_hint(), "name_hint"); + EXPECT_EQ(entry.parent_window(), 12345); + EXPECT_EQ(entry.label(), "label"); EXPECT_TRUE(entry.label_sensitive()); EXPECT_TRUE(entry.label_visible()); EXPECT_FALSE(entry.image_sensitive()); @@ -55,10 +56,11 @@ TEST(TestIndicatorEntry, TestConstruction) TEST(TestIndicatorEntry, TestConstructionEmpty) { - Entry entry("id", "name_hint"); + Entry entry("id", "name_hint", 12345); EXPECT_EQ(entry.id(), "id"); EXPECT_EQ(entry.name_hint(), "name_hint"); + EXPECT_EQ(entry.parent_window(), 12345); EXPECT_TRUE(entry.label().empty()); EXPECT_FALSE(entry.label_sensitive()); EXPECT_FALSE(entry.label_visible()); @@ -74,8 +76,8 @@ TEST(TestIndicatorEntry, TestConstructionEmpty) TEST(TestIndicatorEntry, TestAssignment) { - Entry entry("id", "name_hint", "label", true, true, 0, "some icon", false, true, 10); - Entry other_entry("other_id", "other_name_hint", "other_label", false, false, 2, "other icon", true, false, 5); + Entry entry("id", "name_hint", 12345, "label", true, true, 0, "some icon", false, true, 10); + Entry other_entry("other_id", "other_name_hint", 54321, "other_label", false, false, 2, "other icon", true, false, 5); SigReceiver sig_receiver(entry); EXPECT_CALL(sig_receiver, Updated()); @@ -83,6 +85,7 @@ TEST(TestIndicatorEntry, TestAssignment) EXPECT_EQ(entry.id(), "other_id"); EXPECT_EQ(entry.name_hint(), "other_name_hint"); + EXPECT_EQ(entry.parent_window(), 54321); EXPECT_EQ(entry.label(), "other_label"); EXPECT_FALSE(entry.label_sensitive()); EXPECT_FALSE(entry.label_visible()); @@ -95,8 +98,8 @@ TEST(TestIndicatorEntry, TestAssignment) TEST(TestIndicatorEntry, TestShowNowEvents) { - Entry entry("id", "name_hint", "label", true, true, - 0, "some icon", false, true, -1); + Entry entry("id", "name_hint", 0, "label", true, true, + 0, "some icon", false, true, -1); SigReceiver sig_receiver(entry); // Setting show_now to the same value doesn't emit any events. @@ -116,7 +119,7 @@ TEST(TestIndicatorEntry, TestShowNowEvents) TEST(TestIndicatorEntry, TestActiveEvents) { - Entry entry("id", "name_hint", "label", true, true, 0, "some icon", false, true, -1); + Entry entry("id", "name_hint", 0, "label", true, true, 0, "some icon", false, true, -1); SigReceiver sig_receiver(entry); @@ -137,7 +140,7 @@ TEST(TestIndicatorEntry, TestActiveEvents) TEST(TestIndicatorEntry, TestOnScroll) { - Entry entry("id", "name_hint", "label", true, true, 0, "some icon", false, true, -1); + Entry entry("id", "name_hint", 0, "label", true, true, 0, "some icon", false, true, -1); SigReceiver sig_receiver(entry); EXPECT_CALL(sig_receiver, OnScroll("id", 10)); @@ -149,16 +152,16 @@ TEST(TestIndicatorEntry, TestOnScroll) TEST(TestIndicatorEntry, TestOnShowMenu) { - Entry entry("id", "name_hint", "label", true, true, 0, "some icon", false, true, -1); + Entry entry("id", "name_hint", 123, "label", true, true, 0, "some icon", false, true, -1); SigReceiver sig_receiver(entry); - EXPECT_CALL(sig_receiver, OnShowMenu("id", 0, 10, 20, 1)); + EXPECT_CALL(sig_receiver, OnShowMenu("id", 123, 10, 20, 1)); entry.ShowMenu(10, 20, 1); } TEST(TestIndicatorEntry, TestOnShowMenuXid) { - Entry entry("xid", "name_hint", "label", true, true, 0, "some icon", false, true, -1); + Entry entry("xid", "name_hint", 0, "label", true, true, 0, "some icon", false, true, -1); SigReceiver sig_receiver(entry); EXPECT_CALL(sig_receiver, OnShowMenu("xid", 88492615, 15, 25, 2)); @@ -167,7 +170,7 @@ TEST(TestIndicatorEntry, TestOnShowMenuXid) TEST(TestIndicatorEntry, TestVisibility) { - Entry entry("id", "name_hint", "label", true, true, 0, "some icon", false, false, -1); + Entry entry("id", "name_hint", 0, "label", true, true, 0, "some icon", false, false, -1); EXPECT_TRUE(entry.visible()); @@ -208,7 +211,7 @@ TEST(TestIndicatorEntry, TestVisibility) TEST(TestIndicatorEntry, TestGeometry) { - Entry entry("id", "name_hint", "label", true, true, 0, "some icon", false, true, -1); + Entry entry("id", "name_hint", 0, "label", true, true, 0, "some icon", false, true, -1); SigReceiver sig_receiver(entry); // Setting to the same value doesn't emit any events. diff --git a/tests/test_indicators.cpp b/tests/test_indicators.cpp index 7ff76c8ff..655e8b428 100644 --- a/tests/test_indicators.cpp +++ b/tests/test_indicators.cpp @@ -62,15 +62,15 @@ struct TestIndicators : Test Indicator::Ptr test_indicator_1 = indicators.AddIndicator("indicator-test-1"); - entry = new Entry("indicator-test-1|entry-1", "name-hint-1", "label", true, true, + entry = new Entry("indicator-test-1|entry-1", "name-hint-1", 0, "label", true, true, 0, "icon", true, true, -1); sync_data.push_back(Entry::Ptr(entry)); - entry = new Entry("indicator-test-1|entry-2", "name-hint-2", "label", true, true, + entry = new Entry("indicator-test-1|entry-2", "name-hint-2", 0, "label", true, true, 0, "icon", true, true, -1); sync_data.push_back(Entry::Ptr(entry)); - entry = new Entry("indicator-test-1|entry-3", "name-hint-3", "label", true, true, + entry = new Entry("indicator-test-1|entry-3", "name-hint-3", 0, "label", true, true, 0, "icon", true, true, -1); sync_data.push_back(Entry::Ptr(entry)); @@ -83,11 +83,11 @@ struct TestIndicators : Test Indicator::Ptr test_indicator_2 = indicators.AddIndicator("indicator-test-2"); sync_data.clear(); - entry = new Entry("indicator-test-2|entry-1", "name-hint-1", "label", true, true, + entry = new Entry("indicator-test-2|entry-1", "name-hint-1", 0, "label", true, true, 0, "icon", true, true, -1); sync_data.push_back(Entry::Ptr(entry)); - entry = new Entry("indicator-test-2|entry-2", "name-hint-2", "label", true, true, + entry = new Entry("indicator-test-2|entry-2", "name-hint-2", 0, "label", true, true, 0, "icon", true, true, -1); sync_data.push_back(Entry::Ptr(entry)); diff --git a/tests/test_panel_service.cpp b/tests/test_panel_service.cpp index 14d3d0e4a..9199a018f 100644 --- a/tests/test_panel_service.cpp +++ b/tests/test_panel_service.cpp @@ -46,6 +46,7 @@ struct TestPanelService : Test std::string indicator_id; std::string entry_id; std::string entry_name_hint; + uint32_t parent_window; std::string label; bool label_sensitive; bool label_visible; @@ -63,6 +64,7 @@ struct TestPanelService : Test gchar* indicator_id; gchar* entry_id; gchar* entry_name_hint; + guint32 parent_window; gchar* label; gboolean label_sensitive; gboolean label_visible; @@ -77,6 +79,7 @@ struct TestPanelService : Test &indicator_id, &entry_id, &entry_name_hint, + &parent_window, &label, &label_sensitive, &label_visible, @@ -89,6 +92,7 @@ struct TestPanelService : Test results.push_back({ glib::gchar_to_string(indicator_id), glib::gchar_to_string(entry_id), glib::gchar_to_string(entry_name_hint), + parent_window, glib::gchar_to_string(label), label_sensitive != FALSE, label_visible != FALSE, diff --git a/tests/test_service_panel.cpp b/tests/test_service_panel.cpp index d55222f6c..eca0ba7a5 100644 --- a/tests/test_service_panel.cpp +++ b/tests/test_service_panel.cpp @@ -39,6 +39,7 @@ void add_entry_id(GVariantBuilder *b) "test_indicator_id", "test_entry_id", "test_entry_name_hint", + 0, /* parent window */ "test_entry_label", TRUE, /* label sensitive */ TRUE, /* label visible */ @@ -55,6 +56,7 @@ void add_entry_id_2(GVariantBuilder *b) "test_indicator_id", "test_entry_id2", "test_entry_name_hint2", + 12345, /* parent window */ "test_entry_label2", TRUE, /* label sensitive */ TRUE, /* label visible */ |
