Merge lp:~thumper/unity/move-application-manager into lp:unity

Proposed by Tim Penhey
Status: Work in progress
Proposed branch: lp:~thumper/unity/move-application-manager
Merge into: lp:unity
Prerequisite: lp:~thumper/unity/move-window-manager
Diff against target: 576 lines (+95/-82)
17 files modified
UnityCore/ApplicationManager.cpp (+1/-1)
UnityCore/ApplicationManager.h (+2/-1)
UnityCore/BamfApplicationManager.cpp (+21/-8)
UnityCore/BamfApplicationManager.h (+3/-4)
UnityCore/CMakeLists.txt (+8/-4)
hud/HudController.cpp (+1/-1)
launcher/AbstractLauncherIcon.h (+1/-1)
launcher/ApplicationLauncherIcon.cpp (+19/-2)
launcher/CMakeLists.txt (+0/-1)
launcher/MockLauncherIcon.h (+1/-1)
plugins/unityshell/CMakeLists.txt (+1/-1)
plugins/unityshell/src/PluginAdapter.cpp (+31/-4)
tests/mock-application.h (+1/-1)
unity-shared/BamfApplicationManagerFactory.cpp (+0/-31)
unity-shared/CMakeLists.txt (+2/-17)
unity-shared/StandaloneAppManager.cpp (+3/-3)
unity-standalone/CMakeLists.txt (+0/-1)
To merge this branch: bzr merge lp:~thumper/unity/move-application-manager
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+139356@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

2966. By Tim Penhey

Move the application manager into UnityCore.

2965. By Tim Penhey

Logging, and change the BamfApplicationManager so it doesn't filter out unmapped windows.

2964. By Tim Penhey

Merge prev pipe.

2963. By Tim Penhey

Moar logging.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== renamed file 'unity-shared/ApplicationManager.cpp' => 'UnityCore/ApplicationManager.cpp'
2--- unity-shared/ApplicationManager.cpp 2012-12-12 00:49:23 +0000
3+++ UnityCore/ApplicationManager.cpp 2012-12-12 00:49:23 +0000
4@@ -17,7 +17,7 @@
5 * Authored by: Tim Penhey <tim.penhey@canonical.com>
6 */
7
8-#include "unity-shared/ApplicationManager.h"
9+#include "ApplicationManager.h"
10
11
12 namespace unity
13
14=== renamed file 'unity-shared/ApplicationManager.h' => 'UnityCore/ApplicationManager.h'
15--- unity-shared/ApplicationManager.h 2012-12-12 00:49:23 +0000
16+++ UnityCore/ApplicationManager.h 2012-12-12 00:49:23 +0000
17@@ -25,7 +25,8 @@
18
19 #include <sigc++/signal.h>
20 #include <NuxCore/Property.h>
21-#include <UnityCore/WindowManager.h>
22+
23+#include "WindowManager.h"
24
25
26 namespace unity
27
28=== renamed file 'unity-shared/BamfApplicationManager.cpp' => 'UnityCore/BamfApplicationManager.cpp'
29--- unity-shared/BamfApplicationManager.cpp 2012-12-12 00:49:23 +0000
30+++ UnityCore/BamfApplicationManager.cpp 2012-12-12 00:49:23 +0000
31@@ -17,7 +17,7 @@
32 * Authored by: Tim Penhey <tim.penhey@canonical.com>
33 */
34
35-#include "unity-shared/BamfApplicationManager.h"
36+#include "BamfApplicationManager.h"
37
38 #include <NuxCore/Logger.h>
39
40@@ -26,6 +26,13 @@
41
42 namespace unity
43 {
44+// This function is used by the static Default method on the ApplicationManager
45+// class, and uses link time to make sure there is a function available.
46+std::shared_ptr<ApplicationManager> create_application_manager()
47+{
48+ return std::shared_ptr<ApplicationManager>(new bamf::Manager());
49+}
50+
51 namespace bamf
52 {
53 namespace
54@@ -346,7 +353,7 @@
55 if (!bamf_app_)
56 return result;
57
58- WindowManager& wm = WindowManager::Default();
59+ //WindowManager& wm = WindowManager::Default();
60 std::shared_ptr<GList> children(bamf_view_get_children(bamf_view_), g_list_free);
61 for (GList* l = children.get(); l; l = l->next)
62 {
63@@ -355,12 +362,7 @@
64 if (!window)
65 continue;
66
67- Window window_id = window->window_id();
68-
69- if (wm.IsWindowMapped(window_id))
70- {
71- result.push_back(window);
72- }
73+ result.push_back(window);
74 }
75 return result;
76 }
77@@ -436,6 +438,8 @@
78 for (auto& window : GetWindows())
79 {
80 Window window_id = window->window_id();
81+ LOG_DEBUG(logger) << "Window: " << window_id << ", urgent: " << window->urgent()
82+ << ", visible: " << window->visible();
83 if (window->urgent())
84 urgent_windows.push_back(window_id);
85 else if (window->visible())
86@@ -461,6 +465,9 @@
87 }
88 if (!urgent_windows.empty())
89 {
90+ LOG_DEBUG(logger) << "Urgent windows, FocusWindowGroup, have "
91+ << urgent_windows.size()
92+ << " windows, for monitor " << monitor;
93 // Last param is whether to show only the top most window. In the situation
94 // where we have urgent windows, we want to raise all the urgent windows on
95 // the current workspace, or the workspace of the top most urgent window.
96@@ -468,10 +475,16 @@
97 }
98 else if (!visible_windows.empty())
99 {
100+ LOG_DEBUG(logger) << "Visible windows, FocusWindowGroup, have "
101+ << visible_windows.size()
102+ << " windows, for monitor " << monitor;
103 wm.FocusWindowGroup(visible_windows, visibility, monitor, true);
104 }
105 else
106 {
107+ LOG_DEBUG(logger) << "Non-visible windows, FocusWindowGroup, have "
108+ << non_visible_windows.size()
109+ << " windows, for monitor " << monitor;
110 // Not sure what the use case is for this behaviour, but at this stage,
111 // copying behaviour from ApplicationLauncherIcon.
112 wm.FocusWindowGroup(non_visible_windows, visibility, monitor, true);
113
114=== renamed file 'unity-shared/BamfApplicationManager.h' => 'UnityCore/BamfApplicationManager.h'
115--- unity-shared/BamfApplicationManager.h 2012-11-28 08:47:23 +0000
116+++ UnityCore/BamfApplicationManager.h 2012-12-12 00:49:23 +0000
117@@ -21,10 +21,9 @@
118 #define UNITYSHARED_BAMF_APPLICATION_MANAGER_H
119
120 #include <libbamf/libbamf.h>
121-#include <UnityCore/GLibWrapper.h>
122-#include <UnityCore/GLibSignal.h>
123-
124-#include "unity-shared/ApplicationManager.h"
125+#include "GLibWrapper.h"
126+#include "GLibSignal.h"
127+#include "ApplicationManager.h"
128
129
130 namespace unity
131
132=== modified file 'UnityCore/CMakeLists.txt'
133--- UnityCore/CMakeLists.txt 2012-12-12 00:49:23 +0000
134+++ UnityCore/CMakeLists.txt 2012-12-12 00:49:23 +0000
135@@ -1,12 +1,13 @@
136 find_package (PkgConfig)
137 set(UNITY_CORE_DEPS
138- glib-2.0
139- gio-2.0
140 dee-1.0
141- sigc++-2.0
142- nux-core-4.0
143 gdk-pixbuf-2.0
144+ gio-2.0
145+ glib-2.0
146 gtk+-3.0>=3.1
147+ libbamf3
148+ nux-core-4.0
149+ sigc++-2.0
150 unity-protocol-private
151 )
152 pkg_check_modules (CORE_DEPS REQUIRED ${UNITY_CORE_DEPS})
153@@ -18,6 +19,7 @@
154 # Headers & Sources
155 #
156 set (CORE_HEADERS
157+ ApplicationManager.h
158 ApplicationPreview.h
159 AppmenuIndicator.h
160 Categories.h
161@@ -68,8 +70,10 @@
162 )
163
164 set (CORE_SOURCES
165+ ApplicationManager.cpp
166 ApplicationPreview.cpp
167 AppmenuIndicator.cpp
168+ BamfApplicationManager.cpp
169 Categories.cpp
170 Category.cpp
171 CheckOptionFilter.cpp
172
173=== modified file 'hud/HudController.cpp'
174--- hud/HudController.cpp 2012-12-12 00:49:23 +0000
175+++ hud/HudController.cpp 2012-12-12 00:49:23 +0000
176@@ -20,11 +20,11 @@
177
178 #include <NuxCore/Logger.h>
179 #include <Nux/HLayout.h>
180+#include <UnityCore/ApplicationManager.h>
181 #include <UnityCore/Variant.h>
182 #include <UnityCore/UScreen.h>
183 #include <UnityCore/WindowManager.h>
184
185-#include "unity-shared/ApplicationManager.h"
186 #include "unity-shared/PanelStyle.h"
187 #include "unity-shared/UBusMessages.h"
188
189
190=== modified file 'launcher/AbstractLauncherIcon.h'
191--- launcher/AbstractLauncherIcon.h 2012-12-12 00:49:23 +0000
192+++ launcher/AbstractLauncherIcon.h 2012-12-12 00:49:23 +0000
193@@ -29,9 +29,9 @@
194 #include <libdbusmenu-glib/menuitem.h>
195
196 #include "DndData.h"
197+#include <UnityCore/ApplicationManager.h>
198 #include <UnityCore/Introspectable.h>
199 #include <UnityCore/WindowManager.h>
200-#include <unity-shared/ApplicationManager.h>
201 #include "unity-shared/IconTextureSource.h"
202
203 #include "LauncherEntryRemote.h"
204
205=== modified file 'launcher/ApplicationLauncherIcon.cpp'
206--- launcher/ApplicationLauncherIcon.cpp 2012-11-29 01:50:21 +0000
207+++ launcher/ApplicationLauncherIcon.cpp 2012-12-12 00:49:23 +0000
208@@ -212,6 +212,11 @@
209 SimpleLauncherIcon::ActivateLauncherIcon(arg);
210 WindowManager& wm = WindowManager::Default();
211
212+ LOG_DEBUG(logger) << "ActivateLauncherIcon: " << tooltip_text()
213+ << ", source: " << arg.source
214+ << ", button: " << arg.button
215+ << ", target: " << arg.target
216+ << ", monitor: " << arg.monitor;
217 // This is a little awkward as the target is only set from the switcher.
218 if (arg.target)
219 {
220@@ -251,22 +256,26 @@
221 if (!any_visible && wm.IsWindowOnCurrentDesktop(xid))
222 {
223 any_visible = true;
224+ LOG_DEBUG(logger) << " any_visible is true.";
225 }
226
227 if (!any_mapped && wm.IsWindowMapped(xid))
228 {
229 any_mapped = true;
230+ LOG_DEBUG(logger) << " any_mapped is true.";
231 }
232
233 if (!any_on_top && wm.IsWindowOnTop(xid))
234 {
235 any_on_top = true;
236+ LOG_DEBUG(logger) << " any_on_top is true.";
237 }
238
239 if (!any_on_monitor && window->monitor() == arg.monitor &&
240 wm.IsWindowMapped(xid) && wm.IsWindowVisible(xid))
241 {
242 any_on_monitor = true;
243+ LOG_DEBUG(logger) << " any_on_monitor is true.";
244 }
245
246 if (window->active())
247@@ -293,6 +302,8 @@
248
249 if (!IsRunning() || (IsRunning() && !user_visible)) // #1 above
250 {
251+ LOG_DEBUG(logger) << " 1) Nothing running, or nothing visible -> launch application";
252+
253 if (GetQuirk(Quirk::STARTING))
254 return;
255
256@@ -305,10 +316,12 @@
257 {
258 if (scaleWasActive) // #5 above
259 {
260+ LOG_DEBUG(logger) << " 5) Spread is active -> Spread de-activated, and fall through";
261 Focus(arg);
262 }
263 else // #2 above
264 {
265+ LOG_DEBUG(logger) << " 2) Running and active -> spread application";
266 if (arg.source != ActionArg::SWITCHER)
267 {
268 Spread(true, 0, false);
269@@ -319,12 +332,14 @@
270 {
271 if (scaleWasActive) // #4 above
272 {
273+ LOG_DEBUG(logger) << " 4) Spread is active and different icon pressed -> change spread";
274 Focus(arg);
275 if (arg.source != ActionArg::SWITCHER)
276 Spread(true, 0, false);
277 }
278 else // #3 above
279 {
280+ LOG_DEBUG(logger) << " 3) Running and not active -> focus application";
281 Focus(arg);
282 }
283 }
284@@ -536,18 +551,20 @@
285 ApplicationWindowPtr window = app_->GetFocusableWindow();
286 if (window)
287 {
288- // If we have a window, try to focus it.
289+ LOG_DEBUG(logger) << "We have a window, try to focus it.";
290 if (window->Focus())
291 return;
292 }
293 else if (app_->type() == "webapp")
294 {
295- // Webapps are again special.
296+ LOG_DEBUG(logger) << "Webapps are special.";
297 OpenInstanceLauncherIcon();
298 return;
299 }
300
301 bool show_only_visible = arg.source == ActionArg::SWITCHER;
302+ LOG_DEBUG(logger) << "Focus the windows for the app, show_only_visible: "
303+ << show_only_visible << " for monitor: " << arg.monitor;
304 app_->Focus(show_only_visible, arg.monitor);
305 }
306
307
308=== modified file 'launcher/CMakeLists.txt'
309--- launcher/CMakeLists.txt 2012-12-12 00:49:23 +0000
310+++ launcher/CMakeLists.txt 2012-12-12 00:49:23 +0000
311@@ -100,7 +100,6 @@
312 set (LAUNCHER_LIBS
313 launcher-lib
314 unity-shared
315- unity-shared-bamf
316 )
317
318 #
319
320=== modified file 'launcher/MockLauncherIcon.h'
321--- launcher/MockLauncherIcon.h 2012-11-28 22:00:12 +0000
322+++ launcher/MockLauncherIcon.h 2012-12-12 00:49:23 +0000
323@@ -32,7 +32,7 @@
324 #include <sigc++/sigc++.h>
325
326 #include <libdbusmenu-glib/menuitem.h>
327-#include "unity-shared/ApplicationManager.h"
328+#include <UnityCore/ApplicationManager.h>
329
330 #include "AbstractLauncherIcon.h"
331
332
333=== modified file 'plugins/unityshell/CMakeLists.txt'
334--- plugins/unityshell/CMakeLists.txt 2012-12-12 00:49:23 +0000
335+++ plugins/unityshell/CMakeLists.txt 2012-12-12 00:49:23 +0000
336@@ -11,7 +11,7 @@
337 LIBDIRS "${CMAKE_BINARY_DIR}/UnityCore"
338 )
339 add_dependencies(unityshell unity-core-${UNITY_API_VERSION} dash-lib launcher-lib switcher-lib hud-lib panel-lib shortcuts-lib unity-shared)
340-target_link_libraries(unityshell unity-core-${UNITY_API_VERSION} launcher-lib dash-lib switcher-lib hud-lib panel-lib shortcuts-lib unity-shared unity-shared-bamf)
341+target_link_libraries(unityshell unity-core-${UNITY_API_VERSION} launcher-lib dash-lib switcher-lib hud-lib panel-lib shortcuts-lib unity-shared)
342 set_target_properties(unityshell
343 PROPERTIES INSTALL_RPATH "${CACHED_UNITY_PRIVATE_DEPS_LIBRARY_DIRS}"
344 INSTALL_RPATH_USE_LINK_PATH TRUE)
345
346=== modified file 'plugins/unityshell/src/PluginAdapter.cpp'
347--- plugins/unityshell/src/PluginAdapter.cpp 2012-12-12 00:49:23 +0000
348+++ plugins/unityshell/src/PluginAdapter.cpp 2012-12-12 00:49:23 +0000
349@@ -35,6 +35,13 @@
350 const char* _UNITY_FRAME_EXTENTS = "_UNITY_FRAME_EXTENTS";
351
352 PluginAdapter* global_instance = nullptr;
353+
354+std::ostream& operator<<(std::ostream& o, CompPoint const& p)
355+{
356+ o << "(" << p.x() << ", " << p.y() << ")";
357+ return o;
358+}
359+
360 }
361
362 #define MAXIMIZABLE (CompWindowActionMaximizeHorzMask & CompWindowActionMaximizeVertMask & CompWindowActionResizeMask)
363@@ -735,6 +742,12 @@
364 CompWindow* top_window = nullptr;
365 CompWindow* top_monitor_win = nullptr;
366
367+ LOG_DEBUG(logger) << "FocusWindowGroup, given " << window_ids.size()
368+ << " windows, focus_vis: " << static_cast<int>(focus_visibility)
369+ << ", monitor: " << monitor
370+ << ", only_top_win: " << only_top_win
371+ << ", target_vp: " << target_vp;
372+
373 // mapped windows are visible windows (non-minimised)
374 bool any_on_current = false;
375 bool any_mapped = false;
376@@ -749,6 +762,7 @@
377 if (std::find(window_ids.begin(), window_ids.end(), id) != window_ids.end())
378 windows.push_back(win);
379 }
380+ LOG_DEBUG(logger) << " " << windows.size() << " compiz windows found.";
381
382 // Work out if there are any visible windows on the current view port.
383 for (CompWindow* &win : windows)
384@@ -772,7 +786,7 @@
385 }
386
387 // If we don't find any windows on the current view port, we need to look
388- // for the view port of the maooed window. Or if there are not any mapped
389+ // for the view port of the mapped window. Or if there are not any mapped
390 // windows, then just choosing any view port is fine.
391 if (!any_on_current)
392 {
393@@ -787,10 +801,13 @@
394 break;
395 }
396 }
397+ LOG_DEBUG(logger) << " No windows on current view port, target_vp now "
398+ << target_vp;
399 }
400
401 for (CompWindow* &win : windows)
402 {
403+ LOG_DEBUG(logger) << " win->defaultViewport() == " << win->defaultViewport();
404 if (win->defaultViewport() == target_vp)
405 {
406 int win_monitor = GetWindowMonitor(win->id());
407@@ -804,6 +821,7 @@
408 (focus_visibility == WindowManager::FocusVisibility::ForceUnminimizeInvisible &&
409 win->mapNum() == 0))
410 {
411+ LOG_DEBUG(logger) << " force visibility";
412 top_window = win;
413 forced_unminimize = true;
414
415@@ -814,14 +832,19 @@
416 {
417 bool is_mapped = (win->mapNum() != 0);
418 win->unminimize();
419+ LOG_DEBUG(logger) << " unminimizing window just to be sure";
420
421 /* Initially minimized windows dont get raised */
422 if (!is_mapped)
423+ {
424 win->raise();
425+ LOG_DEBUG(logger) << " win not mapped, raising";
426+ }
427 }
428 }
429 else if ((any_mapped_on_current && !win->minimized()) || !any_mapped_on_current)
430 {
431+ LOG_DEBUG(logger) << " not even sure what to say here";
432 if (!forced_unminimize || target_vp == m_Screen->vp())
433 {
434 top_window = win;
435@@ -831,6 +854,7 @@
436
437 if (!only_top_win)
438 win->raise();
439+ LOG_DEBUG(logger) << " record top window";
440 }
441 }
442 }
443@@ -844,14 +868,17 @@
444 if (only_top_win)
445 {
446 if (forced_unminimize)
447- {
448- top_window->unminimize();
449- }
450+ {
451+ top_window->unminimize();
452+ LOG_DEBUG(logger) << " unminimize the top window";
453+ }
454
455 top_window->raise();
456+ LOG_DEBUG(logger) << " raise the top window";
457 }
458
459 top_window->activate();
460+ LOG_DEBUG(logger) << " activate the top window";
461 }
462 }
463
464
465=== modified file 'tests/mock-application.h'
466--- tests/mock-application.h 2012-11-28 09:34:44 +0000
467+++ tests/mock-application.h 2012-12-12 00:49:23 +0000
468@@ -20,7 +20,7 @@
469 #define TESTS_MOCK_APPLICATION_H
470
471 #include <map>
472-#include "unity-shared/ApplicationManager.h"
473+#include <UnityCore/ApplicationManager.h>
474
475
476 namespace testmocks
477
478=== removed file 'unity-shared/BamfApplicationManagerFactory.cpp'
479--- unity-shared/BamfApplicationManagerFactory.cpp 2012-11-28 03:44:41 +0000
480+++ unity-shared/BamfApplicationManagerFactory.cpp 1970-01-01 00:00:00 +0000
481@@ -1,31 +0,0 @@
482-// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
483-/*
484- * Copyright (C) 2012 Canonical Ltd
485- *
486- * This program is free software: you can redistribute it and/or modify
487- * it under the terms of the GNU General Public License version 3 as
488- * published by the Free Software Foundation.
489- *
490- * This program is distributed in the hope that it will be useful,
491- * but WITHOUT ANY WARRANTY; without even the implied warranty of
492- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
493- * GNU General Public License for more details.
494- *
495- * You should have received a copy of the GNU General Public License
496- * along with this program. If not, see <http://www.gnu.org/licenses/>.
497- *
498- * Authored by: Tim Penhey <tim.penhey@canonical.com>
499- */
500-
501-#include "unity-shared/BamfApplicationManager.h"
502-
503-namespace unity
504-{
505-// This function is used by the static Default method on the ApplicationManager
506-// class, and uses link time to make sure there is a function available.
507-std::shared_ptr<ApplicationManager> create_application_manager()
508-{
509- return std::shared_ptr<ApplicationManager>(new bamf::Manager());
510-}
511-
512-}
513
514=== modified file 'unity-shared/CMakeLists.txt'
515--- unity-shared/CMakeLists.txt 2012-12-12 00:49:23 +0000
516+++ unity-shared/CMakeLists.txt 2012-12-12 00:49:23 +0000
517@@ -25,7 +25,6 @@
518 #
519 set (UNITY_SHARED_SOURCES
520 AbstractSeparator.cpp
521- ApplicationManager.cpp
522 Animator.cpp
523 BGHash.cpp
524 CoverArt.cpp
525@@ -84,22 +83,8 @@
526 target_link_libraries (unity-shared ${LIBS})
527 add_dependencies (unity-shared unity-core-${UNITY_API_VERSION})
528
529-#
530-# We also need to build compiz specific parts and standalone variants of those parts
531-#
532-
533-if (ENABLE_X_SUPPORT)
534- # bamf application manager
535- set (UNITY_SHARED_BAMF_SOURCES
536- BamfApplicationManager.cpp
537- BamfApplicationManagerFactory.cpp
538- )
539- add_library (unity-shared-bamf STATIC ${UNITY_SHARED_BAMF_SOURCES})
540- target_link_libraries (unity-shared-bamf ${LIBS})
541- add_dependencies (unity-shared-bamf unity-shared)
542-endif()
543
544 add_executable (app-manager StandaloneAppManager.cpp)
545-add_dependencies (app-manager unity-shared unity-shared-bamf)
546-target_link_libraries (app-manager unity-shared unity-shared-bamf)
547+add_dependencies (app-manager unity-shared)
548+target_link_libraries (app-manager unity-shared)
549
550
551=== modified file 'unity-shared/StandaloneAppManager.cpp'
552--- unity-shared/StandaloneAppManager.cpp 2012-12-12 00:49:23 +0000
553+++ unity-shared/StandaloneAppManager.cpp 2012-12-12 00:49:23 +0000
554@@ -25,9 +25,9 @@
555 #include <gtk/gtk.h>
556 #include <signal.h>
557
558-#include "unity-shared/ApplicationManager.h"
559-#include "UnityCore/GLibSource.h"
560-#include "UnityCore/StandaloneWindowManager.h"
561+#include <UnityCore/ApplicationManager.h>
562+#include <UnityCore/GLibSource.h>
563+#include <UnityCore/StandaloneWindowManager.h>
564
565 using namespace std;
566 using namespace unity;
567
568=== modified file 'unity-standalone/CMakeLists.txt'
569--- unity-standalone/CMakeLists.txt 2012-12-12 00:49:23 +0000
570+++ unity-standalone/CMakeLists.txt 2012-12-12 00:49:23 +0000
571@@ -35,5 +35,4 @@
572 launcher-lib
573 panel-lib
574 unity-shared
575- unity-shared-bamf
576 )