Merge lp:~3v1n0/unity/fix-690143-v2 into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Jason Smith
Approved revision: no longer in the source branch.
Merged at revision: 1657
Proposed branch: lp:~3v1n0/unity/fix-690143-v2
Merge into: lp:unity
Diff against target: 115 lines (+43/-7)
2 files modified
plugins/unityshell/src/BamfLauncherIcon.cpp (+39/-6)
plugins/unityshell/src/BamfLauncherIcon.h (+4/-1)
To merge this branch: bzr merge lp:~3v1n0/unity/fix-690143-v2
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+77296@code.launchpad.net

Description of the change

Improve the fix for the bug #690143

With the current code if you switch viewport of a window using the alt+space window decoration controls, then the launcher icon won't update its indicator to show if the windows are or not in the current viewport.

This patch fixes this issue.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/BamfLauncherIcon.cpp'
2--- plugins/unityshell/src/BamfLauncherIcon.cpp 2011-09-27 03:41:15 +0000
3+++ plugins/unityshell/src/BamfLauncherIcon.cpp 2011-09-28 23:23:17 +0000
4@@ -140,6 +140,7 @@
5 _launcher = IconManager;
6 _menu_desktop_shortcuts = NULL;
7 _on_desktop_file_changed_handler_id = 0;
8+ _window_moved_id = 0;
9 char* icon_name = bamf_view_get_icon(BAMF_VIEW(m_App));
10
11 tooltip_text = BamfName();
12@@ -172,6 +173,7 @@
13 UpdateDesktopFile();
14
15 WindowManager::Default()->window_minimized.connect(sigc::mem_fun(this, &BamfLauncherIcon::OnWindowMinimized));
16+ WindowManager::Default()->window_moved.connect(sigc::mem_fun(this, &BamfLauncherIcon::OnWindowMoved));
17 WindowManager::Default()->compiz_screen_viewport_switch_ended.connect(sigc::mem_fun(this, &BamfLauncherIcon::OnViewPortSwitchEnded));
18 WindowManager::Default()->terminate_expo.connect(sigc::mem_fun(this, &BamfLauncherIcon::OnViewPortSwitchEnded));
19 IconManager->hidden_changed.connect(sigc::mem_fun(this, &BamfLauncherIcon::OnLauncherHiddenChanged));
20@@ -302,10 +304,12 @@
21 UpdateQuirkTimeDelayed(300, QUIRK_SHIMMER);
22 }
23
24-void BamfLauncherIcon::OnViewPortSwitchEnded()
25+gboolean BamfLauncherIcon::OnWindowMovedTimeout(BamfLauncherIcon* self)
26 {
27+ GList *children = bamf_view_get_children(BAMF_VIEW(self->m_App));
28+
29 bool any_on_current = false;
30- GList *children = bamf_view_get_children(BAMF_VIEW(m_App));
31+ bool found_moved = (self->_window_moved_xid != 0 ? false : true);
32
33 for (GList *l = children; l; l = l->next)
34 {
35@@ -314,17 +318,46 @@
36 if (BAMF_IS_WINDOW(view))
37 {
38 Window xid = bamf_window_get_xid(BAMF_WINDOW(view));
39+
40+ if (self->_window_moved_xid == xid)
41+ found_moved = true;
42+
43 if (WindowManager::Default()->IsWindowOnCurrentDesktop(xid))
44- {
45 any_on_current = true;
46+
47+ if (found_moved && any_on_current)
48 break;
49- }
50 }
51 }
52
53- SetHasWindowOnViewport(any_on_current);
54-
55+ self->SetHasWindowOnViewport(any_on_current);
56+ self->_window_moved_id = 0;
57 g_list_free(children);
58+
59+ return FALSE;
60+}
61+
62+void BamfLauncherIcon::OnWindowMoved(guint32 moved_win)
63+{
64+ if (_window_moved_id != 0)
65+ g_source_remove(_window_moved_id);
66+
67+ _window_moved_xid = moved_win;
68+
69+ if (_window_moved_xid == 0)
70+ {
71+ OnWindowMovedTimeout(this);
72+ }
73+ else
74+ {
75+ _window_moved_id = g_timeout_add(250,
76+ (GSourceFunc)BamfLauncherIcon::OnWindowMovedTimeout, this);
77+ }
78+}
79+
80+void BamfLauncherIcon::OnViewPortSwitchEnded()
81+{
82+ OnWindowMoved(0);
83 }
84
85 bool BamfLauncherIcon::IsSticky()
86
87=== modified file 'plugins/unityshell/src/BamfLauncherIcon.h'
88--- plugins/unityshell/src/BamfLauncherIcon.h 2011-09-28 21:46:40 +0000
89+++ plugins/unityshell/src/BamfLauncherIcon.h 2011-09-28 23:23:17 +0000
90@@ -99,6 +99,8 @@
91 std::set<std::string> _supported_types;
92 bool _supported_types_filled;
93 guint _fill_supported_types_id;
94+ guint32 _window_moved_id;
95+ guint32 _window_moved_xid;
96
97 void EnsureWindowState();
98
99@@ -113,6 +115,7 @@
100 void EnsureMenuItemsReady();
101
102 void OnWindowMinimized(guint32 xid);
103+ void OnWindowMoved(guint32 xid);
104 void OnViewPortSwitchEnded();
105 bool OwnsWindow(Window w);
106
107@@ -138,7 +141,7 @@
108
109 static gboolean OnDndHoveredTimeout(gpointer data);
110 static gboolean FillSupportedTypes(gpointer data);
111+ static gboolean OnWindowMovedTimeout(BamfLauncherIcon *self);
112 };
113
114 #endif // BAMFLAUNCHERICON_H
115-