Merge lp:~azzar1/unity/fix-1003950 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Martin Mrazik
Approved revision: no longer in the source branch.
Merged at revision: 3021
Proposed branch: lp:~azzar1/unity/fix-1003950
Merge into: lp:unity
Diff against target: 678 lines (+443/-37)
8 files modified
tests/CMakeLists.txt (+3/-1)
tests/bamf-mock-window.c (+239/-0)
tests/bamf-mock-window.h (+80/-0)
tests/mock-application.h (+6/-0)
tests/test_bamf_application.cpp (+86/-0)
unity-shared/ApplicationManager.h (+3/-0)
unity-shared/BamfApplicationManager.cpp (+12/-20)
unity-shared/BamfApplicationManager.h (+14/-16)
To merge this branch: bzr merge lp:~azzar1/unity/fix-1003950
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Marco Trevisan (Treviño) Approve
Review via email: mp+140781@code.launchpad.net

Commit message

Include unmapped windows in unity::bamf::Application::GetWindows too.

Description of the change

== Problem ==
Launcher does not show minimized update manager while clicked.

== Fix ==
Include unmapped windows in unity::bamf::Application::GetWindows too.

== Test ==
Unit test added.

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

76 +bamf_mock_window_set_transient (BamfMockWindow *self, BamfWindow* transient)
77 +{
78 + g_return_if_fail (BAMF_IS_MOCK_WINDOW (self));
79 + self->priv->transient = g_object_ref(transient);
80 +}

Mhmh... Probably it's better not to ref it here, since the parent window can be also closed... Probably it's better to add a weak ref instead.

Revision history for this message
Andrea Azzarone (azzar1) wrote :

> 76 +bamf_mock_window_set_transient (BamfMockWindow *self, BamfWindow*
> transient)
> 77 +{
> 78 + g_return_if_fail (BAMF_IS_MOCK_WINDOW (self));
> 79 + self->priv->transient = g_object_ref(transient);
> 80 +}
>
> Mhmh... Probably it's better not to ref it here, since the parent window can
> be also closed... Probably it's better to add a weak ref instead.

Done.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Ops, I think you removed too much. You still need to do
  self->priv->transient = transient;

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Looks good, thanks!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Andrea Azzarone (azzar1) wrote :

> FAILED: Autolanding.
> More details in the following jenkins job:
> http://jenkins.qa.ubuntu.com/job/unity-mbs-autolanding/281/
> Executed test runs:
> FAILURE: http://jenkins.qa.ubuntu.com/job/unity-mbs-
> autolanding/./build=pbuilder,distribution=raring,flavor=amd64/281/console
> FAILURE: http://jenkins.qa.ubuntu.com/job/unity-mbs-
> autolanding/./build=pbuilder,distribution=raring,flavor=i386/281/console

Are we still building with old bamf?

Revision history for this message
Martin Mrazik (mrazik) wrote :

Just for the reference -- yes, it was building with old bamf package. Re-approve fixed it.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2013-01-03 10:25:49 +0000
+++ tests/CMakeLists.txt 2013-01-07 16:54:25 +0000
@@ -191,6 +191,7 @@
191 test_main.cpp191 test_main.cpp
192 test_action_link.cpp192 test_action_link.cpp
193 test_application_launcher_icon.cpp193 test_application_launcher_icon.cpp
194 test_bamf_application.cpp
194 test_bfb_launcher_icon.cpp195 test_bfb_launcher_icon.cpp
195 test_dashview_impl.cpp196 test_dashview_impl.cpp
196 test_dash_controller.cpp197 test_dash_controller.cpp
@@ -246,12 +247,13 @@
246 test_xdnd_manager_imp.cpp247 test_xdnd_manager_imp.cpp
247 test_xdnd_start_stop_notifier_imp.cpp248 test_xdnd_start_stop_notifier_imp.cpp
248 bamf-mock-application.c249 bamf-mock-application.c
250 bamf-mock-window.c
249 gmockmount.c251 gmockmount.c
250 gmockvolume.c252 gmockvolume.c
251 ${UNITY_SRC}/UnityShowdesktopHandler.cpp253 ${UNITY_SRC}/UnityShowdesktopHandler.cpp
252 ${CMAKE_SOURCE_DIR}/plugins/unityshell/src/WindowMinimizeSpeedController.cpp254 ${CMAKE_SOURCE_DIR}/plugins/unityshell/src/WindowMinimizeSpeedController.cpp
253 )255 )
254 target_link_libraries(test-gtest gtest gmock unity-shared ${LIBS} launcher-lib unity-shared-standalone shortcuts-lib previews-lib hud-lib switcher-lib dash-lib panel-lib)256 target_link_libraries(test-gtest gtest gmock unity-shared ${LIBS} launcher-lib unity-shared-bamf unity-shared-standalone shortcuts-lib previews-lib hud-lib switcher-lib dash-lib panel-lib)
255 add_test(UnityGTest test-gtest)257 add_test(UnityGTest test-gtest)
256endif (ENABLE_X_SUPPORT)258endif (ENABLE_X_SUPPORT)
257endif (GTEST_SRC_DIR AND259endif (GTEST_SRC_DIR AND
258260
=== added file 'tests/bamf-mock-window.c'
--- tests/bamf-mock-window.c 1970-01-01 00:00:00 +0000
+++ tests/bamf-mock-window.c 2013-01-07 16:54:25 +0000
@@ -0,0 +1,239 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright 2012 Canonical Ltd.
4 *
5 * This program is free software: you can redistribute it and/or modify it
6 * under the terms of the GNU Lesser General Public License version 3, as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranties of
11 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the applicable version of the GNU Lesser General Public
13 * License for more details.
14 *
15 * You should have received a copy of both the GNU Lesser General Public
16 * License version 3 along with this program. If not, see
17 * <http://www.gnu.org/licenses/>
18 *
19 * Authored by: Andrea Azzaronea <andrea.azzarone@canonical>
20 *
21 */
22
23#include <glib.h>
24
25#include "bamf-mock-window.h"
26
27G_DEFINE_TYPE (BamfMockWindow, bamf_mock_window, BAMF_TYPE_WINDOW);
28
29#define BAMF_MOCK_WINDOW_GET_PRIVATE(o) \
30 (G_TYPE_INSTANCE_GET_PRIVATE ((o), BAMF_TYPE_MOCK_WINDOW, BamfMockWindowPrivate))
31
32struct _BamfMockWindowPrivate
33{
34 BamfWindow* transient;
35 BamfWindowType window_type;
36 guint32 xid;
37 guint32 pid;
38 gint monitor;
39 GHashTable* props;
40 BamfWindowMaximizationType maximized;
41 time_t last_active;
42};
43
44void
45bamf_mock_window_set_transient (BamfMockWindow *self, BamfWindow* transient)
46{
47 g_return_if_fail (BAMF_IS_MOCK_WINDOW (self));
48
49 self->priv->transient = transient;
50 g_object_add_weak_pointer (G_OBJECT (self->priv->transient), (gpointer *) &self->priv->transient);
51}
52
53void
54bamf_mock_window_set_window_type (BamfMockWindow *self, BamfWindowType window_type)
55{
56 g_return_if_fail (BAMF_IS_MOCK_WINDOW (self));
57 self->priv->window_type = window_type;
58}
59
60void
61bamf_mock_window_set_xid (BamfMockWindow *self, guint32 xid)
62{
63 g_return_if_fail (BAMF_IS_MOCK_WINDOW (self));
64 self->priv->xid = xid;
65}
66
67void
68bamf_mock_window_set_pid (BamfMockWindow *self, guint32 pid)
69{
70 g_return_if_fail (BAMF_IS_MOCK_WINDOW (self));
71 self->priv->pid = pid;
72}
73
74void
75bamf_mock_window_set_monitor (BamfMockWindow *self, gint monitor)
76{
77 g_return_if_fail (BAMF_IS_MOCK_WINDOW (self));
78
79 if (self->priv->monitor != monitor)
80 {
81 gint old_value = self->priv->monitor;
82 self->priv->monitor = monitor;
83 g_signal_emit_by_name (G_OBJECT (self), "monitor-changed", old_value, monitor, NULL);
84 }
85}
86
87void
88bamf_mock_window_set_utf8_prop (BamfMockWindow *self, const char* prop, const char* value)
89{
90 g_return_if_fail (BAMF_IS_MOCK_WINDOW (self));
91
92 g_hash_table_insert(self->priv->props, g_strdup(prop), g_strdup(value));
93}
94
95void
96bamf_mock_window_set_maximized (BamfMockWindow *self, BamfWindowMaximizationType maximized)
97{
98 g_return_if_fail (BAMF_IS_MOCK_WINDOW (self));
99
100 if (self->priv->maximized != maximized)
101 {
102 BamfWindowMaximizationType old_value = self->priv->maximized;
103 self->priv->maximized = maximized;
104 g_signal_emit_by_name (G_OBJECT (self), "maximized-changed", old_value, maximized, NULL);
105 }
106}
107
108void bamf_mock_window_set_last_active (BamfMockWindow *self, time_t last_active)
109{
110 g_return_if_fail (BAMF_IS_MOCK_WINDOW (self));
111 self->priv->last_active = last_active;
112}
113
114static void
115bamf_mock_window_finalize (GObject *object)
116{
117 BamfMockWindow *self = BAMF_MOCK_WINDOW (object);
118
119 if (self->priv->transient)
120 {
121 g_object_remove_weak_pointer(G_OBJECT (self->priv->transient), (gpointer *) &self->priv->transient);
122 self->priv->transient = NULL;
123 }
124
125
126 if (self->priv->props)
127 {
128 g_hash_table_unref (self->priv->props);
129 self->priv->props = NULL;
130 }
131}
132
133static BamfWindow *
134bamf_mock_window_get_transient (BamfWindow *window)
135{
136 g_return_val_if_fail (BAMF_IS_MOCK_WINDOW (window), NULL);
137 BamfMockWindow *self = BAMF_MOCK_WINDOW (window);
138 return self->priv->transient;
139}
140
141static BamfWindowType
142bamf_mock_window_get_window_type (BamfWindow *window)
143{
144 g_return_val_if_fail (BAMF_IS_MOCK_WINDOW (window), BAMF_WINDOW_NORMAL);
145 BamfMockWindow *self = BAMF_MOCK_WINDOW (window);
146 return self->priv->window_type;
147}
148
149static guint32
150bamf_mock_window_get_xid (BamfWindow *window)
151{
152 g_return_val_if_fail (BAMF_IS_MOCK_WINDOW (window), 0);
153 BamfMockWindow *self = BAMF_MOCK_WINDOW (window);
154 return self->priv->xid;
155}
156
157static guint32
158bamf_mock_window_get_pid (BamfWindow *window)
159{
160 g_return_val_if_fail (BAMF_IS_MOCK_WINDOW (window), 0);
161 BamfMockWindow *self = BAMF_MOCK_WINDOW (window);
162 return self->priv->pid;
163}
164
165static gint
166bamf_mock_window_get_monitor (BamfWindow *window)
167{
168 g_return_val_if_fail (BAMF_IS_MOCK_WINDOW (window), BAMF_WINDOW_NORMAL);
169 BamfMockWindow *self = BAMF_MOCK_WINDOW (window);
170 return self->priv->monitor;
171}
172
173static gchar *
174bamf_mock_window_get_utf8_prop (BamfWindow *window, const char* prop)
175{
176 g_return_val_if_fail (BAMF_IS_MOCK_WINDOW (window), BAMF_WINDOW_NORMAL);
177 BamfMockWindow *self = BAMF_MOCK_WINDOW (window);
178
179 if (g_hash_table_lookup(self->priv->props, prop))
180 return g_strdup(g_hash_table_lookup(self->priv->props, prop));
181
182 return NULL;
183}
184
185static BamfWindowMaximizationType
186bamf_mock_window_maximized (BamfWindow *window)
187{
188 g_return_val_if_fail (BAMF_IS_MOCK_WINDOW (window), BAMF_WINDOW_FLOATING);
189 BamfMockWindow *self = BAMF_MOCK_WINDOW (window);
190 return self->priv->maximized;
191}
192
193static time_t
194bamf_mock_window_last_active (BamfWindow *window)
195{
196 g_return_val_if_fail (BAMF_IS_MOCK_WINDOW (window), 0);
197 BamfMockWindow *self = BAMF_MOCK_WINDOW (window);
198 return self->priv->last_active;
199}
200
201static void
202bamf_mock_window_class_init (BamfMockWindowClass *klass)
203{
204 GObjectClass *obj_class = G_OBJECT_CLASS (klass);
205 BamfWindowClass *window_class = BAMF_WINDOW_CLASS (klass);
206
207 obj_class->finalize = bamf_mock_window_finalize;
208 window_class->get_transient = bamf_mock_window_get_transient;
209 window_class->get_window_type = bamf_mock_window_get_window_type;
210 window_class->get_xid = bamf_mock_window_get_xid;
211 window_class->get_pid = bamf_mock_window_get_pid;
212 window_class->get_monitor = bamf_mock_window_get_monitor;
213 window_class->get_utf8_prop = bamf_mock_window_get_utf8_prop;
214 window_class->maximized = bamf_mock_window_maximized;
215 window_class->last_active = bamf_mock_window_last_active;
216
217 g_type_class_add_private (obj_class, sizeof (BamfMockWindowPrivate));
218}
219
220static void
221bamf_mock_window_init (BamfMockWindow *self)
222{
223 self->priv = BAMF_MOCK_WINDOW_GET_PRIVATE (self);
224
225 self->priv->transient = NULL;
226 self->priv->window_type = BAMF_WINDOW_NORMAL;
227 self->priv->xid = 0;
228 self->priv->pid = 0;
229 self->priv->monitor = 0;
230 self->priv->props = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
231 self->priv->maximized = BAMF_WINDOW_FLOATING;
232 self->priv->last_active = 0;
233}
234
235BamfMockWindow *
236bamf_mock_window_new ()
237{
238 return g_object_new (BAMF_TYPE_MOCK_WINDOW, NULL);
239}
0240
=== added file 'tests/bamf-mock-window.h'
--- tests/bamf-mock-window.h 1970-01-01 00:00:00 +0000
+++ tests/bamf-mock-window.h 2013-01-07 16:54:25 +0000
@@ -0,0 +1,80 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright 2012 Canonical Ltd.
4 *
5 * This program is free software: you can redistribute it and/or modify it
6 * under the terms of the GNU Lesser General Public License version 3, as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranties of
11 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the applicable version of the GNU Lesser General Public
13 * License for more details.
14 *
15 * You should have received a copy of both the GNU Lesser General Public
16 * License version 3 along with this program. If not, see
17 * <http://www.gnu.org/licenses/>
18 *
19 * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
20 *
21 */
22
23#ifndef MOCK_BAMF_MOCK_WINDOW
24#define MOCK_BAMF_MOCK_WINDOW
25
26#include <time.h>
27#include <glib-object.h>
28#include <libbamf/libbamf.h>
29
30G_BEGIN_DECLS
31
32#define BAMF_TYPE_MOCK_WINDOW (bamf_mock_window_get_type ())
33
34#define BAMF_MOCK_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\
35 BAMF_TYPE_MOCK_WINDOW, BamfMockWindow))
36
37#define BAMF_MOCK_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),\
38 BAMF_TYPE_MOCK_WINDOW, BamfMockWindowClass))
39
40#define BAMF_IS_MOCK_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
41 BAMF_TYPE_MOCK_WINDOW))
42
43#define BAMF_IS_MOCK_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\
44 BAMF_TYPE_MOCK_WINDOW))
45
46#define BAMF_MOCK_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\
47 BAMF_TYPE_MOCK_WINDOW, BamfMockWindowClass))
48
49typedef struct _BamfMockWindow BamfMockWindow;
50typedef struct _BamfMockWindowClass BamfMockWindowClass;
51typedef struct _BamfMockWindowPrivate BamfMockWindowPrivate;
52
53struct _BamfMockWindow
54{
55 BamfWindow parent;
56
57 BamfMockWindowPrivate *priv;
58};
59
60struct _BamfMockWindowClass
61{
62 BamfWindowClass parent_class;
63};
64
65GType bamf_mock_window_get_type (void) G_GNUC_CONST;
66
67BamfMockWindow * bamf_mock_window_new ();
68
69void bamf_mock_window_set_transient (BamfMockWindow *self, BamfWindow* transient);
70void bamf_mock_window_set_window_type (BamfMockWindow *self, BamfWindowType window_type);
71void bamf_mock_window_set_xid (BamfMockWindow *self, guint32 xid);
72void bamf_mock_window_set_pid (BamfMockWindow *self, guint32 pid);
73void bamf_mock_window_set_monitor (BamfMockWindow *self, gint monitor);
74void bamf_mock_window_set_utf8_prop (BamfMockWindow *self, const char* prop, const char* value);
75void bamf_mock_window_set_maximized (BamfMockWindow *self, BamfWindowMaximizationType maximized);
76void bamf_mock_window_set_last_active (BamfMockWindow *self, time_t last_active);
77
78G_END_DECLS
79
80#endif
081
=== modified file 'tests/mock-application.h'
--- tests/mock-application.h 2012-12-18 17:57:48 +0000
+++ tests/mock-application.h 2013-01-07 16:54:25 +0000
@@ -139,6 +139,12 @@
139 {139 {
140 return unity::ApplicationList();140 return unity::ApplicationList();
141 }141 }
142
143 unity::ApplicationPtr GetApplicationForWindow(Window xid)
144 {
145 return unity::ApplicationPtr();
146 }
147
142private:148private:
143 typedef std::map<std::string, unity::ApplicationPtr> AppMap;149 typedef std::map<std::string, unity::ApplicationPtr> AppMap;
144 AppMap app_map_;150 AppMap app_map_;
145151
=== added file 'tests/test_bamf_application.cpp'
--- tests/test_bamf_application.cpp 1970-01-01 00:00:00 +0000
+++ tests/test_bamf_application.cpp 2013-01-07 16:54:25 +0000
@@ -0,0 +1,86 @@
1/*
2 * Copyright 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * version 3 along with this program. If not, see
15 * <http://www.gnu.org/licenses/>
16 *
17 * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
18 */
19
20#include <glib.h>
21#include <gmock/gmock.h>
22
23#include "BamfApplicationManager.h"
24#include "bamf-mock-application.h"
25#include "bamf-mock-window.h"
26#include "StandaloneWindowManager.h"
27
28#include <UnityCore/GLibWrapper.h>
29
30namespace {
31
32struct MockApplicationManager : public unity::ApplicationManager
33{
34 MOCK_METHOD0(GetActiveWindow, unity::ApplicationWindowPtr());
35 MOCK_METHOD1(GetApplicationForDesktopFile, unity::ApplicationPtr(std::string const&));
36 MOCK_METHOD0(GetRunningApplications, unity::ApplicationList());
37 MOCK_METHOD1(GetApplicationForWindow, unity::ApplicationPtr(Window));
38};
39
40unity::StandaloneWindow::Ptr AddFakeWindowToWM(Window xid, bool mapped)
41{
42 auto fake_window = std::make_shared<unity::StandaloneWindow>(xid);
43 fake_window->mapped = mapped;
44
45 unity::StandaloneWindowManager* wm = dynamic_cast<unity::StandaloneWindowManager*>(&unity::WindowManager::Default());
46 wm->AddStandaloneWindow(fake_window);
47
48 return fake_window;
49}
50
51struct TestBamfApplication : public testing::Test
52{
53 TestBamfApplication()
54 : bamf_mock_application_(bamf_mock_application_new())
55 , application_(mock_manager_, unity::glib::object_cast<BamfApplication>(bamf_mock_application_))
56 {}
57
58 MockApplicationManager mock_manager_;
59 unity::glib::Object<BamfMockApplication> bamf_mock_application_;
60 unity::bamf::Application application_;
61};
62
63TEST_F(TestBamfApplication, GetWindows)
64{
65 GList* children = nullptr;
66 for (int i = 0; i<5; ++i)
67 {
68 BamfMockWindow* window = bamf_mock_window_new();
69 bamf_mock_window_set_xid(window, i);
70 children = g_list_append(children, window);
71 }
72 bamf_mock_application_set_children(bamf_mock_application_, children);
73
74 AddFakeWindowToWM(0, true);
75 AddFakeWindowToWM(1, true);
76 AddFakeWindowToWM(2, false);
77 AddFakeWindowToWM(3, true);
78 AddFakeWindowToWM(4, false);
79
80 auto windows = application_.GetWindows();
81 ASSERT_EQ(windows.size(), 5);
82
83 g_list_free_full(children, g_object_unref);
84}
85
86}
0\ No newline at end of file87\ No newline at end of file
188
=== modified file 'unity-shared/ApplicationManager.h'
--- unity-shared/ApplicationManager.h 2012-12-18 17:57:48 +0000
+++ unity-shared/ApplicationManager.h 2013-01-07 16:54:25 +0000
@@ -121,6 +121,9 @@
121121
122 virtual ApplicationList GetRunningApplications() = 0;122 virtual ApplicationList GetRunningApplications() = 0;
123123
124 virtual ApplicationPtr GetApplicationForWindow(Window xid) = 0;
125
126
124 sigc::signal<void, ApplicationPtr const&> application_started;127 sigc::signal<void, ApplicationPtr const&> application_started;
125128
126 sigc::signal<void, ApplicationPtr const&> active_application_changed;129 sigc::signal<void, ApplicationPtr const&> active_application_changed;
127130
=== modified file 'unity-shared/BamfApplicationManager.cpp'
--- unity-shared/BamfApplicationManager.cpp 2012-12-18 17:57:48 +0000
+++ unity-shared/BamfApplicationManager.cpp 2013-01-07 16:54:25 +0000
@@ -37,7 +37,7 @@
3737
38// Due to the way glib handles object inheritance, we need to cast between pointer types.38// Due to the way glib handles object inheritance, we need to cast between pointer types.
39// In order to make the up-call for the base class easy, we pass through a void* for the view.39// In order to make the up-call for the base class easy, we pass through a void* for the view.
40View::View(Manager const& manager, glib::Object<BamfView> const& view)40View::View(ApplicationManager const& manager, glib::Object<BamfView> const& view)
41 : manager_(manager)41 : manager_(manager)
42 , bamf_view_(view)42 , bamf_view_(view)
43{43{
@@ -81,7 +81,7 @@
81}81}
8282
8383
84WindowBase::WindowBase(Manager const& manager,84WindowBase::WindowBase(ApplicationManager const& manager,
85 glib::Object<BamfView> const& window)85 glib::Object<BamfView> const& window)
86 : View(manager, window)86 : View(manager, window)
87{87{
@@ -140,7 +140,7 @@
140}140}
141141
142142
143AppWindow::AppWindow(Manager const& manager, glib::Object<BamfView> const& window)143AppWindow::AppWindow(ApplicationManager const& manager, glib::Object<BamfView> const& window)
144 : WindowBase(manager, window)144 : WindowBase(manager, window)
145 , bamf_window_(glib::object_cast<BamfWindow>(window))145 , bamf_window_(glib::object_cast<BamfWindow>(window))
146{146{
@@ -161,8 +161,8 @@
161{161{
162 // Moderately evil, but better than changing the method to non-const.162 // Moderately evil, but better than changing the method to non-const.
163 // We know that the manager will always be able to be non-const.163 // We know that the manager will always be able to be non-const.
164 Manager& m = const_cast<Manager&>(manager_);164 ApplicationManager& m = const_cast<ApplicationManager&>(manager_);
165 return m.GetApplicationForWindow(bamf_window_);165 return m.GetApplicationForWindow(window_id());
166}166}
167167
168void AppWindow::Quit() const168void AppWindow::Quit() const
@@ -170,7 +170,7 @@
170 WindowManager::Default().Close(window_id());170 WindowManager::Default().Close(window_id());
171}171}
172172
173Tab::Tab(Manager const& manager, glib::Object<BamfView> const& tab)173Tab::Tab(ApplicationManager const& manager, glib::Object<BamfView> const& tab)
174 : WindowBase(manager, tab)174 : WindowBase(manager, tab)
175 , bamf_tab_(glib::object_cast<BamfTab>(tab))175 , bamf_tab_(glib::object_cast<BamfTab>(tab))
176{}176{}
@@ -206,7 +206,7 @@
206}206}
207207
208// Being brutal with this function.208// Being brutal with this function.
209ApplicationWindowPtr create_window(Manager const& manager, glib::Object<BamfView> const& view)209ApplicationWindowPtr create_window(ApplicationManager const& manager, glib::Object<BamfView> const& view)
210{210{
211 ApplicationWindowPtr result;211 ApplicationWindowPtr result;
212 if (view.IsType(BAMF_TYPE_TAB))212 if (view.IsType(BAMF_TYPE_TAB))
@@ -221,14 +221,14 @@
221 return result;221 return result;
222}222}
223223
224Application::Application(Manager const& manager, glib::Object<BamfView> const& app)224Application::Application(ApplicationManager const& manager, glib::Object<BamfView> const& app)
225 : View(manager, app)225 : View(manager, app)
226 , bamf_app_(glib::object_cast<BamfApplication>(app))226 , bamf_app_(glib::object_cast<BamfApplication>(app))
227{227{
228 HookUpEvents();228 HookUpEvents();
229}229}
230230
231Application::Application(Manager const& manager, glib::Object<BamfApplication> const& app)231Application::Application(ApplicationManager const& manager, glib::Object<BamfApplication> const& app)
232 : View(manager, glib::object_cast<BamfView>(app))232 : View(manager, glib::object_cast<BamfView>(app))
233 , bamf_app_(app)233 , bamf_app_(app)
234{234{
@@ -347,21 +347,13 @@
347 if (!bamf_app_)347 if (!bamf_app_)
348 return result;348 return result;
349349
350 WindowManager& wm = WindowManager::Default();
351 std::shared_ptr<GList> children(bamf_view_get_children(bamf_view_), g_list_free);350 std::shared_ptr<GList> children(bamf_view_get_children(bamf_view_), g_list_free);
352 for (GList* l = children.get(); l; l = l->next)351 for (GList* l = children.get(); l; l = l->next)
353 {352 {
354 glib::Object<BamfView> view(BAMF_VIEW(l->data), glib::AddRef());353 glib::Object<BamfView> view(BAMF_VIEW(l->data), glib::AddRef());
355 ApplicationWindowPtr window(create_window(manager_, view));354 ApplicationWindowPtr window(create_window(manager_, view));
356 if (!window)355 if (window)
357 continue;
358
359 Window window_id = window->window_id();
360
361 if (wm.IsWindowMapped(window_id))
362 {
363 result.push_back(window);356 result.push_back(window);
364 }
365 }357 }
366 return result;358 return result;
367}359}
@@ -592,10 +584,10 @@
592 return result;584 return result;
593}585}
594586
595ApplicationPtr Manager::GetApplicationForWindow(glib::Object<BamfWindow> const& window)587ApplicationPtr Manager::GetApplicationForWindow(Window xid)
596{588{
597 ApplicationPtr result;589 ApplicationPtr result;
598 glib::Object<BamfApplication> app(bamf_matcher_get_application_for_window(matcher_, window),590 glib::Object<BamfApplication> app(bamf_matcher_get_application_for_xid(matcher_, xid),
599 glib::AddRef());591 glib::AddRef());
600 if (app)592 if (app)
601 result.reset(new Application(*this, app));593 result.reset(new Application(*this, app));
602594
=== modified file 'unity-shared/BamfApplicationManager.h'
--- unity-shared/BamfApplicationManager.h 2012-12-18 17:57:48 +0000
+++ unity-shared/BamfApplicationManager.h 2013-01-07 16:54:25 +0000
@@ -31,11 +31,10 @@
31{31{
32namespace bamf32namespace bamf
33{33{
34class Manager;
35class View34class View
36{35{
37public:36public:
38 View(Manager const& manager,37 View(ApplicationManager const& manager,
39 glib::Object<BamfView> const& view);38 glib::Object<BamfView> const& view);
4039
41 std::string title() const;40 std::string title() const;
@@ -48,7 +47,7 @@
48 bool GetUrgent() const;47 bool GetUrgent() const;
4948
50protected:49protected:
51 Manager const& manager_;50 ApplicationManager const& manager_;
52 glib::Object<BamfView> bamf_view_;51 glib::Object<BamfView> bamf_view_;
53};52};
5453
@@ -56,7 +55,7 @@
56class WindowBase: public ::unity::ApplicationWindow, public View55class WindowBase: public ::unity::ApplicationWindow, public View
57{56{
58protected:57protected:
59 WindowBase(Manager const& manager,58 WindowBase(ApplicationManager const& manager,
60 glib::Object<BamfView> const& window);59 glib::Object<BamfView> const& window);
6160
62public:61public:
@@ -74,7 +73,7 @@
74class AppWindow: public WindowBase73class AppWindow: public WindowBase
75{74{
76public:75public:
77 AppWindow(Manager const& manager,76 AppWindow(ApplicationManager const& manager,
78 glib::Object<BamfView> const& window);77 glib::Object<BamfView> const& window);
7978
80 virtual Window window_id() const;79 virtual Window window_id() const;
@@ -89,7 +88,7 @@
89class Tab: public WindowBase88class Tab: public WindowBase
90{89{
91public:90public:
92 Tab(Manager const& manager,91 Tab(ApplicationManager const& manager,
93 glib::Object<BamfView> const& tab);92 glib::Object<BamfView> const& tab);
9493
95 virtual Window window_id() const;94 virtual Window window_id() const;
@@ -106,9 +105,9 @@
106class Application : public ::unity::Application, public View105class Application : public ::unity::Application, public View
107{106{
108public:107public:
109 Application(Manager const& manager,108 Application(ApplicationManager const& manager,
110 glib::Object<BamfView> const& app);109 glib::Object<BamfView> const& app);
111 Application(Manager const& manager,110 Application(ApplicationManager const& manager,
112 glib::Object<BamfApplication> const& app);111 glib::Object<BamfApplication> const& app);
113112
114 virtual std::string title() const;113 virtual std::string title() const;
@@ -149,14 +148,13 @@
149 Manager();148 Manager();
150 ~Manager();149 ~Manager();
151150
152 virtual ApplicationWindowPtr GetActiveWindow();151 ApplicationWindowPtr GetActiveWindow() override;
153152
154 virtual ApplicationPtr GetApplicationForDesktopFile(std::string const& desktop_file);153 ApplicationPtr GetApplicationForDesktopFile(std::string const& desktop_file) override;
155154
156 virtual ApplicationList GetRunningApplications();155 ApplicationList GetRunningApplications() override;
157156
158157 ApplicationPtr GetApplicationForWindow(Window xid) override;
159 virtual ApplicationPtr GetApplicationForWindow(glib::Object<BamfWindow> const& window);
160158
161private:159private:
162 void OnViewOpened(BamfMatcher* matcher, BamfView* view);160 void OnViewOpened(BamfMatcher* matcher, BamfView* view);