diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2012-05-21 17:30:30 +0200 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2012-05-21 17:30:30 +0200 |
| commit | ff9a9ce351d6d6816ed0b49b1902cc1e4ad0d82b (patch) | |
| tree | c0d8ab7bfe94e2c4d0334fbf07ef90e8f3300e0a | |
| parent | 72d9d1f75f7016e389959a7bbcad6e6b5ca148ea (diff) | |
Merging fix for "Missing GIMP icon bug"
(bzr r2348.2.2)
| -rw-r--r-- | plugins/unityshell/src/BamfLauncherIcon.cpp | 42 | ||||
| -rw-r--r-- | plugins/unityshell/src/BamfLauncherIcon.h | 2 | ||||
| -rw-r--r-- | tests/autopilot/autopilot/tests/__init__.py | 5 | ||||
| -rw-r--r-- | tests/autopilot/autopilot/tests/test_launcher.py | 14 |
4 files changed, 59 insertions, 4 deletions
diff --git a/plugins/unityshell/src/BamfLauncherIcon.cpp b/plugins/unityshell/src/BamfLauncherIcon.cpp index 0561954c2..ec4f7b639 100644 --- a/plugins/unityshell/src/BamfLauncherIcon.cpp +++ b/plugins/unityshell/src/BamfLauncherIcon.cpp @@ -55,7 +55,7 @@ BamfLauncherIcon::BamfLauncherIcon(BamfApplication* app) , _window_moved_id(0) { g_object_set_qdata(G_OBJECT(app), g_quark_from_static_string("unity-seen"), - GINT_TO_POINTER(1)); + GUINT_TO_POINTER(1)); auto bamf_view = glib::object_cast<BamfView>(_bamf_app); glib::String icon(bamf_view_get_icon(bamf_view)); @@ -101,10 +101,17 @@ BamfLauncherIcon::BamfLauncherIcon(BamfApplication* app) sig = new glib::Signal<void, BamfView*, gboolean>(bamf_view, "running-changed", [&] (BamfView*, gboolean running) { SetQuirk(QUIRK_RUNNING, running); + if (running) { EnsureWindowState(); UpdateIconGeometries(GetCenters()); + + if (_remove_timeout_id) + { + g_source_remove(_remove_timeout_id); + _remove_timeout_id = 0; + } } }); _gsignals.Add(sig); @@ -119,7 +126,23 @@ BamfLauncherIcon::BamfLauncherIcon(BamfApplication* app) sig = new glib::Signal<void, BamfView*>(bamf_view, "closed", [&] (BamfView*) { if (!IsSticky()) - Remove(); + { + /* Use a timeout to remove the icon, this avoids + * that we remove an application that is going + * to be reopened soon. So applications that + * have a splash screen won't be removed from + * the launcher while the splash is closed and + * a new window is opened. */ + if (_remove_timeout_id) + g_source_remove(_remove_timeout_id); + + _remove_timeout_id = g_timeout_add_seconds(1, [] (gpointer data) -> gboolean { + auto self = static_cast<BamfLauncherIcon*>(data); + self->Remove(); + self->_remove_timeout_id = 0; + return false; + }, this); + } }); _gsignals.Add(sig); @@ -147,6 +170,9 @@ BamfLauncherIcon::~BamfLauncherIcon() g_object_set_qdata(G_OBJECT(_bamf_app.RawPtr()), g_quark_from_static_string("unity-seen"), nullptr); + if (_remove_timeout_id != 0) + g_source_remove(_remove_timeout_id); + if (_fill_supported_types_id != 0) g_source_remove(_fill_supported_types_id); @@ -160,6 +186,18 @@ BamfLauncherIcon::~BamfLauncherIcon() g_source_remove(_dnd_hover_timer); } +void BamfLauncherIcon::Remove() +{ + /* Removing the unity-seen flag to the wrapped bamf application, on remove + * request we make sure that if the bamf application is re-opened while + * the removal process is still ongoing, the application will be shown + * on the launcher. */ + g_object_set_qdata(G_OBJECT(_bamf_app.RawPtr()), + g_quark_from_static_string("unity-seen"), nullptr); + + SimpleLauncherIcon::Remove(); +} + bool BamfLauncherIcon::IsSticky() const { return bamf_view_is_sticky(BAMF_VIEW(_bamf_app.RawPtr())); diff --git a/plugins/unityshell/src/BamfLauncherIcon.h b/plugins/unityshell/src/BamfLauncherIcon.h index 279e8a8a2..471e8760c 100644 --- a/plugins/unityshell/src/BamfLauncherIcon.h +++ b/plugins/unityshell/src/BamfLauncherIcon.h @@ -66,6 +66,7 @@ public: std::string NameForWindow(Window window); protected: + void Remove(); void UpdateIconGeometries(std::vector<nux::Point3> center); void OnCenterStabilized(std::vector<nux::Point3> center); void AddProperties(GVariantBuilder* builder); @@ -124,6 +125,7 @@ private: guint _dnd_hover_timer; bool _supported_types_filled; + guint _remove_timeout_id; guint _fill_supported_types_id; guint _window_moved_id; guint _quicklist_activated_id; diff --git a/tests/autopilot/autopilot/tests/__init__.py b/tests/autopilot/autopilot/tests/__init__.py index e8ed05af0..f6dd1d47d 100644 --- a/tests/autopilot/autopilot/tests/__init__.py +++ b/tests/autopilot/autopilot/tests/__init__.py @@ -277,8 +277,9 @@ class AutopilotTestCase(VideoCapturedTestCase, KeybindingsHelper): def close_all_app(self, app_name): """Close all instances of the app_name.""" app = self.KNOWN_APPS[app_name] - self.addCleanup(call, "kill `pidof %s`" % (app['process-name']), shell=True) - super(LoggedTestCase, self).tearDown() + pids = check_output(["pidof", app['process-name']]).split() + if len(pids): + call(["kill"] + pids) def get_app_instances(self, app_name): """Get BamfApplication instances for app_name.""" diff --git a/tests/autopilot/autopilot/tests/test_launcher.py b/tests/autopilot/autopilot/tests/test_launcher.py index 291e01e7b..b26aa336f 100644 --- a/tests/autopilot/autopilot/tests/test_launcher.py +++ b/tests/autopilot/autopilot/tests/test_launcher.py @@ -445,6 +445,20 @@ class LauncherIconsBehaviorTests(LauncherTestCase): self.assertTrue(mah_win2.is_hidden) self.assertVisibleWindowStack([mah_win1, calc_win]) + def test_icon_shows_on_quick_application_reopen(self): + """Icons should stay on launcher when an application is quickly closed/reopened.""" + calc = self.start_app("Calculator") + desktop_file = calc.desktop_file + calc_icon = self.launcher.model.get_icon_by_desktop_id(desktop_file) + self.assertThat(calc_icon.visible, Eventually(Equals(True))) + + self.close_all_app("Calculator") + calc = self.start_app("Calculator") + sleep(2) + + calc_icon = self.launcher.model.get_icon_by_desktop_id(desktop_file) + self.assertThat(calc_icon, NotEquals(None)) + self.assertThat(calc_icon.visible, Eventually(Equals(True))) class LauncherRevealTests(LauncherTestCase): """Test the launcher reveal behavior when in autohide mode.""" |
