Merge lp:~3v1n0/unity/application-manager-new into lp:unity
- application-manager-new
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Christopher Townsend |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3975 |
Proposed branch: | lp:~3v1n0/unity/application-manager-new |
Merge into: | lp:unity |
Prerequisite: | lp:~3v1n0/unity/lim-everywhere |
Diff against target: |
2037 lines (+583/-507) 15 files modified
launcher/ApplicationLauncherIcon.cpp (+11/-11) launcher/MockLauncherIcon.h (+1/-1) panel/CMakeLists.txt (+1/-1) panel/PanelMenuView.cpp (+102/-251) panel/PanelMenuView.h (+11/-21) tests/mock-application.h (+15/-7) tests/test_application_launcher_icon.cpp (+5/-2) tests/test_panel_menu_view.cpp (+1/-8) tests/test_switcher_controller.h (+1/-1) tests/test_switcher_controller_class.cpp (+1/-1) unity-shared/ApplicationManager.cpp (+19/-0) unity-shared/ApplicationManager.h (+64/-6) unity-shared/BamfApplicationManager.cpp (+215/-145) unity-shared/BamfApplicationManager.h (+36/-18) unity-shared/StandaloneAppManager.cpp (+100/-34) |
To merge this branch: | bzr merge lp:~3v1n0/unity/application-manager-new |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Christopher Townsend | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Stephen M. Webb (community) | Needs Fixing | ||
Review via email: mp+248778@code.launchpad.net |
Commit message
ApplicationManager: add missing features, keep a copy of views around
Use this in PanelMenuView, getting rid of the BAMF internal at this level.
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3969
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3972
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3973
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3975
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3976
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Stephen M. Webb (bregma) wrote : | # |
One of the commits made after this MP was reviewd and approved cause unit test failures.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3982
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3982
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3982
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Christopher Townsend (townsend) wrote : | # |
Ok, all good now.
Preview Diff
1 | === modified file 'launcher/ApplicationLauncherIcon.cpp' | |||
2 | --- launcher/ApplicationLauncherIcon.cpp 2015-03-25 14:59:04 +0000 | |||
3 | +++ launcher/ApplicationLauncherIcon.cpp 2015-05-22 16:04:25 +0000 | |||
4 | @@ -156,13 +156,14 @@ | |||
5 | 156 | { | 156 | { |
6 | 157 | // Lambda functions should be fine here because when the application the icon | 157 | // Lambda functions should be fine here because when the application the icon |
7 | 158 | // is only ever removed when the application is closed. | 158 | // is only ever removed when the application is closed. |
9 | 159 | signals_conn_.Add(app_->window_opened.connect([this](ApplicationWindow const&) { | 159 | signals_conn_.Add(app_->window_opened.connect([this](ApplicationWindowPtr const&) { |
10 | 160 | EnsureWindowState(); | 160 | EnsureWindowState(); |
11 | 161 | UpdateIconGeometries(GetCenters()); | 161 | UpdateIconGeometries(GetCenters()); |
12 | 162 | })); | 162 | })); |
13 | 163 | 163 | ||
16 | 164 | signals_conn_.Add(app_->window_closed.connect(sigc::mem_fun(this, &ApplicationLauncherIcon::EnsureWindowState))); | 164 | auto ensure_windows_cb = sigc::hide(sigc::mem_fun(this, &ApplicationLauncherIcon::EnsureWindowState)); |
17 | 165 | signals_conn_.Add(app_->window_moved.connect(sigc::hide(sigc::mem_fun(this, &ApplicationLauncherIcon::EnsureWindowState)))); | 165 | signals_conn_.Add(app_->window_closed.connect(ensure_windows_cb)); |
18 | 166 | signals_conn_.Add(app_->window_moved.connect(ensure_windows_cb)); | ||
19 | 166 | 167 | ||
20 | 167 | signals_conn_.Add(app_->urgent.changed.connect([this](bool const& urgent) { | 168 | signals_conn_.Add(app_->urgent.changed.connect([this](bool const& urgent) { |
21 | 168 | LOG_DEBUG(logger) << tooltip_text() << " urgent now " << (urgent ? "true" : "false"); | 169 | LOG_DEBUG(logger) << tooltip_text() << " urgent now " << (urgent ? "true" : "false"); |
22 | @@ -235,7 +236,7 @@ | |||
23 | 235 | if (!SimpleLauncherIcon::GetQuirk(Quirk::ACTIVE, monitor)) | 236 | if (!SimpleLauncherIcon::GetQuirk(Quirk::ACTIVE, monitor)) |
24 | 236 | return false; | 237 | return false; |
25 | 237 | 238 | ||
27 | 238 | if (app_->type() == "webapp") | 239 | if (app_->type() == AppType::WEBAPP) |
28 | 239 | return true; | 240 | return true; |
29 | 240 | 241 | ||
30 | 241 | // Sometimes BAMF is not fast enough to update the active application | 242 | // Sometimes BAMF is not fast enough to update the active application |
31 | @@ -702,7 +703,7 @@ | |||
32 | 702 | if (window->Focus()) | 703 | if (window->Focus()) |
33 | 703 | return; | 704 | return; |
34 | 704 | } | 705 | } |
36 | 705 | else if (app_->type() == "webapp") | 706 | else if (app_->type() == AppType::WEBAPP) |
37 | 706 | { | 707 | { |
38 | 707 | // Webapps are again special. | 708 | // Webapps are again special. |
39 | 708 | OpenInstanceLauncherIcon(arg.timestamp); | 709 | OpenInstanceLauncherIcon(arg.timestamp); |
40 | @@ -837,8 +838,6 @@ | |||
41 | 837 | if (windows.size() < 2) | 838 | if (windows.size() < 2) |
42 | 838 | return; | 839 | return; |
43 | 839 | 840 | ||
44 | 840 | Window active = WindowManager::Default().GetActiveWindow(); | ||
45 | 841 | |||
46 | 842 | // add menu items for all open windows | 841 | // add menu items for all open windows |
47 | 843 | for (auto const& w : windows) | 842 | for (auto const& w : windows) |
48 | 844 | { | 843 | { |
49 | @@ -862,7 +861,7 @@ | |||
50 | 862 | wm.Raise(xid); | 861 | wm.Raise(xid); |
51 | 863 | }); | 862 | }); |
52 | 864 | 863 | ||
54 | 865 | if (xid == active) | 864 | if (w->active()) |
55 | 866 | { | 865 | { |
56 | 867 | dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE, DBUSMENU_MENUITEM_TOGGLE_RADIO); | 866 | dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE, DBUSMENU_MENUITEM_TOGGLE_RADIO); |
57 | 868 | dbusmenu_menuitem_property_set_int(menu_item, DBUSMENU_MENUITEM_PROP_TOGGLE_STATE, DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED); | 867 | dbusmenu_menuitem_property_set_int(menu_item, DBUSMENU_MENUITEM_PROP_TOGGLE_STATE, DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED); |
58 | @@ -1113,7 +1112,7 @@ | |||
59 | 1113 | 1112 | ||
60 | 1114 | void ApplicationLauncherIcon::UpdateIconGeometries(std::vector<nux::Point3> const& centers) | 1113 | void ApplicationLauncherIcon::UpdateIconGeometries(std::vector<nux::Point3> const& centers) |
61 | 1115 | { | 1114 | { |
63 | 1116 | if (app_->type() == "webapp") | 1115 | if (app_->type() == AppType::WEBAPP) |
64 | 1117 | return; | 1116 | return; |
65 | 1118 | 1117 | ||
66 | 1119 | nux::Geometry geo(0, 0, icon_size, icon_size); | 1118 | nux::Geometry geo(0, 0, icon_size, icon_size); |
67 | @@ -1189,6 +1188,7 @@ | |||
68 | 1189 | auto const& desktop_file = DesktopFile(); | 1188 | auto const& desktop_file = DesktopFile(); |
69 | 1190 | 1189 | ||
70 | 1191 | return boost::algorithm::ends_with(desktop_file, "org.gnome.Nautilus.desktop") || | 1190 | return boost::algorithm::ends_with(desktop_file, "org.gnome.Nautilus.desktop") || |
71 | 1191 | boost::algorithm::ends_with(desktop_file, "nautilus.desktop") || | ||
72 | 1192 | boost::algorithm::ends_with(desktop_file, "nautilus-folder-handler.desktop") || | 1192 | boost::algorithm::ends_with(desktop_file, "nautilus-folder-handler.desktop") || |
73 | 1193 | boost::algorithm::ends_with(desktop_file, "nautilus-home.desktop"); | 1193 | boost::algorithm::ends_with(desktop_file, "nautilus-home.desktop"); |
74 | 1194 | } | 1194 | } |
75 | @@ -1264,14 +1264,14 @@ | |||
76 | 1264 | 1264 | ||
77 | 1265 | bool ApplicationLauncherIcon::AllowDetailViewInSwitcher() const | 1265 | bool ApplicationLauncherIcon::AllowDetailViewInSwitcher() const |
78 | 1266 | { | 1266 | { |
80 | 1267 | return app_->type() != "webapp"; | 1267 | return app_->type() != AppType::WEBAPP; |
81 | 1268 | } | 1268 | } |
82 | 1269 | 1269 | ||
83 | 1270 | uint64_t ApplicationLauncherIcon::SwitcherPriority() | 1270 | uint64_t ApplicationLauncherIcon::SwitcherPriority() |
84 | 1271 | { | 1271 | { |
85 | 1272 | uint64_t result = 0; | 1272 | uint64_t result = 0; |
86 | 1273 | // Webapps always go at the back. | 1273 | // Webapps always go at the back. |
88 | 1274 | if (app_->type() == "webapp") | 1274 | if (app_->type() == AppType::WEBAPP) |
89 | 1275 | return result; | 1275 | return result; |
90 | 1276 | 1276 | ||
91 | 1277 | for (auto& window : app_->GetWindows()) | 1277 | for (auto& window : app_->GetWindows()) |
92 | 1278 | 1278 | ||
93 | === modified file 'launcher/MockLauncherIcon.h' | |||
94 | --- launcher/MockLauncherIcon.h 2015-03-20 16:23:04 +0000 | |||
95 | +++ launcher/MockLauncherIcon.h 2015-05-22 16:04:25 +0000 | |||
96 | @@ -52,7 +52,7 @@ | |||
97 | 52 | icon.SetGetterFunction([this] { return ""; }); | 52 | icon.SetGetterFunction([this] { return ""; }); |
98 | 53 | } | 53 | } |
99 | 54 | 54 | ||
101 | 55 | virtual std::string type() const { return "mock"; } | 55 | virtual WindowType type() const { return WindowType::UNKNOWN; } |
102 | 56 | 56 | ||
103 | 57 | virtual Window window_id() const { return xid_; } | 57 | virtual Window window_id() const { return xid_; } |
104 | 58 | virtual int monitor() const { return -1; } | 58 | virtual int monitor() const { return -1; } |
105 | 59 | 59 | ||
106 | === modified file 'panel/CMakeLists.txt' | |||
107 | --- panel/CMakeLists.txt 2014-02-12 07:13:01 +0000 | |||
108 | +++ panel/CMakeLists.txt 2015-05-22 16:04:25 +0000 | |||
109 | @@ -36,4 +36,4 @@ | |||
110 | 36 | # | 36 | # |
111 | 37 | add_executable (panel StandalonePanel.cpp) | 37 | add_executable (panel StandalonePanel.cpp) |
112 | 38 | find_library (COMPIZ_LIB compiz_core ${COMPIZ_LIBDIR}) | 38 | find_library (COMPIZ_LIB compiz_core ${COMPIZ_LIBDIR}) |
114 | 39 | target_link_libraries (panel panel-lib unity-shared unity-shared-standalone ${COMPIZ_LIB}) | 39 | target_link_libraries (panel panel-lib unity-shared unity-shared-standalone unity-shared-bamf ${COMPIZ_LIB}) |
115 | 40 | 40 | ||
116 | === modified file 'panel/PanelMenuView.cpp' | |||
117 | --- panel/PanelMenuView.cpp 2015-02-19 14:19:44 +0000 | |||
118 | +++ panel/PanelMenuView.cpp 2015-05-22 16:04:25 +0000 | |||
119 | @@ -20,6 +20,7 @@ | |||
120 | 20 | 20 | ||
121 | 21 | #include <Nux/Nux.h> | 21 | #include <Nux/Nux.h> |
122 | 22 | #include <NuxCore/Logger.h> | 22 | #include <NuxCore/Logger.h> |
123 | 23 | #include <UnityCore/GLibWrapper.h> | ||
124 | 23 | #include <boost/algorithm/string/erase.hpp> | 24 | #include <boost/algorithm/string/erase.hpp> |
125 | 24 | 25 | ||
126 | 25 | #include "PanelMenuView.h" | 26 | #include "PanelMenuView.h" |
127 | @@ -87,13 +88,11 @@ | |||
128 | 87 | , maximized_window(0) | 88 | , maximized_window(0) |
129 | 88 | , focused(true) | 89 | , focused(true) |
130 | 89 | , menu_manager_(menus) | 90 | , menu_manager_(menus) |
131 | 90 | , matcher_(bamf_matcher_get_default()) | ||
132 | 91 | , is_inside_(false) | 91 | , is_inside_(false) |
133 | 92 | , is_grabbed_(false) | 92 | , is_grabbed_(false) |
134 | 93 | , is_maximized_(false) | 93 | , is_maximized_(false) |
135 | 94 | , is_desktop_focused_(false) | 94 | , is_desktop_focused_(false) |
136 | 95 | , last_active_view_(nullptr) | 95 | , last_active_view_(nullptr) |
137 | 96 | , new_application_(nullptr) | ||
138 | 97 | , switcher_showing_(false) | 96 | , switcher_showing_(false) |
139 | 98 | , spread_showing_(false) | 97 | , spread_showing_(false) |
140 | 99 | , launcher_keynav_(false) | 98 | , launcher_keynav_(false) |
141 | @@ -105,9 +104,8 @@ | |||
142 | 105 | , always_show_menus_(menu_manager_->always_show_menus()) | 104 | , always_show_menus_(menu_manager_->always_show_menus()) |
143 | 106 | , desktop_name_(get_current_desktop()) | 105 | , desktop_name_(get_current_desktop()) |
144 | 107 | { | 106 | { |
148 | 108 | BamfWindow* active_win = bamf_matcher_get_active_window(matcher_); | 107 | if (ApplicationWindowPtr const& win = ApplicationManager::Default().GetActiveWindow()) |
149 | 109 | if (BAMF_IS_WINDOW(active_win)) | 108 | active_window = win->window_id(); |
147 | 110 | active_window = bamf_window_get_xid(active_win); | ||
150 | 111 | 109 | ||
151 | 112 | SetupWindowButtons(); | 110 | SetupWindowButtons(); |
152 | 113 | SetupTitlebarGrabArea(); | 111 | SetupTitlebarGrabArea(); |
153 | @@ -117,8 +115,7 @@ | |||
154 | 117 | 115 | ||
155 | 118 | opacity = 0.0f; | 116 | opacity = 0.0f; |
156 | 119 | 117 | ||
159 | 120 | if (Refresh()) | 118 | RefreshAndRedraw(); |
158 | 121 | FullRedraw(); | ||
160 | 122 | } | 119 | } |
161 | 123 | 120 | ||
162 | 124 | PanelMenuView::~PanelMenuView() | 121 | PanelMenuView::~PanelMenuView() |
163 | @@ -144,14 +141,11 @@ | |||
164 | 144 | 141 | ||
165 | 145 | void PanelMenuView::SetupPanelMenuViewSignals() | 142 | void PanelMenuView::SetupPanelMenuViewSignals() |
166 | 146 | { | 143 | { |
175 | 147 | active_win_changed_signal_.Connect(matcher_, "active-window-changed", | 144 | auto& am = ApplicationManager::Default(); |
176 | 148 | sigc::mem_fun(this, &PanelMenuView::OnActiveWindowChanged)); | 145 | am.active_window_changed.connect(sigc::mem_fun(this, &PanelMenuView::OnActiveWindowChanged)); |
177 | 149 | active_app_changed_signal_.Connect(matcher_, "active-application-changed", | 146 | am.active_application_changed.connect(sigc::mem_fun(this, &PanelMenuView::OnActiveAppChanged)); |
178 | 150 | sigc::mem_fun(this, &PanelMenuView::OnActiveAppChanged)); | 147 | am.application_started.connect(sigc::mem_fun(this, &PanelMenuView::OnApplicationStarted)); |
179 | 151 | view_opened_signal_.Connect(matcher_, "view-opened", | 148 | am.application_stopped.connect(sigc::mem_fun(this, &PanelMenuView::OnApplicationClosed)); |
172 | 152 | sigc::mem_fun(this, &PanelMenuView::OnViewOpened)); | ||
173 | 153 | view_closed_signal_.Connect(matcher_, "view-closed", | ||
174 | 154 | sigc::mem_fun(this, &PanelMenuView::OnViewClosed)); | ||
180 | 155 | 149 | ||
181 | 156 | mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter)); | 150 | mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter)); |
182 | 157 | mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave)); | 151 | mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave)); |
183 | @@ -232,9 +226,9 @@ | |||
184 | 232 | wm.window_resized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMoved)); | 226 | wm.window_resized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMoved)); |
185 | 233 | wm.initiate_spread.connect(sigc::mem_fun(this, &PanelMenuView::OnSpreadInitiate)); | 227 | wm.initiate_spread.connect(sigc::mem_fun(this, &PanelMenuView::OnSpreadInitiate)); |
186 | 234 | wm.terminate_spread.connect(sigc::mem_fun(this, &PanelMenuView::OnSpreadTerminate)); | 228 | wm.terminate_spread.connect(sigc::mem_fun(this, &PanelMenuView::OnSpreadTerminate)); |
190 | 235 | wm.initiate_expo.connect(sigc::mem_fun(this, &PanelMenuView::OnExpoInitiate)); | 229 | wm.initiate_expo.connect(sigc::mem_fun(this, &PanelMenuView::RefreshAndRedraw)); |
191 | 236 | wm.terminate_expo.connect(sigc::mem_fun(this, &PanelMenuView::OnExpoTerminate)); | 230 | wm.terminate_expo.connect(sigc::mem_fun(this, &PanelMenuView::RefreshAndRedraw)); |
192 | 237 | wm.screen_viewport_switch_ended.connect(sigc::mem_fun(this, &PanelMenuView::OnExpoTerminate)); | 231 | wm.screen_viewport_switch_ended.connect(sigc::mem_fun(this, &PanelMenuView::RefreshAndRedraw)); |
193 | 238 | } | 232 | } |
194 | 239 | 233 | ||
195 | 240 | void PanelMenuView::SetupUBusManagerInterests() | 234 | void PanelMenuView::SetupUBusManagerInterests() |
196 | @@ -300,7 +294,7 @@ | |||
197 | 300 | void PanelMenuView::OnLIMChanged(bool lim) | 294 | void PanelMenuView::OnLIMChanged(bool lim) |
198 | 301 | { | 295 | { |
199 | 302 | integrated_menus_ = lim; | 296 | integrated_menus_ = lim; |
201 | 303 | new_application_ = nullptr; | 297 | new_application_.reset(); |
202 | 304 | 298 | ||
203 | 305 | if (!integrated_menus_) | 299 | if (!integrated_menus_) |
204 | 306 | { | 300 | { |
205 | @@ -321,7 +315,7 @@ | |||
206 | 321 | if (!always_show_menus_) | 315 | if (!always_show_menus_) |
207 | 322 | CheckMouseInside(); | 316 | CheckMouseInside(); |
208 | 323 | 317 | ||
210 | 324 | FullRedraw(); | 318 | QueueDraw(); |
211 | 325 | } | 319 | } |
212 | 326 | 320 | ||
213 | 327 | nux::Area* PanelMenuView::FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type) | 321 | nux::Area* PanelMenuView::FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type) |
214 | @@ -762,41 +756,13 @@ | |||
215 | 762 | std::string PanelMenuView::GetActiveViewName(bool use_appname) const | 756 | std::string PanelMenuView::GetActiveViewName(bool use_appname) const |
216 | 763 | { | 757 | { |
217 | 764 | std::string label; | 758 | std::string label; |
223 | 765 | BamfWindow* window; | 759 | auto& am = ApplicationManager::Default(); |
224 | 766 | 760 | ||
225 | 767 | window = bamf_matcher_get_active_window(matcher_); | 761 | if (ApplicationWindowPtr const& window = am.GetActiveWindow()) |
221 | 768 | |||
222 | 769 | if (BAMF_IS_WINDOW(window)) | ||
226 | 770 | { | 762 | { |
256 | 771 | BamfView *view = reinterpret_cast<BamfView*>(window); | 763 | Window window_xid = window->window_id(); |
257 | 772 | Window window_xid = bamf_window_get_xid(window); | 764 | |
258 | 773 | 765 | if (window->type() == WindowType::DESKTOP) | |
230 | 774 | if (bamf_window_get_window_type(window) == BAMF_WINDOW_DOCK) | ||
231 | 775 | { | ||
232 | 776 | auto panel = const_cast<PanelMenuView*>(this)->GetTopLevelViewWindow(); | ||
233 | 777 | if (static_cast<nux::BaseWindow*>(panel)->GetInputWindowId() == window_xid) | ||
234 | 778 | return desktop_name_; | ||
235 | 779 | |||
236 | 780 | std::vector<Window> const& our_xids = nux::XInputWindow::NativeHandleList(); | ||
237 | 781 | |||
238 | 782 | if (std::find(our_xids.begin(), our_xids.end(), window_xid) != our_xids.end()) | ||
239 | 783 | { | ||
240 | 784 | /* If the active window is an unity window, we need to fallback to the | ||
241 | 785 | * top one, anyway we should always avoid to focus unity internal windows */ | ||
242 | 786 | BamfWindow* top_win = GetBamfWindowForXid(GetTopWindow()); | ||
243 | 787 | |||
244 | 788 | if (top_win && top_win != window) | ||
245 | 789 | { | ||
246 | 790 | window = top_win; | ||
247 | 791 | } | ||
248 | 792 | else | ||
249 | 793 | { | ||
250 | 794 | return ""; | ||
251 | 795 | } | ||
252 | 796 | } | ||
253 | 797 | } | ||
254 | 798 | |||
255 | 799 | if (bamf_window_get_window_type(window) == BAMF_WINDOW_DESKTOP) | ||
259 | 800 | { | 766 | { |
260 | 801 | label = desktop_name_; | 767 | label = desktop_name_; |
261 | 802 | } | 768 | } |
262 | @@ -806,27 +772,16 @@ | |||
263 | 806 | } | 772 | } |
264 | 807 | 773 | ||
265 | 808 | if (WindowManager::Default().IsWindowMaximized(window_xid) && !use_appname) | 774 | if (WindowManager::Default().IsWindowMaximized(window_xid) && !use_appname) |
287 | 809 | { | 775 | label = window->title(); |
288 | 810 | label = glib::String(bamf_view_get_name(view)).Str(); | 776 | |
289 | 811 | } | 777 | if (label.empty()) |
290 | 812 | 778 | { | |
291 | 813 | if (label.empty()) | 779 | if (ApplicationPtr const& app = am.GetActiveApplication()) |
292 | 814 | { | 780 | label = app->title(); |
293 | 815 | BamfApplication* app; | 781 | } |
294 | 816 | app = bamf_matcher_get_application_for_window(matcher_, window); | 782 | |
295 | 817 | 783 | if (label.empty()) | |
296 | 818 | if (BAMF_IS_APPLICATION(app)) | 784 | label = window->title(); |
276 | 819 | { | ||
277 | 820 | view = reinterpret_cast<BamfView*>(app); | ||
278 | 821 | label = glib::String(bamf_view_get_name(view)).Str(); | ||
279 | 822 | } | ||
280 | 823 | } | ||
281 | 824 | |||
282 | 825 | if (label.empty()) | ||
283 | 826 | { | ||
284 | 827 | view = reinterpret_cast<BamfView*>(window); | ||
285 | 828 | label = glib::String(bamf_view_get_name(view)).Str(); | ||
286 | 829 | } | ||
297 | 830 | } | 785 | } |
298 | 831 | 786 | ||
299 | 832 | return label; | 787 | return label; |
300 | @@ -835,24 +790,16 @@ | |||
301 | 835 | std::string PanelMenuView::GetMaximizedViewName(bool use_appname) const | 790 | std::string PanelMenuView::GetMaximizedViewName(bool use_appname) const |
302 | 836 | { | 791 | { |
303 | 837 | Window maximized = maximized_window(); | 792 | Window maximized = maximized_window(); |
304 | 838 | BamfWindow* window = nullptr; | ||
305 | 839 | std::string label; | 793 | std::string label; |
306 | 840 | 794 | ||
310 | 841 | window = GetBamfWindowForXid(maximized); | 795 | if (ApplicationWindowPtr const& window = ApplicationManager::Default().GetWindowForId(maximized)) |
308 | 842 | |||
309 | 843 | if (BAMF_IS_WINDOW(window)) | ||
311 | 844 | { | 796 | { |
314 | 845 | BamfView* view = reinterpret_cast<BamfView*>(window); | 797 | label = window->title(); |
313 | 846 | label = glib::String(bamf_view_get_name(view)).Str(); | ||
315 | 847 | 798 | ||
316 | 848 | if (use_appname || label.empty()) | 799 | if (use_appname || label.empty()) |
317 | 849 | { | 800 | { |
324 | 850 | BamfApplication* app = bamf_matcher_get_application_for_window(matcher_, window); | 801 | if (ApplicationPtr const& app = window->application()) |
325 | 851 | 802 | label = app->title(); | |
320 | 852 | if (BAMF_IS_APPLICATION(app)) | ||
321 | 853 | view = reinterpret_cast<BamfView*>(app); | ||
322 | 854 | |||
323 | 855 | label = glib::String(bamf_view_get_name(view)).Str(); | ||
326 | 856 | } | 803 | } |
327 | 857 | } | 804 | } |
328 | 858 | 805 | ||
329 | @@ -963,6 +910,12 @@ | |||
330 | 963 | return true; | 910 | return true; |
331 | 964 | } | 911 | } |
332 | 965 | 912 | ||
333 | 913 | void PanelMenuView::RefreshAndRedraw() | ||
334 | 914 | { | ||
335 | 915 | if (Refresh()) | ||
336 | 916 | QueueDraw(); | ||
337 | 917 | } | ||
338 | 918 | |||
339 | 966 | void PanelMenuView::OnActiveChanged(PanelIndicatorEntryView* view, bool is_active) | 919 | void PanelMenuView::OnActiveChanged(PanelIndicatorEntryView* view, bool is_active) |
340 | 967 | { | 920 | { |
341 | 968 | if (is_active) | 921 | if (is_active) |
342 | @@ -977,8 +930,7 @@ | |||
343 | 977 | } | 930 | } |
344 | 978 | } | 931 | } |
345 | 979 | 932 | ||
348 | 980 | if (Refresh()) | 933 | RefreshAndRedraw(); |
347 | 981 | FullRedraw(); | ||
349 | 982 | } | 934 | } |
350 | 983 | 935 | ||
351 | 984 | void PanelMenuView::OnEntryAdded(indicator::Entry::Ptr const& entry) | 936 | void PanelMenuView::OnEntryAdded(indicator::Entry::Ptr const& entry) |
352 | @@ -1012,22 +964,13 @@ | |||
353 | 1012 | } | 964 | } |
354 | 1013 | } | 965 | } |
355 | 1014 | 966 | ||
356 | 1015 | void PanelMenuView::OnNameChanged(BamfView* bamf_view, gchar* new_name, gchar* old_name) | ||
357 | 1016 | { | ||
358 | 1017 | if (Refresh()) | ||
359 | 1018 | FullRedraw(); | ||
360 | 1019 | } | ||
361 | 1020 | |||
362 | 1021 | bool PanelMenuView::OnNewAppShow() | 967 | bool PanelMenuView::OnNewAppShow() |
363 | 1022 | { | 968 | { |
366 | 1023 | BamfApplication* active_app = bamf_matcher_get_active_application(matcher_); | 969 | new_application_ = ApplicationManager::Default().GetActiveApplication(); |
365 | 1024 | new_application_ = glib::Object<BamfApplication>(active_app, glib::AddRef()); | ||
367 | 1025 | QueueDraw(); | 970 | QueueDraw(); |
368 | 1026 | 971 | ||
369 | 1027 | if (sources_.GetSource(NEW_APP_HIDE_TIMEOUT)) | 972 | if (sources_.GetSource(NEW_APP_HIDE_TIMEOUT)) |
370 | 1028 | { | ||
371 | 1029 | new_app_menu_shown_ = false; | 973 | new_app_menu_shown_ = false; |
372 | 1030 | } | ||
373 | 1031 | 974 | ||
374 | 1032 | auto cb_func = sigc::mem_fun(this, &PanelMenuView::OnNewAppHide); | 975 | auto cb_func = sigc::mem_fun(this, &PanelMenuView::OnNewAppHide); |
375 | 1033 | sources_.AddTimeoutSeconds(menu_manager_->discovery(), cb_func, NEW_APP_HIDE_TIMEOUT); | 976 | sources_.AddTimeoutSeconds(menu_manager_->discovery(), cb_func, NEW_APP_HIDE_TIMEOUT); |
376 | @@ -1044,69 +987,51 @@ | |||
377 | 1044 | return false; | 987 | return false; |
378 | 1045 | } | 988 | } |
379 | 1046 | 989 | ||
381 | 1047 | void PanelMenuView::OnViewOpened(BamfMatcher *matcher, BamfView *view) | 990 | void PanelMenuView::OnApplicationStarted(ApplicationPtr const& app) |
382 | 1048 | { | 991 | { |
383 | 1049 | /* FIXME: here we should also check for if the view is also user_visible | 992 | /* FIXME: here we should also check for if the view is also user_visible |
384 | 1050 | * but it seems that BAMF doesn't handle this correctly after some | 993 | * but it seems that BAMF doesn't handle this correctly after some |
385 | 1051 | * stress tests (repeated launches). */ | 994 | * stress tests (repeated launches). */ |
387 | 1052 | if (!BAMF_IS_APPLICATION(view) || integrated_menus_) | 995 | if (integrated_menus_) |
388 | 1053 | return; | 996 | return; |
389 | 1054 | 997 | ||
391 | 1055 | new_apps_.push_front(glib::Object<BamfApplication>(BAMF_APPLICATION(view), glib::AddRef())); | 998 | new_apps_.push_front(app); |
392 | 1056 | } | 999 | } |
393 | 1057 | 1000 | ||
395 | 1058 | void PanelMenuView::OnApplicationClosed(BamfApplication* app) | 1001 | void PanelMenuView::OnApplicationClosed(ApplicationPtr const& app) |
396 | 1059 | { | 1002 | { |
398 | 1060 | if (BAMF_IS_APPLICATION(app) && !integrated_menus_) | 1003 | if (app && !integrated_menus_) |
399 | 1061 | { | 1004 | { |
400 | 1062 | if (std::find(new_apps_.begin(), new_apps_.end(), app) != new_apps_.end()) | 1005 | if (std::find(new_apps_.begin(), new_apps_.end(), app) != new_apps_.end()) |
401 | 1063 | { | 1006 | { |
403 | 1064 | new_apps_.remove(glib::Object<BamfApplication>(app, glib::AddRef())); | 1007 | new_apps_.remove(app); |
404 | 1065 | } | 1008 | } |
405 | 1066 | else if (new_apps_.empty()) | 1009 | else if (new_apps_.empty()) |
406 | 1067 | { | 1010 | { |
408 | 1068 | new_application_ = nullptr; | 1011 | new_application_.reset(); |
409 | 1069 | } | 1012 | } |
410 | 1070 | } | 1013 | } |
411 | 1071 | 1014 | ||
412 | 1072 | if (app == new_application_) | 1015 | if (app == new_application_) |
413 | 1073 | { | 1016 | { |
450 | 1074 | new_application_ = nullptr; | 1017 | new_application_.reset(); |
451 | 1075 | } | 1018 | } |
452 | 1076 | } | 1019 | } |
453 | 1077 | 1020 | ||
454 | 1078 | void PanelMenuView::OnViewClosed(BamfMatcher *matcher, BamfView *view) | 1021 | void PanelMenuView::OnWindowClosed(ApplicationWindowPtr const& win) |
455 | 1079 | { | 1022 | { |
456 | 1080 | if (reinterpret_cast<BamfView*>(view_name_changed_signal_.object()) == view) | 1023 | /* FIXME, this can be removed when window_unmapped WindowManager signal |
457 | 1081 | { | 1024 | * will emit the proper xid */ |
458 | 1082 | view_name_changed_signal_.Disconnect(); | 1025 | OnWindowUnmapped(win->window_id()); |
459 | 1083 | } | 1026 | } |
460 | 1084 | 1027 | ||
461 | 1085 | if (BAMF_IS_APPLICATION(view)) | 1028 | void PanelMenuView::OnActiveAppChanged(ApplicationPtr const& new_app) |
462 | 1086 | { | 1029 | { |
463 | 1087 | OnApplicationClosed(reinterpret_cast<BamfApplication*>(view)); | 1030 | if (new_app) |
464 | 1088 | } | 1031 | { |
465 | 1089 | else if (reinterpret_cast<BamfApplication*>(view) == new_application_) | 1032 | app_name_changed_conn_ = new_app->title.changed.connect([this] (std::string const&t) { |
466 | 1090 | { | 1033 | RefreshAndRedraw(); |
467 | 1091 | new_application_ = nullptr; | 1034 | }); |
432 | 1092 | } | ||
433 | 1093 | else if (BAMF_IS_WINDOW(view)) | ||
434 | 1094 | { | ||
435 | 1095 | /* FIXME, this can be removed when window_unmapped WindowManager signal | ||
436 | 1096 | * will emit the proper xid */ | ||
437 | 1097 | Window xid = bamf_window_get_xid(reinterpret_cast<BamfWindow*>(view)); | ||
438 | 1098 | OnWindowUnmapped(xid); | ||
439 | 1099 | } | ||
440 | 1100 | } | ||
441 | 1101 | |||
442 | 1102 | void PanelMenuView::OnActiveAppChanged(BamfMatcher *matcher, | ||
443 | 1103 | BamfApplication* old_app, | ||
444 | 1104 | BamfApplication* new_app) | ||
445 | 1105 | { | ||
446 | 1106 | if (BAMF_IS_APPLICATION(new_app)) | ||
447 | 1107 | { | ||
448 | 1108 | app_name_changed_signal_.Connect(BAMF_VIEW(new_app), "name-changed", | ||
449 | 1109 | sigc::mem_fun(this, &PanelMenuView::OnNameChanged)); | ||
468 | 1110 | 1035 | ||
469 | 1111 | if (integrated_menus_ || always_show_menus_) | 1036 | if (integrated_menus_ || always_show_menus_) |
470 | 1112 | return; | 1037 | return; |
471 | @@ -1140,7 +1065,7 @@ | |||
472 | 1140 | } | 1065 | } |
473 | 1141 | } | 1066 | } |
474 | 1142 | 1067 | ||
476 | 1143 | void PanelMenuView::OnActiveWindowChanged(BamfMatcher *matcher, BamfView* old_view, BamfView* new_view) | 1068 | void PanelMenuView::OnActiveWindowChanged(ApplicationWindowPtr const& new_win) |
477 | 1144 | { | 1069 | { |
478 | 1145 | show_now_activated_ = false; | 1070 | show_now_activated_ = false; |
479 | 1146 | is_maximized_ = false; | 1071 | is_maximized_ = false; |
480 | @@ -1149,13 +1074,12 @@ | |||
481 | 1149 | 1074 | ||
482 | 1150 | sources_.Remove(WINDOW_MOVED_TIMEOUT); | 1075 | sources_.Remove(WINDOW_MOVED_TIMEOUT); |
483 | 1151 | 1076 | ||
485 | 1152 | if (BAMF_IS_WINDOW(new_view)) | 1077 | if (new_win) |
486 | 1153 | { | 1078 | { |
490 | 1154 | BamfWindow* window = reinterpret_cast<BamfWindow*>(new_view); | 1079 | active_xid = new_win->window_id(); |
491 | 1155 | active_xid = bamf_window_get_xid(window); | 1080 | is_maximized_ = new_win->maximized(); |
489 | 1156 | is_maximized_ = (bamf_window_maximized(window) == BAMF_WINDOW_MAXIMIZED); | ||
492 | 1157 | 1081 | ||
494 | 1158 | if (bamf_window_get_window_type(window) == BAMF_WINDOW_DESKTOP) | 1082 | if (new_win->type() == WindowType::DESKTOP) |
495 | 1159 | { | 1083 | { |
496 | 1160 | is_desktop_focused_ = !maximized_window(); | 1084 | is_desktop_focused_ = !maximized_window(); |
497 | 1161 | we_control_active_ = true; | 1085 | we_control_active_ = true; |
498 | @@ -1173,14 +1097,13 @@ | |||
499 | 1173 | } | 1097 | } |
500 | 1174 | 1098 | ||
501 | 1175 | // register callback for new view | 1099 | // register callback for new view |
504 | 1176 | view_name_changed_signal_.Connect(new_view, "name-changed", | 1100 | win_name_changed_conn_ = new_win->title.changed.connect([this] (std::string const& t) { |
505 | 1177 | sigc::mem_fun(this, &PanelMenuView::OnNameChanged)); | 1101 | RefreshAndRedraw(); |
506 | 1102 | }); | ||
507 | 1178 | } | 1103 | } |
508 | 1179 | 1104 | ||
509 | 1180 | active_window = active_xid; | 1105 | active_window = active_xid; |
513 | 1181 | 1106 | RefreshAndRedraw(); | |
511 | 1182 | if (Refresh()) | ||
512 | 1183 | FullRedraw(); | ||
514 | 1184 | } | 1107 | } |
515 | 1185 | 1108 | ||
516 | 1186 | void PanelMenuView::OnSpreadInitiate() | 1109 | void PanelMenuView::OnSpreadInitiate() |
517 | @@ -1195,18 +1118,6 @@ | |||
518 | 1195 | QueueDraw(); | 1118 | QueueDraw(); |
519 | 1196 | } | 1119 | } |
520 | 1197 | 1120 | ||
521 | 1198 | void PanelMenuView::OnExpoInitiate() | ||
522 | 1199 | { | ||
523 | 1200 | if (Refresh()) | ||
524 | 1201 | QueueDraw(); | ||
525 | 1202 | } | ||
526 | 1203 | |||
527 | 1204 | void PanelMenuView::OnExpoTerminate() | ||
528 | 1205 | { | ||
529 | 1206 | if (Refresh()) | ||
530 | 1207 | QueueDraw(); | ||
531 | 1208 | } | ||
532 | 1209 | |||
533 | 1210 | void PanelMenuView::OnWindowMinimized(Window xid) | 1121 | void PanelMenuView::OnWindowMinimized(Window xid) |
534 | 1211 | { | 1122 | { |
535 | 1212 | maximized_wins_.erase(std::remove(maximized_wins_.begin(), maximized_wins_.end(), xid), maximized_wins_.end()); | 1123 | maximized_wins_.erase(std::remove(maximized_wins_.begin(), maximized_wins_.end(), xid), maximized_wins_.end()); |
536 | @@ -1214,13 +1125,11 @@ | |||
537 | 1214 | 1125 | ||
538 | 1215 | if (xid == active_window()) | 1126 | if (xid == active_window()) |
539 | 1216 | { | 1127 | { |
542 | 1217 | if (Refresh()) | 1128 | RefreshAndRedraw(); |
541 | 1218 | QueueDraw(); | ||
543 | 1219 | } | 1129 | } |
544 | 1220 | else if (integrated_menus_ && window_buttons_->controlled_window == xid) | 1130 | else if (integrated_menus_ && window_buttons_->controlled_window == xid) |
545 | 1221 | { | 1131 | { |
548 | 1222 | if (Refresh()) | 1132 | RefreshAndRedraw(); |
547 | 1223 | QueueDraw(); | ||
549 | 1224 | } | 1133 | } |
550 | 1225 | } | 1134 | } |
551 | 1226 | 1135 | ||
552 | @@ -1234,8 +1143,7 @@ | |||
553 | 1234 | UpdateMaximizedWindow(); | 1143 | UpdateMaximizedWindow(); |
554 | 1235 | } | 1144 | } |
555 | 1236 | 1145 | ||
558 | 1237 | if (Refresh()) | 1146 | RefreshAndRedraw(); |
557 | 1238 | QueueDraw(); | ||
559 | 1239 | } | 1147 | } |
560 | 1240 | else | 1148 | else |
561 | 1241 | { | 1149 | { |
562 | @@ -1247,8 +1155,7 @@ | |||
563 | 1247 | 1155 | ||
564 | 1248 | if (integrated_menus_ && IsWindowUnderOurControl(xid)) | 1156 | if (integrated_menus_ && IsWindowUnderOurControl(xid)) |
565 | 1249 | { | 1157 | { |
568 | 1250 | if (Refresh()) | 1158 | RefreshAndRedraw(); |
567 | 1251 | QueueDraw(); | ||
569 | 1252 | } | 1159 | } |
570 | 1253 | } | 1160 | } |
571 | 1254 | } | 1161 | } |
572 | @@ -1262,13 +1169,11 @@ | |||
573 | 1262 | 1169 | ||
574 | 1263 | if (xid == active_window()) | 1170 | if (xid == active_window()) |
575 | 1264 | { | 1171 | { |
578 | 1265 | if (Refresh()) | 1172 | RefreshAndRedraw(); |
577 | 1266 | QueueDraw(); | ||
579 | 1267 | } | 1173 | } |
580 | 1268 | else if (integrated_menus_ && window_buttons_->controlled_window == xid) | 1174 | else if (integrated_menus_ && window_buttons_->controlled_window == xid) |
581 | 1269 | { | 1175 | { |
584 | 1270 | if (Refresh()) | 1176 | RefreshAndRedraw(); |
583 | 1271 | QueueDraw(); | ||
585 | 1272 | } | 1177 | } |
586 | 1273 | } | 1178 | } |
587 | 1274 | 1179 | ||
588 | @@ -1281,8 +1186,7 @@ | |||
589 | 1281 | maximized_wins_.push_front(xid); | 1186 | maximized_wins_.push_front(xid); |
590 | 1282 | UpdateMaximizedWindow(); | 1187 | UpdateMaximizedWindow(); |
591 | 1283 | 1188 | ||
594 | 1284 | if (Refresh()) | 1189 | RefreshAndRedraw(); |
593 | 1285 | QueueDraw(); | ||
595 | 1286 | } | 1190 | } |
596 | 1287 | else | 1191 | else |
597 | 1288 | { | 1192 | { |
598 | @@ -1303,8 +1207,7 @@ | |||
599 | 1303 | CheckMouseInside(); | 1207 | CheckMouseInside(); |
600 | 1304 | is_maximized_ = true; | 1208 | is_maximized_ = true; |
601 | 1305 | 1209 | ||
604 | 1306 | if (Refresh()) | 1210 | RefreshAndRedraw(); |
603 | 1307 | FullRedraw(); | ||
605 | 1308 | } | 1211 | } |
606 | 1309 | else | 1212 | else |
607 | 1310 | { | 1213 | { |
608 | @@ -1313,8 +1216,7 @@ | |||
609 | 1313 | 1216 | ||
610 | 1314 | if (integrated_menus_ && IsWindowUnderOurControl(xid)) | 1217 | if (integrated_menus_ && IsWindowUnderOurControl(xid)) |
611 | 1315 | { | 1218 | { |
614 | 1316 | if (Refresh()) | 1219 | RefreshAndRedraw(); |
613 | 1317 | QueueDraw(); | ||
615 | 1318 | } | 1220 | } |
616 | 1319 | } | 1221 | } |
617 | 1320 | } | 1222 | } |
618 | @@ -1328,14 +1230,11 @@ | |||
619 | 1328 | { | 1230 | { |
620 | 1329 | is_maximized_ = false; | 1231 | is_maximized_ = false; |
621 | 1330 | is_grabbed_ = false; | 1232 | is_grabbed_ = false; |
625 | 1331 | 1233 | RefreshAndRedraw(); | |
623 | 1332 | if (Refresh()) | ||
624 | 1333 | FullRedraw(); | ||
626 | 1334 | } | 1234 | } |
627 | 1335 | else if (integrated_menus_ && window_buttons_->controlled_window == xid) | 1235 | else if (integrated_menus_ && window_buttons_->controlled_window == xid) |
628 | 1336 | { | 1236 | { |
631 | 1337 | if (Refresh()) | 1237 | RefreshAndRedraw(); |
630 | 1338 | QueueDraw(); | ||
632 | 1339 | } | 1238 | } |
633 | 1340 | } | 1239 | } |
634 | 1341 | 1240 | ||
635 | @@ -1350,8 +1249,7 @@ | |||
636 | 1350 | if (HasVisibleMenus()) | 1249 | if (HasVisibleMenus()) |
637 | 1351 | on_indicator_updated.emit(); | 1250 | on_indicator_updated.emit(); |
638 | 1352 | 1251 | ||
641 | 1353 | if (Refresh()) | 1252 | RefreshAndRedraw(); |
640 | 1354 | QueueDraw(); | ||
642 | 1355 | } | 1253 | } |
643 | 1356 | 1254 | ||
644 | 1357 | return false; | 1255 | return false; |
645 | @@ -1436,55 +1334,20 @@ | |||
646 | 1436 | Window PanelMenuView::GetTopWindow() const | 1334 | Window PanelMenuView::GetTopWindow() const |
647 | 1437 | { | 1335 | { |
648 | 1438 | Window window_xid = 0; | 1336 | Window window_xid = 0; |
649 | 1439 | GList* windows = bamf_matcher_get_window_stack_for_monitor(matcher_, monitor_); | ||
650 | 1440 | 1337 | ||
652 | 1441 | for (GList* l = windows; l; l = l->next) | 1338 | for (auto const& win : ApplicationManager::Default().GetWindowsForMonitor(monitor_)) |
653 | 1442 | { | 1339 | { |
661 | 1443 | if (!BAMF_IS_WINDOW(l->data)) | 1340 | Window xid = win->window_id(); |
662 | 1444 | continue; | 1341 | |
663 | 1445 | 1342 | if (win->visible() && IsValidWindow(xid)) | |
657 | 1446 | Window xid = bamf_window_get_xid(static_cast<BamfWindow*>(l->data)); | ||
658 | 1447 | bool visible = bamf_view_is_user_visible(static_cast<BamfView*>(l->data)); | ||
659 | 1448 | |||
660 | 1449 | if (visible && IsValidWindow(xid)) | ||
664 | 1450 | { | 1343 | { |
665 | 1451 | window_xid = xid; | 1344 | window_xid = xid; |
666 | 1452 | } | 1345 | } |
667 | 1453 | } | 1346 | } |
668 | 1454 | 1347 | ||
669 | 1455 | g_list_free(windows); | ||
670 | 1456 | |||
671 | 1457 | return window_xid; | 1348 | return window_xid; |
672 | 1458 | } | 1349 | } |
673 | 1459 | 1350 | ||
674 | 1460 | BamfWindow* PanelMenuView::GetBamfWindowForXid(Window xid) const | ||
675 | 1461 | { | ||
676 | 1462 | BamfWindow* window = nullptr; | ||
677 | 1463 | |||
678 | 1464 | if (xid != 0) | ||
679 | 1465 | { | ||
680 | 1466 | GList* windows = bamf_matcher_get_windows(matcher_); | ||
681 | 1467 | |||
682 | 1468 | for (GList* l = windows; l; l = l->next) | ||
683 | 1469 | { | ||
684 | 1470 | if (!BAMF_IS_WINDOW(l->data)) | ||
685 | 1471 | continue; | ||
686 | 1472 | |||
687 | 1473 | auto win = static_cast<BamfWindow*>(l->data); | ||
688 | 1474 | |||
689 | 1475 | if (bamf_window_get_xid(win) == xid) | ||
690 | 1476 | { | ||
691 | 1477 | window = win; | ||
692 | 1478 | break; | ||
693 | 1479 | } | ||
694 | 1480 | } | ||
695 | 1481 | |||
696 | 1482 | g_list_free(windows); | ||
697 | 1483 | } | ||
698 | 1484 | |||
699 | 1485 | return window; | ||
700 | 1486 | } | ||
701 | 1487 | |||
702 | 1488 | void PanelMenuView::ActivateIntegratedMenus(nux::Point const& click) | 1351 | void PanelMenuView::ActivateIntegratedMenus(nux::Point const& click) |
703 | 1489 | { | 1352 | { |
704 | 1490 | if (!layout_->GetAbsoluteGeometry().IsInside(click)) | 1353 | if (!layout_->GetAbsoluteGeometry().IsInside(click)) |
705 | @@ -1679,8 +1542,7 @@ | |||
706 | 1679 | 1542 | ||
707 | 1680 | is_inside_ = true; | 1543 | is_inside_ = true; |
708 | 1681 | is_grabbed_ = true; | 1544 | is_grabbed_ = true; |
711 | 1682 | if (Refresh()) | 1545 | RefreshAndRedraw(); |
710 | 1683 | FullRedraw(); | ||
712 | 1684 | 1546 | ||
713 | 1685 | /* Ungrab the pointer and start the X move, to make the decorator handle it */ | 1547 | /* Ungrab the pointer and start the X move, to make the decorator handle it */ |
714 | 1686 | titlebar_grab_area_->SetGrabbed(false); | 1548 | titlebar_grab_area_->SetGrabbed(false); |
715 | @@ -1700,8 +1562,7 @@ | |||
716 | 1700 | if (!is_inside_) | 1562 | if (!is_inside_) |
717 | 1701 | is_grabbed_ = false; | 1563 | is_grabbed_ = false; |
718 | 1702 | 1564 | ||
721 | 1703 | if (Refresh()) | 1565 | RefreshAndRedraw(); |
720 | 1704 | FullRedraw(); | ||
722 | 1705 | } | 1566 | } |
723 | 1706 | 1567 | ||
724 | 1707 | // Introspectable | 1568 | // Introspectable |
725 | @@ -1763,8 +1624,7 @@ | |||
726 | 1763 | show_now_activated_ = false; | 1624 | show_now_activated_ = false; |
727 | 1764 | } | 1625 | } |
728 | 1765 | 1626 | ||
731 | 1766 | if (Refresh()) | 1627 | RefreshAndRedraw(); |
730 | 1767 | QueueDraw(); | ||
732 | 1768 | } | 1628 | } |
733 | 1769 | 1629 | ||
734 | 1770 | void PanelMenuView::OnLauncherKeyNavStarted(GVariant* data) | 1630 | void PanelMenuView::OnLauncherKeyNavStarted(GVariant* data) |
735 | @@ -1785,9 +1645,7 @@ | |||
736 | 1785 | 1645 | ||
737 | 1786 | launcher_keynav_ = false; | 1646 | launcher_keynav_ = false; |
738 | 1787 | CheckMouseInside(); | 1647 | CheckMouseInside(); |
742 | 1788 | 1648 | RefreshAndRedraw(); | |
740 | 1789 | if (Refresh()) | ||
741 | 1790 | QueueDraw(); | ||
743 | 1791 | } | 1649 | } |
744 | 1792 | 1650 | ||
745 | 1793 | void PanelMenuView::OnLauncherSelectionChanged(GVariant* data) | 1651 | void PanelMenuView::OnLauncherSelectionChanged(GVariant* data) |
746 | @@ -1854,23 +1712,17 @@ | |||
747 | 1854 | 1712 | ||
748 | 1855 | maximized_wins_.clear(); | 1713 | maximized_wins_.clear(); |
749 | 1856 | monitor_geo_ = UScreen::GetDefault()->GetMonitorGeometry(monitor_); | 1714 | monitor_geo_ = UScreen::GetDefault()->GetMonitorGeometry(monitor_); |
750 | 1857 | GList* windows = bamf_matcher_get_window_stack_for_monitor(matcher_, monitor_); | ||
751 | 1858 | 1715 | ||
753 | 1859 | for (GList* l = windows; l; l = l->next) | 1716 | for (auto const& win : ApplicationManager::Default().GetWindowsForMonitor(monitor_)) |
754 | 1860 | { | 1717 | { |
763 | 1861 | if (!BAMF_IS_WINDOW(l->data)) | 1718 | auto xid = win->window_id(); |
764 | 1862 | continue; | 1719 | |
765 | 1863 | 1720 | if (win->active()) | |
758 | 1864 | auto window = static_cast<BamfWindow*>(l->data); | ||
759 | 1865 | auto view = static_cast<BamfView*>(l->data); | ||
760 | 1866 | auto xid = bamf_window_get_xid(window); | ||
761 | 1867 | |||
762 | 1868 | if (bamf_view_is_active(view)) | ||
766 | 1869 | active_window = xid; | 1721 | active_window = xid; |
767 | 1870 | 1722 | ||
769 | 1871 | if (bamf_window_maximized(window) == BAMF_WINDOW_MAXIMIZED) | 1723 | if (win->maximized()) |
770 | 1872 | { | 1724 | { |
772 | 1873 | if (xid == active_window()) | 1725 | if (win->active()) |
773 | 1874 | maximized_wins_.push_front(xid); | 1726 | maximized_wins_.push_front(xid); |
774 | 1875 | else | 1727 | else |
775 | 1876 | maximized_wins_.push_back(xid); | 1728 | maximized_wins_.push_back(xid); |
776 | @@ -1881,7 +1733,6 @@ | |||
777 | 1881 | UpdateMaximizedWindow(); | 1733 | UpdateMaximizedWindow(); |
778 | 1882 | 1734 | ||
779 | 1883 | OnStyleChanged(); | 1735 | OnStyleChanged(); |
780 | 1884 | g_list_free(windows); | ||
781 | 1885 | } | 1736 | } |
782 | 1886 | 1737 | ||
783 | 1887 | bool PanelMenuView::HasMenus() const | 1738 | bool PanelMenuView::HasMenus() const |
784 | 1888 | 1739 | ||
785 | === modified file 'panel/PanelMenuView.h' | |||
786 | --- panel/PanelMenuView.h 2015-02-04 09:54:49 +0000 | |||
787 | +++ panel/PanelMenuView.h 2015-05-22 16:04:25 +0000 | |||
788 | @@ -22,12 +22,11 @@ | |||
789 | 22 | #define PANEL_MENU_VIEW_H | 22 | #define PANEL_MENU_VIEW_H |
790 | 23 | 23 | ||
791 | 24 | #include <NuxCore/Animation.h> | 24 | #include <NuxCore/Animation.h> |
792 | 25 | #include <UnityCore/GLibWrapper.h> | ||
793 | 26 | #include <UnityCore/GLibSignal.h> | 25 | #include <UnityCore/GLibSignal.h> |
794 | 27 | #include <libbamf/libbamf.h> | ||
795 | 28 | 26 | ||
796 | 29 | #include "PanelIndicatorsView.h" | 27 | #include "PanelIndicatorsView.h" |
797 | 30 | #include "PanelTitlebarGrabAreaView.h" | 28 | #include "PanelTitlebarGrabAreaView.h" |
798 | 29 | #include "unity-shared/ApplicationManager.h" | ||
799 | 31 | #include "unity-shared/MenuManager.h" | 30 | #include "unity-shared/MenuManager.h" |
800 | 32 | #include "unity-shared/StaticCairoText.h" | 31 | #include "unity-shared/StaticCairoText.h" |
801 | 33 | #include "unity-shared/WindowButtons.h" | 32 | #include "unity-shared/WindowButtons.h" |
802 | @@ -88,20 +87,17 @@ | |||
803 | 88 | 87 | ||
804 | 89 | void OnActiveChanged(PanelIndicatorEntryView* view, bool is_active); | 88 | void OnActiveChanged(PanelIndicatorEntryView* view, bool is_active); |
805 | 90 | void OnEntryViewAdded(PanelIndicatorEntryView* view); | 89 | void OnEntryViewAdded(PanelIndicatorEntryView* view); |
812 | 91 | void OnViewOpened(BamfMatcher* matcher, BamfView* view); | 90 | void OnApplicationStarted(ApplicationPtr const&); |
813 | 92 | void OnViewClosed(BamfMatcher* matcher, BamfView* view); | 91 | void OnApplicationClosed(ApplicationPtr const&); |
814 | 93 | void OnApplicationClosed(BamfApplication* app); | 92 | void OnWindowClosed(ApplicationWindowPtr const&); |
815 | 94 | void OnActiveWindowChanged(BamfMatcher* matcher, BamfView* old_view, BamfView* new_view); | 93 | void OnActiveWindowChanged(ApplicationWindowPtr const&); |
816 | 95 | void OnActiveAppChanged(BamfMatcher* matcher, BamfApplication* old_app, BamfApplication* new_app); | 94 | void OnActiveAppChanged(ApplicationPtr const&); |
811 | 96 | void OnNameChanged(BamfView* bamf_view, gchar* new_name, gchar* old_name); | ||
817 | 97 | void OnStyleChanged(); | 95 | void OnStyleChanged(); |
818 | 98 | void OnLIMChanged(bool); | 96 | void OnLIMChanged(bool); |
819 | 99 | void OnAlwaysShowMenusChanged(bool); | 97 | void OnAlwaysShowMenusChanged(bool); |
820 | 100 | 98 | ||
821 | 101 | void OnSpreadInitiate(); | 99 | void OnSpreadInitiate(); |
822 | 102 | void OnSpreadTerminate(); | 100 | void OnSpreadTerminate(); |
823 | 103 | void OnExpoInitiate(); | ||
824 | 104 | void OnExpoTerminate(); | ||
825 | 105 | void OnWindowMinimized(Window xid); | 101 | void OnWindowMinimized(Window xid); |
826 | 106 | void OnWindowUnminimized(Window xid); | 102 | void OnWindowUnminimized(Window xid); |
827 | 107 | void OnWindowUnmapped(Window xid); | 103 | void OnWindowUnmapped(Window xid); |
828 | @@ -122,6 +118,7 @@ | |||
829 | 122 | void FullRedraw(); | 118 | void FullRedraw(); |
830 | 123 | std::string GetCurrentTitle() const; | 119 | std::string GetCurrentTitle() const; |
831 | 124 | bool Refresh(bool force = false); | 120 | bool Refresh(bool force = false); |
832 | 121 | void RefreshAndRedraw(); | ||
833 | 125 | 122 | ||
834 | 126 | void UpdateTitleTexture(nux::Geometry const&, std::string const& label); | 123 | void UpdateTitleTexture(nux::Geometry const&, std::string const& label); |
835 | 127 | void UpdateLastGeometry(nux::Geometry const& geo); | 124 | void UpdateLastGeometry(nux::Geometry const& geo); |
836 | @@ -131,8 +128,6 @@ | |||
837 | 131 | void OnPanelViewMouseEnter(int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state); | 128 | void OnPanelViewMouseEnter(int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state); |
838 | 132 | void OnPanelViewMouseLeave(int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state); | 129 | void OnPanelViewMouseLeave(int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state); |
839 | 133 | 130 | ||
840 | 134 | BamfWindow* GetBamfWindowForXid(Window xid) const; | ||
841 | 135 | |||
842 | 136 | void OnSwitcherShown(GVariant* data); | 131 | void OnSwitcherShown(GVariant* data); |
843 | 137 | void OnLauncherKeyNavStarted(GVariant* data); | 132 | void OnLauncherKeyNavStarted(GVariant* data); |
844 | 138 | void OnLauncherKeyNavEnded(GVariant* data); | 133 | void OnLauncherKeyNavEnded(GVariant* data); |
845 | @@ -164,7 +159,6 @@ | |||
846 | 164 | void ActivateIntegratedMenus(nux::Point const&); | 159 | void ActivateIntegratedMenus(nux::Point const&); |
847 | 165 | 160 | ||
848 | 166 | menu::Manager::Ptr menu_manager_; | 161 | menu::Manager::Ptr menu_manager_; |
849 | 167 | glib::Object<BamfMatcher> matcher_; | ||
850 | 168 | 162 | ||
851 | 169 | nux::TextureLayer* title_layer_; | 163 | nux::TextureLayer* title_layer_; |
852 | 170 | nux::ObjectPtr<WindowButtons> window_buttons_; | 164 | nux::ObjectPtr<WindowButtons> window_buttons_; |
853 | @@ -179,8 +173,8 @@ | |||
854 | 179 | 173 | ||
855 | 180 | PanelIndicatorEntryView* last_active_view_; | 174 | PanelIndicatorEntryView* last_active_view_; |
856 | 181 | std::deque<Window> maximized_wins_; | 175 | std::deque<Window> maximized_wins_; |
859 | 182 | glib::Object<BamfApplication> new_application_; | 176 | ApplicationPtr new_application_; |
860 | 183 | std::list<glib::Object<BamfApplication>> new_apps_; | 177 | std::list<ApplicationPtr> new_apps_; |
861 | 184 | std::string panel_title_; | 178 | std::string panel_title_; |
862 | 185 | nux::Geometry last_geo_; | 179 | nux::Geometry last_geo_; |
863 | 186 | nux::Geometry title_geo_; | 180 | nux::Geometry title_geo_; |
864 | @@ -198,12 +192,8 @@ | |||
865 | 198 | nux::Geometry monitor_geo_; | 192 | nux::Geometry monitor_geo_; |
866 | 199 | const std::string desktop_name_; | 193 | const std::string desktop_name_; |
867 | 200 | 194 | ||
874 | 201 | glib::Signal<void, BamfMatcher*, BamfView*> view_opened_signal_; | 195 | connection::Wrapper app_name_changed_conn_; |
875 | 202 | glib::Signal<void, BamfMatcher*, BamfView*> view_closed_signal_; | 196 | connection::Wrapper win_name_changed_conn_; |
870 | 203 | glib::Signal<void, BamfMatcher*, BamfView*, BamfView*> active_win_changed_signal_; | ||
871 | 204 | glib::Signal<void, BamfMatcher*, BamfApplication*, BamfApplication*> active_app_changed_signal_; | ||
872 | 205 | glib::Signal<void, BamfView*, gchar*, gchar*> view_name_changed_signal_; | ||
873 | 206 | glib::Signal<void, BamfView*, gchar*, gchar*> app_name_changed_signal_; | ||
876 | 207 | 197 | ||
877 | 208 | UBusManager ubus_manager_; | 198 | UBusManager ubus_manager_; |
878 | 209 | glib::SourceManager sources_; | 199 | glib::SourceManager sources_; |
879 | 210 | 200 | ||
880 | === modified file 'tests/mock-application.h' | |||
881 | --- tests/mock-application.h 2015-02-03 09:46:48 +0000 | |||
882 | +++ tests/mock-application.h 2015-05-22 16:04:25 +0000 | |||
883 | @@ -40,8 +40,8 @@ | |||
884 | 40 | MockApplicationWindow(Window xid) | 40 | MockApplicationWindow(Window xid) |
885 | 41 | : xid_(xid) | 41 | : xid_(xid) |
886 | 42 | , monitor_(0) | 42 | , monitor_(0) |
887 | 43 | , type_(unity::WindowType::MOCK) | ||
888 | 43 | , title_("MockApplicationWindow "+std::to_string(xid_)) | 44 | , title_("MockApplicationWindow "+std::to_string(xid_)) |
889 | 44 | , type_("window") | ||
890 | 45 | , visible_(true) | 45 | , visible_(true) |
891 | 46 | , active_(false) | 46 | , active_(false) |
892 | 47 | , urgent_(false) | 47 | , urgent_(false) |
893 | @@ -61,26 +61,28 @@ | |||
894 | 61 | 61 | ||
895 | 62 | Window xid_; | 62 | Window xid_; |
896 | 63 | int monitor_; | 63 | int monitor_; |
897 | 64 | unity::WindowType type_; | ||
898 | 64 | std::string title_; | 65 | std::string title_; |
899 | 65 | std::string icon_; | 66 | std::string icon_; |
900 | 66 | std::string type_; | ||
901 | 67 | 67 | ||
902 | 68 | bool visible_; | 68 | bool visible_; |
903 | 69 | bool active_; | 69 | bool active_; |
904 | 70 | bool urgent_; | 70 | bool urgent_; |
905 | 71 | 71 | ||
907 | 72 | MOCK_CONST_METHOD0(type, std::string()); | 72 | MOCK_CONST_METHOD0(type, unity::WindowType()); |
908 | 73 | MOCK_CONST_METHOD0(window_id, Window()); | 73 | MOCK_CONST_METHOD0(window_id, Window()); |
909 | 74 | MOCK_CONST_METHOD0(monitor, int()); | 74 | MOCK_CONST_METHOD0(monitor, int()); |
910 | 75 | MOCK_CONST_METHOD0(application, unity::ApplicationPtr()); | 75 | MOCK_CONST_METHOD0(application, unity::ApplicationPtr()); |
911 | 76 | MOCK_CONST_METHOD0(Focus, bool()); | 76 | MOCK_CONST_METHOD0(Focus, bool()); |
912 | 77 | MOCK_CONST_METHOD0(Quit, void()); | 77 | MOCK_CONST_METHOD0(Quit, void()); |
913 | 78 | 78 | ||
915 | 79 | virtual bool LocalFocus() const | 79 | bool LocalFocus() |
916 | 80 | { | 80 | { |
917 | 81 | auto& wm = unity::WindowManager::Default(); | 81 | auto& wm = unity::WindowManager::Default(); |
918 | 82 | wm.Raise(xid_); | 82 | wm.Raise(xid_); |
919 | 83 | wm.Activate(xid_); | 83 | wm.Activate(xid_); |
920 | 84 | active_ = true; | ||
921 | 85 | active.changed.emit(active_); | ||
922 | 84 | return true; | 86 | return true; |
923 | 85 | } | 87 | } |
924 | 86 | 88 | ||
925 | @@ -124,7 +126,7 @@ | |||
926 | 124 | , active_(false) | 126 | , active_(false) |
927 | 125 | , running_(false) | 127 | , running_(false) |
928 | 126 | , urgent_(false) | 128 | , urgent_(false) |
930 | 127 | , type_("mock") | 129 | , type_(unity::AppType::MOCK) |
931 | 128 | { | 130 | { |
932 | 129 | seen.SetSetterFunction(sigc::mem_fun(this, &MockApplication::SetSeen)); | 131 | seen.SetSetterFunction(sigc::mem_fun(this, &MockApplication::SetSeen)); |
933 | 130 | sticky.SetSetterFunction(sigc::mem_fun(this, &MockApplication::SetSticky)); | 132 | sticky.SetSetterFunction(sigc::mem_fun(this, &MockApplication::SetSticky)); |
934 | @@ -159,10 +161,10 @@ | |||
935 | 159 | bool running_; | 161 | bool running_; |
936 | 160 | bool urgent_; | 162 | bool urgent_; |
937 | 161 | unity::WindowList windows_; | 163 | unity::WindowList windows_; |
939 | 162 | std::string type_; | 164 | unity::AppType type_; |
940 | 163 | std::vector<std::pair<unity::ApplicationEventType, unity::ApplicationSubjectPtr>> actions_log_; | 165 | std::vector<std::pair<unity::ApplicationEventType, unity::ApplicationSubjectPtr>> actions_log_; |
941 | 164 | 166 | ||
943 | 165 | MOCK_CONST_METHOD0(type, std::string()); | 167 | MOCK_CONST_METHOD0(type, unity::AppType()); |
944 | 166 | MOCK_CONST_METHOD0(repr, std::string()); | 168 | MOCK_CONST_METHOD0(repr, std::string()); |
945 | 167 | MOCK_CONST_METHOD0(desktop_id, std::string()); | 169 | MOCK_CONST_METHOD0(desktop_id, std::string()); |
946 | 168 | MOCK_CONST_METHOD0(GetWindows, unity::WindowList()); | 170 | MOCK_CONST_METHOD0(GetWindows, unity::WindowList()); |
947 | @@ -306,6 +308,9 @@ | |||
948 | 306 | ON_CALL(*this, GetActiveWindow()).WillByDefault(Invoke([this] { return unity::ApplicationWindowPtr(); } )); | 308 | ON_CALL(*this, GetActiveWindow()).WillByDefault(Invoke([this] { return unity::ApplicationWindowPtr(); } )); |
949 | 307 | ON_CALL(*this, GetRunningApplications()).WillByDefault(Invoke([this] { return unity::ApplicationList(); } )); | 309 | ON_CALL(*this, GetRunningApplications()).WillByDefault(Invoke([this] { return unity::ApplicationList(); } )); |
950 | 308 | ON_CALL(*this, GetApplicationForWindow(_)).WillByDefault(Invoke([this] (Window) { return unity::ApplicationPtr(); } )); | 310 | ON_CALL(*this, GetApplicationForWindow(_)).WillByDefault(Invoke([this] (Window) { return unity::ApplicationPtr(); } )); |
951 | 311 | ON_CALL(*this, GetActiveApplication()).WillByDefault(Invoke([this] { return unity::ApplicationPtr(); } )); | ||
952 | 312 | ON_CALL(*this, GetWindowsForMonitor(_)).WillByDefault(Invoke([this] (Window) { return unity::WindowList(); } )); | ||
953 | 313 | ON_CALL(*this, GetWindowForId(_)).WillByDefault(Invoke([this] (int) { return unity::ApplicationWindowPtr(); } )); | ||
954 | 309 | } | 314 | } |
955 | 310 | 315 | ||
956 | 311 | static void StartApp(std::string const& desktop_file) | 316 | static void StartApp(std::string const& desktop_file) |
957 | @@ -322,6 +327,9 @@ | |||
958 | 322 | MOCK_CONST_METHOD1(GetApplicationForDesktopFile, unity::ApplicationPtr(std::string const&)); | 327 | MOCK_CONST_METHOD1(GetApplicationForDesktopFile, unity::ApplicationPtr(std::string const&)); |
959 | 323 | MOCK_CONST_METHOD0(GetRunningApplications, unity::ApplicationList()); | 328 | MOCK_CONST_METHOD0(GetRunningApplications, unity::ApplicationList()); |
960 | 324 | MOCK_CONST_METHOD1(GetApplicationForWindow, unity::ApplicationPtr(Window)); | 329 | MOCK_CONST_METHOD1(GetApplicationForWindow, unity::ApplicationPtr(Window)); |
961 | 330 | MOCK_CONST_METHOD0(GetActiveApplication, unity::ApplicationPtr()); | ||
962 | 331 | MOCK_CONST_METHOD1(GetWindowsForMonitor, unity::WindowList(int)); | ||
963 | 332 | MOCK_CONST_METHOD1(GetWindowForId, unity::ApplicationWindowPtr(Window)); | ||
964 | 325 | 333 | ||
965 | 326 | unity::ApplicationPtr LocalGetApplicationForDesktopFile(std::string const& desktop_file) | 334 | unity::ApplicationPtr LocalGetApplicationForDesktopFile(std::string const& desktop_file) |
966 | 327 | { | 335 | { |
967 | 328 | 336 | ||
968 | === modified file 'tests/test_application_launcher_icon.cpp' | |||
969 | --- tests/test_application_launcher_icon.cpp 2015-03-30 15:48:38 +0000 | |||
970 | +++ tests/test_application_launcher_icon.cpp 2015-05-22 16:04:25 +0000 | |||
971 | @@ -775,7 +775,10 @@ | |||
972 | 775 | mock_app->windows_ = { win1, win2 }; | 775 | mock_app->windows_ = { win1, win2 }; |
973 | 776 | WM->AddStandaloneWindow(wm_win1); | 776 | WM->AddStandaloneWindow(wm_win1); |
974 | 777 | WM->AddStandaloneWindow(wm_win2); | 777 | WM->AddStandaloneWindow(wm_win2); |
975 | 778 | |||
976 | 779 | win2->Focus(); | ||
977 | 778 | ASSERT_TRUE(wm_win2->active()); | 780 | ASSERT_TRUE(wm_win2->active()); |
978 | 781 | ASSERT_TRUE(win2->active()); | ||
979 | 779 | 782 | ||
980 | 780 | auto const& menus = mock_icon->Menus(); | 783 | auto const& menus = mock_icon->Menus(); |
981 | 781 | auto const& menu1 = GetMenuItemWithLabel(menus, win1->title()); | 784 | auto const& menu1 = GetMenuItemWithLabel(menus, win1->title()); |
982 | @@ -1121,10 +1124,10 @@ | |||
983 | 1121 | 1124 | ||
984 | 1122 | TEST_F(TestApplicationLauncherIcon, AllowDetailViewInSwitcher) | 1125 | TEST_F(TestApplicationLauncherIcon, AllowDetailViewInSwitcher) |
985 | 1123 | { | 1126 | { |
987 | 1124 | mock_app->type_ = "mock"; | 1127 | mock_app->type_ = AppType::NORMAL; |
988 | 1125 | EXPECT_TRUE(mock_icon->AllowDetailViewInSwitcher()); | 1128 | EXPECT_TRUE(mock_icon->AllowDetailViewInSwitcher()); |
989 | 1126 | 1129 | ||
991 | 1127 | mock_app->type_ = "webapp"; | 1130 | mock_app->type_ = AppType::WEBAPP; |
992 | 1128 | EXPECT_FALSE(mock_icon->AllowDetailViewInSwitcher()); | 1131 | EXPECT_FALSE(mock_icon->AllowDetailViewInSwitcher()); |
993 | 1129 | } | 1132 | } |
994 | 1130 | 1133 | ||
995 | 1131 | 1134 | ||
996 | === modified file 'tests/test_panel_menu_view.cpp' | |||
997 | --- tests/test_panel_menu_view.cpp 2015-03-13 13:49:16 +0000 | |||
998 | +++ tests/test_panel_menu_view.cpp 2015-05-22 16:04:25 +0000 | |||
999 | @@ -45,13 +45,7 @@ | |||
1000 | 45 | { | 45 | { |
1001 | 46 | MockPanelMenuView(menu::Manager::Ptr const& menu_manager) | 46 | MockPanelMenuView(menu::Manager::Ptr const& menu_manager) |
1002 | 47 | : PanelMenuView(menu_manager) | 47 | : PanelMenuView(menu_manager) |
1010 | 48 | { | 48 | {} |
1004 | 49 | view_opened_signal_.Disconnect(); | ||
1005 | 50 | active_win_changed_signal_.Disconnect(); | ||
1006 | 51 | active_app_changed_signal_.Disconnect(); | ||
1007 | 52 | view_closed_signal_.Disconnect(); | ||
1008 | 53 | maximized_wins_.clear(); | ||
1009 | 54 | } | ||
1011 | 55 | 49 | ||
1012 | 56 | MOCK_METHOD0(QueueDraw, void()); | 50 | MOCK_METHOD0(QueueDraw, void()); |
1013 | 57 | MOCK_CONST_METHOD1(GetActiveViewName, std::string(bool)); | 51 | MOCK_CONST_METHOD1(GetActiveViewName, std::string(bool)); |
1014 | @@ -81,7 +75,6 @@ | |||
1015 | 81 | panel_win->ComputeContentSize(); | 75 | panel_win->ComputeContentSize(); |
1016 | 82 | 76 | ||
1017 | 83 | menu_view.SetMonitor(monitor); | 77 | menu_view.SetMonitor(monitor); |
1018 | 84 | menu_view.maximized_wins_.clear(); | ||
1019 | 85 | 78 | ||
1020 | 86 | return panel_win; | 79 | return panel_win; |
1021 | 87 | } | 80 | } |
1022 | 88 | 81 | ||
1023 | === modified file 'tests/test_switcher_controller.h' | |||
1024 | --- tests/test_switcher_controller.h 2014-03-21 04:40:12 +0000 | |||
1025 | +++ tests/test_switcher_controller.h 2015-05-22 16:04:25 +0000 | |||
1026 | @@ -54,7 +54,7 @@ | |||
1027 | 54 | FakeApplicationWindow(Window xid, uint64_t active_number = 0); | 54 | FakeApplicationWindow(Window xid, uint64_t active_number = 0); |
1028 | 55 | ~FakeApplicationWindow(); | 55 | ~FakeApplicationWindow(); |
1029 | 56 | 56 | ||
1031 | 57 | virtual std::string type() const; | 57 | virtual WindowType type() const; |
1032 | 58 | 58 | ||
1033 | 59 | virtual Window window_id() const; | 59 | virtual Window window_id() const; |
1034 | 60 | virtual int monitor() const; | 60 | virtual int monitor() const; |
1035 | 61 | 61 | ||
1036 | === modified file 'tests/test_switcher_controller_class.cpp' | |||
1037 | --- tests/test_switcher_controller_class.cpp 2013-10-14 17:36:51 +0000 | |||
1038 | +++ tests/test_switcher_controller_class.cpp 2015-05-22 16:04:25 +0000 | |||
1039 | @@ -41,7 +41,7 @@ | |||
1040 | 41 | testwrapper::StandaloneWM::Get()->Close(xid_); | 41 | testwrapper::StandaloneWM::Get()->Close(xid_); |
1041 | 42 | } | 42 | } |
1042 | 43 | 43 | ||
1044 | 44 | std::string FakeApplicationWindow::type() const { return "mock"; } | 44 | WindowType FakeApplicationWindow::type() const { return WindowType::MOCK; } |
1045 | 45 | 45 | ||
1046 | 46 | Window FakeApplicationWindow::window_id() const { return xid_; } | 46 | Window FakeApplicationWindow::window_id() const { return xid_; } |
1047 | 47 | int FakeApplicationWindow::monitor() const { return -1; } | 47 | int FakeApplicationWindow::monitor() const { return -1; } |
1048 | 48 | 48 | ||
1049 | === modified file 'unity-shared/ApplicationManager.cpp' | |||
1050 | --- unity-shared/ApplicationManager.cpp 2012-11-29 09:25:50 +0000 | |||
1051 | +++ unity-shared/ApplicationManager.cpp 2015-05-22 16:04:25 +0000 | |||
1052 | @@ -33,6 +33,25 @@ | |||
1053 | 33 | return *instance; | 33 | return *instance; |
1054 | 34 | } | 34 | } |
1055 | 35 | 35 | ||
1056 | 36 | bool operator==(ApplicationPtr const& lhs, ApplicationPtr const& rhs) | ||
1057 | 37 | { | ||
1058 | 38 | return (lhs.get() == rhs.get() || (lhs && rhs && *lhs == *rhs)); | ||
1059 | 39 | } | ||
1060 | 40 | |||
1061 | 41 | bool operator!=(ApplicationPtr const& lhs, ApplicationPtr const& rhs) | ||
1062 | 42 | { | ||
1063 | 43 | return !(lhs == rhs); | ||
1064 | 44 | } | ||
1065 | 45 | |||
1066 | 46 | bool operator==(ApplicationWindowPtr const& lhs, ApplicationWindowPtr const& rhs) | ||
1067 | 47 | { | ||
1068 | 48 | return (lhs.get() == rhs.get() || (lhs && rhs && *lhs == *rhs)); | ||
1069 | 49 | } | ||
1070 | 50 | |||
1071 | 51 | bool operator!=(ApplicationWindowPtr const& lhs, ApplicationWindowPtr const& rhs) | ||
1072 | 52 | { | ||
1073 | 53 | return !(lhs == rhs); | ||
1074 | 54 | } | ||
1075 | 36 | 55 | ||
1076 | 37 | // This method is needed to create an unresolved external for the | 56 | // This method is needed to create an unresolved external for the |
1077 | 38 | // WindowManager::Default method. This is because it is highly likely that | 57 | // WindowManager::Default method. This is because it is highly likely that |
1078 | 39 | 58 | ||
1079 | === modified file 'unity-shared/ApplicationManager.h' | |||
1080 | --- unity-shared/ApplicationManager.h 2013-09-11 09:11:30 +0000 | |||
1081 | +++ unity-shared/ApplicationManager.h 2015-05-22 16:04:25 +0000 | |||
1082 | @@ -50,13 +50,35 @@ | |||
1083 | 50 | LEAVE | 50 | LEAVE |
1084 | 51 | }; | 51 | }; |
1085 | 52 | 52 | ||
1086 | 53 | enum class AppType | ||
1087 | 54 | { | ||
1088 | 55 | NORMAL, | ||
1089 | 56 | WEBAPP, | ||
1090 | 57 | MOCK, | ||
1091 | 58 | UNKNOWN | ||
1092 | 59 | }; | ||
1093 | 60 | |||
1094 | 61 | enum class WindowType | ||
1095 | 62 | { | ||
1096 | 63 | NORMAL, | ||
1097 | 64 | DESKTOP, | ||
1098 | 65 | DOCK, | ||
1099 | 66 | DIALOG, | ||
1100 | 67 | TOOLBAR, | ||
1101 | 68 | MENU, | ||
1102 | 69 | UTILITY, | ||
1103 | 70 | SPLASHSCREEN, | ||
1104 | 71 | TAB, | ||
1105 | 72 | MOCK, | ||
1106 | 73 | UNKNOWN | ||
1107 | 74 | }; | ||
1108 | 75 | |||
1109 | 53 | class ApplicationWindow | 76 | class ApplicationWindow |
1110 | 54 | { | 77 | { |
1111 | 55 | public: | 78 | public: |
1112 | 56 | virtual ~ApplicationWindow() = default; | 79 | virtual ~ApplicationWindow() = default; |
1113 | 57 | 80 | ||
1116 | 58 | virtual std::string type() const = 0; // 'window' or 'tab' | 81 | virtual WindowType type() const = 0; |
1115 | 59 | |||
1117 | 60 | virtual Window window_id() const = 0; | 82 | virtual Window window_id() const = 0; |
1118 | 61 | virtual int monitor() const = 0; | 83 | virtual int monitor() const = 0; |
1119 | 62 | 84 | ||
1120 | @@ -69,20 +91,32 @@ | |||
1121 | 69 | // Closes the window, or the browser tab if a webapp. | 91 | // Closes the window, or the browser tab if a webapp. |
1122 | 70 | virtual void Quit() const = 0; | 92 | virtual void Quit() const = 0; |
1123 | 71 | 93 | ||
1124 | 94 | virtual bool operator==(ApplicationWindow const& other) const | ||
1125 | 95 | { | ||
1126 | 96 | return (window_id() == other.window_id()); | ||
1127 | 97 | } | ||
1128 | 98 | |||
1129 | 99 | virtual bool operator!=(ApplicationWindow const& other) const | ||
1130 | 100 | { | ||
1131 | 101 | return !(operator==(other)); | ||
1132 | 102 | } | ||
1133 | 103 | |||
1134 | 72 | nux::ROProperty<std::string> title; | 104 | nux::ROProperty<std::string> title; |
1135 | 73 | nux::ROProperty<std::string> icon; | 105 | nux::ROProperty<std::string> icon; |
1136 | 74 | 106 | ||
1137 | 75 | nux::ROProperty<bool> visible; | 107 | nux::ROProperty<bool> visible; |
1138 | 76 | nux::ROProperty<bool> active; | 108 | nux::ROProperty<bool> active; |
1139 | 77 | nux::ROProperty<bool> urgent; | 109 | nux::ROProperty<bool> urgent; |
1140 | 110 | nux::ROProperty<bool> maximized; | ||
1141 | 78 | }; | 111 | }; |
1142 | 79 | 112 | ||
1143 | 113 | |||
1144 | 80 | class Application | 114 | class Application |
1145 | 81 | { | 115 | { |
1146 | 82 | public: | 116 | public: |
1147 | 83 | virtual ~Application() = default; | 117 | virtual ~Application() = default; |
1148 | 84 | 118 | ||
1150 | 85 | virtual std::string type() const = 0; | 119 | virtual AppType type() const = 0; |
1151 | 86 | 120 | ||
1152 | 87 | // A string representation of the object. | 121 | // A string representation of the object. |
1153 | 88 | virtual std::string repr() const = 0; | 122 | virtual std::string repr() const = 0; |
1154 | @@ -102,6 +136,17 @@ | |||
1155 | 102 | virtual void LogEvent(ApplicationEventType, ApplicationSubjectPtr const&) const = 0; | 136 | virtual void LogEvent(ApplicationEventType, ApplicationSubjectPtr const&) const = 0; |
1156 | 103 | 137 | ||
1157 | 104 | virtual std::string desktop_id() const = 0; | 138 | virtual std::string desktop_id() const = 0; |
1158 | 139 | |||
1159 | 140 | virtual bool operator==(Application const& other) const | ||
1160 | 141 | { | ||
1161 | 142 | return (!desktop_id().empty() && (desktop_id() == other.desktop_id())); | ||
1162 | 143 | } | ||
1163 | 144 | |||
1164 | 145 | virtual bool operator!=(Application const& other) const | ||
1165 | 146 | { | ||
1166 | 147 | return !(operator==(other)); | ||
1167 | 148 | } | ||
1168 | 149 | |||
1169 | 105 | nux::ROProperty<std::string> desktop_file; | 150 | nux::ROProperty<std::string> desktop_file; |
1170 | 106 | nux::ROProperty<std::string> title; | 151 | nux::ROProperty<std::string> title; |
1171 | 107 | nux::ROProperty<std::string> icon; | 152 | nux::ROProperty<std::string> icon; |
1172 | @@ -117,11 +162,12 @@ | |||
1173 | 117 | 162 | ||
1174 | 118 | sigc::signal<void> closed; | 163 | sigc::signal<void> closed; |
1175 | 119 | 164 | ||
1179 | 120 | sigc::signal<void, ApplicationWindow const&> window_opened; | 165 | sigc::signal<void, ApplicationWindowPtr const&> window_opened; |
1180 | 121 | sigc::signal<void, ApplicationWindow const&> window_moved; | 166 | sigc::signal<void, ApplicationWindowPtr const&> window_moved; |
1181 | 122 | sigc::signal<void> window_closed; | 167 | sigc::signal<void, ApplicationWindowPtr const&> window_closed; |
1182 | 123 | }; | 168 | }; |
1183 | 124 | 169 | ||
1184 | 170 | |||
1185 | 125 | class ApplicationSubject | 171 | class ApplicationSubject |
1186 | 126 | { | 172 | { |
1187 | 127 | public: | 173 | public: |
1188 | @@ -165,16 +211,28 @@ | |||
1189 | 165 | static ApplicationManager& Default(); | 211 | static ApplicationManager& Default(); |
1190 | 166 | 212 | ||
1191 | 167 | virtual ApplicationPtr GetUnityApplication() const = 0; | 213 | virtual ApplicationPtr GetUnityApplication() const = 0; |
1192 | 214 | virtual ApplicationPtr GetActiveApplication() const = 0; | ||
1193 | 168 | virtual ApplicationWindowPtr GetActiveWindow() const = 0; | 215 | virtual ApplicationWindowPtr GetActiveWindow() const = 0; |
1194 | 169 | virtual ApplicationPtr GetApplicationForDesktopFile(std::string const& desktop_file) const = 0; | 216 | virtual ApplicationPtr GetApplicationForDesktopFile(std::string const& desktop_file) const = 0; |
1195 | 170 | virtual ApplicationList GetRunningApplications() const = 0; | 217 | virtual ApplicationList GetRunningApplications() const = 0; |
1196 | 218 | virtual WindowList GetWindowsForMonitor(int monitor = -1) const = 0; | ||
1197 | 171 | virtual ApplicationPtr GetApplicationForWindow(Window xid) const = 0; | 219 | virtual ApplicationPtr GetApplicationForWindow(Window xid) const = 0; |
1198 | 220 | virtual ApplicationWindowPtr GetWindowForId(Window xid) const = 0; | ||
1199 | 172 | 221 | ||
1200 | 173 | sigc::signal<void, ApplicationPtr const&> application_started; | 222 | sigc::signal<void, ApplicationPtr const&> application_started; |
1201 | 223 | sigc::signal<void, ApplicationPtr const&> application_stopped; | ||
1202 | 174 | sigc::signal<void, ApplicationPtr const&> active_application_changed; | 224 | sigc::signal<void, ApplicationPtr const&> active_application_changed; |
1203 | 225 | sigc::signal<void, ApplicationWindowPtr const&> window_opened; | ||
1204 | 226 | sigc::signal<void, ApplicationWindowPtr const&> window_closed; | ||
1205 | 175 | sigc::signal<void, ApplicationWindowPtr const&> active_window_changed; | 227 | sigc::signal<void, ApplicationWindowPtr const&> active_window_changed; |
1206 | 176 | }; | 228 | }; |
1207 | 177 | 229 | ||
1208 | 230 | |||
1209 | 231 | bool operator==(ApplicationPtr const&, ApplicationPtr const&); | ||
1210 | 232 | bool operator!=(ApplicationPtr const&, ApplicationPtr const&); | ||
1211 | 233 | bool operator==(ApplicationWindowPtr const&, ApplicationWindowPtr const&); | ||
1212 | 234 | bool operator!=(ApplicationWindowPtr const&, ApplicationWindowPtr const&); | ||
1213 | 235 | |||
1214 | 178 | } | 236 | } |
1215 | 179 | 237 | ||
1216 | 180 | #endif // UNITYSHARED_APPLICATION_MANAGER_H | 238 | #endif // UNITYSHARED_APPLICATION_MANAGER_H |
1217 | 181 | 239 | ||
1218 | === modified file 'unity-shared/BamfApplicationManager.cpp' | |||
1219 | --- unity-shared/BamfApplicationManager.cpp 2013-10-03 22:39:01 +0000 | |||
1220 | +++ unity-shared/BamfApplicationManager.cpp 2015-05-22 16:04:25 +0000 | |||
1221 | @@ -34,7 +34,47 @@ | |||
1222 | 34 | namespace | 34 | namespace |
1223 | 35 | { | 35 | { |
1224 | 36 | const char* UNSEEN_QUARK = "unity-unseen"; | 36 | const char* UNSEEN_QUARK = "unity-unseen"; |
1226 | 37 | } | 37 | |
1227 | 38 | namespace pool | ||
1228 | 39 | { | ||
1229 | 40 | // We keep a cache on views here, it would be nice to clean these on BAMF reload | ||
1230 | 41 | std::unordered_map<BamfView*, ApplicationPtr> apps_; | ||
1231 | 42 | std::unordered_map<BamfView*, ApplicationWindowPtr> wins_; | ||
1232 | 43 | |||
1233 | 44 | ApplicationPtr EnsureApplication(ApplicationManager const& manager, BamfView* view) | ||
1234 | 45 | { | ||
1235 | 46 | if (!BAMF_IS_APPLICATION(view)) | ||
1236 | 47 | return nullptr; | ||
1237 | 48 | |||
1238 | 49 | auto it = apps_.find(view); | ||
1239 | 50 | |||
1240 | 51 | if (it != apps_.end()) | ||
1241 | 52 | return it->second; | ||
1242 | 53 | |||
1243 | 54 | glib::Object<BamfApplication> bamfapp(reinterpret_cast<BamfApplication*>(view), glib::AddRef()); | ||
1244 | 55 | auto const& app = std::make_shared<Application>(manager, bamfapp); | ||
1245 | 56 | apps_.insert({view, app}); | ||
1246 | 57 | return app; | ||
1247 | 58 | } | ||
1248 | 59 | |||
1249 | 60 | ApplicationWindowPtr EnsureWindow(ApplicationManager const& manager, BamfView* view) | ||
1250 | 61 | { | ||
1251 | 62 | if (!BAMF_IS_WINDOW(view)) | ||
1252 | 63 | return nullptr; | ||
1253 | 64 | |||
1254 | 65 | auto it = wins_.find(view); | ||
1255 | 66 | |||
1256 | 67 | if (it != wins_.end()) | ||
1257 | 68 | return it->second; | ||
1258 | 69 | |||
1259 | 70 | glib::Object<BamfWindow> bamfwin(reinterpret_cast<BamfWindow*>(view), glib::AddRef()); | ||
1260 | 71 | auto const& win = std::make_shared<AppWindow>(manager, bamfwin); | ||
1261 | 72 | wins_.insert({view, win}); | ||
1262 | 73 | return win; | ||
1263 | 74 | } | ||
1264 | 75 | |||
1265 | 76 | } // pool namespace | ||
1266 | 77 | } // anonymous namespace | ||
1267 | 38 | 78 | ||
1268 | 39 | 79 | ||
1269 | 40 | // Due to the way glib handles object inheritance, we need to cast between pointer types. | 80 | // Due to the way glib handles object inheritance, we need to cast between pointer types. |
1270 | @@ -54,11 +94,6 @@ | |||
1271 | 54 | return glib::String(bamf_view_get_icon(bamf_view_)).Str(); | 94 | return glib::String(bamf_view_get_icon(bamf_view_)).Str(); |
1272 | 55 | } | 95 | } |
1273 | 56 | 96 | ||
1274 | 57 | std::string View::type() const | ||
1275 | 58 | { | ||
1276 | 59 | return glib::gchar_to_string(bamf_view_get_view_type(bamf_view_)); | ||
1277 | 60 | } | ||
1278 | 61 | |||
1279 | 62 | bool View::GetVisible() const | 97 | bool View::GetVisible() const |
1280 | 63 | { | 98 | { |
1281 | 64 | return bamf_view_is_user_visible(bamf_view_); | 99 | return bamf_view_is_user_visible(bamf_view_); |
1282 | @@ -80,11 +115,6 @@ | |||
1283 | 80 | } | 115 | } |
1284 | 81 | 116 | ||
1285 | 82 | 117 | ||
1286 | 83 | std::string WindowBase::type() const | ||
1287 | 84 | { | ||
1288 | 85 | return View::type(); | ||
1289 | 86 | } | ||
1290 | 87 | |||
1291 | 88 | WindowBase::WindowBase(ApplicationManager const& manager, | 118 | WindowBase::WindowBase(ApplicationManager const& manager, |
1292 | 89 | glib::Object<BamfView> const& window) | 119 | glib::Object<BamfView> const& window) |
1293 | 90 | : View(manager, window) | 120 | : View(manager, window) |
1294 | @@ -122,13 +152,10 @@ | |||
1295 | 122 | Window xid = window_id(); | 152 | Window xid = window_id(); |
1296 | 123 | if (xid) | 153 | if (xid) |
1297 | 124 | { | 154 | { |
1305 | 125 | std::vector<Window> windows = { xid }; | 155 | auto& wm = WindowManager::Default(); |
1306 | 126 | // TODO: we should simplify the use case of focusing one window. | 156 | wm.UnMinimize(xid); |
1307 | 127 | // Somewhat outside the scope of these changes however. | 157 | wm.Raise(xid); |
1308 | 128 | WindowManager::Default().FocusWindowGroup( | 158 | wm.Activate(xid); |
1302 | 129 | windows, | ||
1303 | 130 | WindowManager::FocusVisibility::ForceUnminimizeInvisible, | ||
1304 | 131 | monitor(),true); | ||
1309 | 132 | return true; | 159 | return true; |
1310 | 133 | } | 160 | } |
1311 | 134 | return false; | 161 | return false; |
1312 | @@ -136,14 +163,25 @@ | |||
1313 | 136 | 163 | ||
1314 | 137 | 164 | ||
1315 | 138 | AppWindow::AppWindow(ApplicationManager const& manager, glib::Object<BamfWindow> const& window) | 165 | AppWindow::AppWindow(ApplicationManager const& manager, glib::Object<BamfWindow> const& window) |
1318 | 139 | : WindowBase(manager, glib::object_cast<BamfView>(window)) | 166 | : AppWindow(manager, glib::object_cast<BamfView>(window)) |
1317 | 140 | , bamf_window_(window) | ||
1319 | 141 | {} | 167 | {} |
1320 | 142 | 168 | ||
1321 | 143 | AppWindow::AppWindow(ApplicationManager const& manager, glib::Object<BamfView> const& window) | 169 | AppWindow::AppWindow(ApplicationManager const& manager, glib::Object<BamfView> const& window) |
1322 | 144 | : WindowBase(manager, window) | 170 | : WindowBase(manager, window) |
1323 | 145 | , bamf_window_(glib::object_cast<BamfWindow>(window)) | 171 | , bamf_window_(glib::object_cast<BamfWindow>(window)) |
1325 | 146 | {} | 172 | { |
1326 | 173 | maximized.SetGetterFunction(std::bind(&AppWindow::GetMaximized, this)); | ||
1327 | 174 | signals_.Add<void, BamfWindow*, gint, gint>(bamf_window_, "maximized-changed", | ||
1328 | 175 | [this] (BamfWindow*, gint old_state, gint state) { | ||
1329 | 176 | if ((old_state == BAMF_WINDOW_MAXIMIZED) != (state == BAMF_WINDOW_MAXIMIZED)) | ||
1330 | 177 | this->maximized.changed.emit(state == BAMF_WINDOW_MAXIMIZED); | ||
1331 | 178 | }); | ||
1332 | 179 | } | ||
1333 | 180 | |||
1334 | 181 | bool AppWindow::GetMaximized() const | ||
1335 | 182 | { | ||
1336 | 183 | return bamf_window_maximized(bamf_window_) == BAMF_WINDOW_MAXIMIZED; | ||
1337 | 184 | } | ||
1338 | 147 | 185 | ||
1339 | 148 | Window AppWindow::window_id() const | 186 | Window AppWindow::window_id() const |
1340 | 149 | { | 187 | { |
1341 | @@ -155,6 +193,31 @@ | |||
1342 | 155 | return bamf_window_get_monitor(bamf_window_); | 193 | return bamf_window_get_monitor(bamf_window_); |
1343 | 156 | } | 194 | } |
1344 | 157 | 195 | ||
1345 | 196 | WindowType AppWindow::type() const | ||
1346 | 197 | { | ||
1347 | 198 | switch (bamf_window_get_window_type(bamf_window_)) | ||
1348 | 199 | { | ||
1349 | 200 | case BAMF_WINDOW_NORMAL: | ||
1350 | 201 | return WindowType::NORMAL; | ||
1351 | 202 | case BAMF_WINDOW_DESKTOP: | ||
1352 | 203 | return WindowType::DESKTOP; | ||
1353 | 204 | case BAMF_WINDOW_DOCK: | ||
1354 | 205 | return WindowType::DOCK; | ||
1355 | 206 | case BAMF_WINDOW_DIALOG: | ||
1356 | 207 | return WindowType::DIALOG; | ||
1357 | 208 | case BAMF_WINDOW_TOOLBAR: | ||
1358 | 209 | return WindowType::TOOLBAR; | ||
1359 | 210 | case BAMF_WINDOW_MENU: | ||
1360 | 211 | return WindowType::MENU; | ||
1361 | 212 | case BAMF_WINDOW_UTILITY: | ||
1362 | 213 | return WindowType::UTILITY; | ||
1363 | 214 | case BAMF_WINDOW_SPLASHSCREEN: | ||
1364 | 215 | return WindowType::SPLASHSCREEN; | ||
1365 | 216 | default: | ||
1366 | 217 | return WindowType::UNKNOWN; | ||
1367 | 218 | } | ||
1368 | 219 | } | ||
1369 | 220 | |||
1370 | 158 | ApplicationPtr AppWindow::application() const | 221 | ApplicationPtr AppWindow::application() const |
1371 | 159 | { | 222 | { |
1372 | 160 | // Moderately evil, but better than changing the method to non-const. | 223 | // Moderately evil, but better than changing the method to non-const. |
1373 | @@ -183,6 +246,11 @@ | |||
1374 | 183 | return bamf_tab_get_xid(bamf_tab_); | 246 | return bamf_tab_get_xid(bamf_tab_); |
1375 | 184 | } | 247 | } |
1376 | 185 | 248 | ||
1377 | 249 | WindowType Tab::type() const | ||
1378 | 250 | { | ||
1379 | 251 | return WindowType::TAB; | ||
1380 | 252 | } | ||
1381 | 253 | |||
1382 | 186 | int Tab::monitor() const | 254 | int Tab::monitor() const |
1383 | 187 | { | 255 | { |
1384 | 188 | // TODO, we could find the real window for the window_id, and get the monitor for that. | 256 | // TODO, we could find the real window for the window_id, and get the monitor for that. |
1385 | @@ -208,37 +276,14 @@ | |||
1386 | 208 | bamf_tab_close(bamf_tab_); | 276 | bamf_tab_close(bamf_tab_); |
1387 | 209 | } | 277 | } |
1388 | 210 | 278 | ||
1389 | 211 | // Being brutal with this function. | ||
1390 | 212 | ApplicationWindowPtr create_window(ApplicationManager const& manager, glib::Object<BamfView> const& view) | ||
1391 | 213 | { | ||
1392 | 214 | if (view.IsType(BAMF_TYPE_WINDOW)) | ||
1393 | 215 | { | ||
1394 | 216 | return std::make_shared<AppWindow>(manager, view); | ||
1395 | 217 | } | ||
1396 | 218 | else if (view.IsType(BAMF_TYPE_TAB)) | ||
1397 | 219 | { | ||
1398 | 220 | return std::make_shared<Tab>(manager, view); | ||
1399 | 221 | } | ||
1400 | 222 | // We don't handle applications here. | ||
1401 | 223 | return nullptr; | ||
1402 | 224 | } | ||
1403 | 225 | |||
1404 | 226 | Application::Application(ApplicationManager const& manager, glib::Object<BamfView> const& app) | 279 | Application::Application(ApplicationManager const& manager, glib::Object<BamfView> const& app) |
1410 | 227 | : View(manager, app) | 280 | : Application(manager, glib::object_cast<BamfApplication>(app)) |
1411 | 228 | , bamf_app_(glib::object_cast<BamfApplication>(app)) | 281 | {} |
1407 | 229 | { | ||
1408 | 230 | HookUpEvents(); | ||
1409 | 231 | } | ||
1412 | 232 | 282 | ||
1413 | 233 | Application::Application(ApplicationManager const& manager, glib::Object<BamfApplication> const& app) | 283 | Application::Application(ApplicationManager const& manager, glib::Object<BamfApplication> const& app) |
1414 | 234 | : View(manager, glib::object_cast<BamfView>(app)) | 284 | : View(manager, glib::object_cast<BamfView>(app)) |
1415 | 235 | , bamf_app_(app) | 285 | , bamf_app_(app) |
1416 | 236 | { | 286 | { |
1417 | 237 | HookUpEvents(); | ||
1418 | 238 | } | ||
1419 | 239 | |||
1420 | 240 | void Application::HookUpEvents() | ||
1421 | 241 | { | ||
1422 | 242 | // Hook up the property set/get functions | 287 | // Hook up the property set/get functions |
1423 | 243 | using namespace std::placeholders; | 288 | using namespace std::placeholders; |
1424 | 244 | desktop_file.SetGetterFunction(std::bind(&Application::GetDesktopFile, this)); | 289 | desktop_file.SetGetterFunction(std::bind(&Application::GetDesktopFile, this)); |
1425 | @@ -292,24 +337,21 @@ | |||
1426 | 292 | signals_.Add<void, BamfView*, BamfView*>(bamf_view_, "child-added", | 337 | signals_.Add<void, BamfView*, BamfView*>(bamf_view_, "child-added", |
1427 | 293 | [this] (BamfView*, BamfView* child) { | 338 | [this] (BamfView*, BamfView* child) { |
1428 | 294 | // Ownership is not passed on signals | 339 | // Ownership is not passed on signals |
1433 | 295 | glib::Object<BamfView> view(child, glib::AddRef()); | 340 | if (ApplicationWindowPtr const& win = pool::EnsureWindow(manager_, child)) |
1434 | 296 | ApplicationWindowPtr const& win = create_window(this->manager_, view); | 341 | this->window_opened.emit(win); |
1431 | 297 | if (win) | ||
1432 | 298 | this->window_opened.emit(*win); | ||
1435 | 299 | }); | 342 | }); |
1436 | 300 | 343 | ||
1437 | 301 | signals_.Add<void, BamfView*, BamfView*>(bamf_view_, "child-removed", | 344 | signals_.Add<void, BamfView*, BamfView*>(bamf_view_, "child-removed", |
1438 | 302 | [this] (BamfView*, BamfView* child) { | 345 | [this] (BamfView*, BamfView* child) { |
1440 | 303 | this->window_closed.emit(); | 346 | if (ApplicationWindowPtr const& win = pool::EnsureWindow(manager_, child)) |
1441 | 347 | this->window_closed.emit(win); | ||
1442 | 304 | }); | 348 | }); |
1443 | 305 | 349 | ||
1444 | 306 | signals_.Add<void, BamfView*, BamfView*>(bamf_view_, "child-moved", | 350 | signals_.Add<void, BamfView*, BamfView*>(bamf_view_, "child-moved", |
1445 | 307 | [this] (BamfView*, BamfView* child) { | 351 | [this] (BamfView*, BamfView* child) { |
1446 | 308 | // Ownership is not passed on signals | 352 | // Ownership is not passed on signals |
1451 | 309 | glib::Object<BamfView> view(child, glib::AddRef()); | 353 | if (ApplicationWindowPtr const& win = pool::EnsureWindow(manager_, child)) |
1452 | 310 | ApplicationWindowPtr const& win = create_window(this->manager_, view); | 354 | this->window_moved.emit(win); |
1449 | 311 | if (win) | ||
1450 | 312 | this->window_moved.emit(*win); | ||
1453 | 313 | }); | 355 | }); |
1454 | 314 | } | 356 | } |
1455 | 315 | 357 | ||
1456 | @@ -318,16 +360,21 @@ | |||
1457 | 318 | return glib::gchar_to_string(bamf_application_get_desktop_file(bamf_app_)); | 360 | return glib::gchar_to_string(bamf_application_get_desktop_file(bamf_app_)); |
1458 | 319 | } | 361 | } |
1459 | 320 | 362 | ||
1461 | 321 | std::string Application::type() const | 363 | AppType Application::type() const |
1462 | 322 | { | 364 | { |
1463 | 323 | // Can't determine the type of a non-running app. | 365 | // Can't determine the type of a non-running app. |
1464 | 324 | std::string result = "unknown"; | ||
1465 | 325 | if (running()) | 366 | if (running()) |
1466 | 326 | { | 367 | { |
1469 | 327 | const gchar* type = bamf_application_get_application_type(bamf_app_); | 368 | auto type = glib::gchar_to_string(bamf_application_get_application_type(bamf_app_)); |
1470 | 328 | if (type) result = type; | 369 | |
1471 | 370 | if (type == "system") | ||
1472 | 371 | return AppType::NORMAL; | ||
1473 | 372 | |||
1474 | 373 | if (type == "webapp") | ||
1475 | 374 | return AppType::WEBAPP; | ||
1476 | 329 | } | 375 | } |
1478 | 330 | return result; | 376 | |
1479 | 377 | return AppType::UNKNOWN; | ||
1480 | 331 | } | 378 | } |
1481 | 332 | 379 | ||
1482 | 333 | std::string Application::repr() const | 380 | std::string Application::repr() const |
1483 | @@ -347,9 +394,7 @@ | |||
1484 | 347 | std::shared_ptr<GList> children(bamf_view_get_children(bamf_view_), g_list_free); | 394 | std::shared_ptr<GList> children(bamf_view_get_children(bamf_view_), g_list_free); |
1485 | 348 | for (GList* l = children.get(); l; l = l->next) | 395 | for (GList* l = children.get(); l; l = l->next) |
1486 | 349 | { | 396 | { |
1490 | 350 | glib::Object<BamfView> view(BAMF_VIEW(l->data), glib::AddRef()); | 397 | if (ApplicationWindowPtr const& window = pool::EnsureWindow(manager_, static_cast<BamfView*>(l->data))) |
1488 | 351 | ApplicationWindowPtr const& window(create_window(manager_, view)); | ||
1489 | 352 | if (window) | ||
1491 | 353 | result.push_back(window); | 398 | result.push_back(window); |
1492 | 354 | } | 399 | } |
1493 | 355 | return result; | 400 | return result; |
1494 | @@ -389,9 +434,7 @@ | |||
1495 | 389 | 434 | ||
1496 | 390 | ApplicationWindowPtr Application::GetFocusableWindow() const | 435 | ApplicationWindowPtr Application::GetFocusableWindow() const |
1497 | 391 | { | 436 | { |
1501 | 392 | glib::Object<BamfView> view(bamf_application_get_focusable_child(bamf_app_), | 437 | return pool::EnsureWindow(manager_, bamf_application_get_focusable_child(bamf_app_)); |
1499 | 393 | glib::AddRef()); | ||
1500 | 394 | return create_window(manager_, view); | ||
1502 | 395 | } | 438 | } |
1503 | 396 | 439 | ||
1504 | 397 | void Application::Focus(bool show_only_visible, int monitor) const | 440 | void Application::Focus(bool show_only_visible, int monitor) const |
1505 | @@ -507,29 +550,19 @@ | |||
1506 | 507 | LOG_TRACE(logger) << "Create BAMF Application Manager"; | 550 | LOG_TRACE(logger) << "Create BAMF Application Manager"; |
1507 | 508 | signals_.Add<void, BamfMatcher*, BamfView*> (matcher_, "view-opened", | 551 | signals_.Add<void, BamfMatcher*, BamfView*> (matcher_, "view-opened", |
1508 | 509 | sigc::mem_fun(this, &Manager::OnViewOpened)); | 552 | sigc::mem_fun(this, &Manager::OnViewOpened)); |
1509 | 553 | signals_.Add<void, BamfMatcher*, BamfView*> (matcher_, "view-closed", | ||
1510 | 554 | sigc::mem_fun(this, &Manager::OnViewClosed)); | ||
1511 | 510 | 555 | ||
1512 | 511 | signals_.Add<void, BamfMatcher*, BamfView*, BamfView*>(matcher_, "active-window-changed", | 556 | signals_.Add<void, BamfMatcher*, BamfView*, BamfView*>(matcher_, "active-window-changed", |
1513 | 512 | [this](BamfMatcher*, BamfView* /* from */, BamfView* to) { | 557 | [this](BamfMatcher*, BamfView* /* from */, BamfView* to) { |
1518 | 513 | // Ownership is not passed on signals | 558 | if (ApplicationWindowPtr const& win = pool::EnsureWindow(*this, to)) |
1515 | 514 | glib::Object<BamfView> view(to, glib::AddRef()); | ||
1516 | 515 | ApplicationWindowPtr const& win = create_window(*this, view); | ||
1517 | 516 | if (win) | ||
1519 | 517 | this->active_window_changed.emit(win); | 559 | this->active_window_changed.emit(win); |
1520 | 518 | }); | 560 | }); |
1521 | 519 | 561 | ||
1522 | 520 | signals_.Add<void, BamfMatcher*, BamfApplication*, BamfApplication*> (matcher_, "active-application-changed", | 562 | signals_.Add<void, BamfMatcher*, BamfApplication*, BamfApplication*> (matcher_, "active-application-changed", |
1523 | 521 | [this](BamfMatcher*, BamfApplication* /* from */, BamfApplication* to) { | 563 | [this](BamfMatcher*, BamfApplication* /* from */, BamfApplication* to) { |
1535 | 522 | if (to) | 564 | auto const& app = pool::EnsureApplication(*this, reinterpret_cast<BamfView*>(to)); |
1536 | 523 | { | 565 | this->active_application_changed.emit(app); |
1526 | 524 | // Ownership is not passed on signals | ||
1527 | 525 | glib::Object<BamfApplication> bamf_app(to, glib::AddRef()); | ||
1528 | 526 | auto app = std::make_shared<Application>(*this, bamf_app); | ||
1529 | 527 | this->active_application_changed.emit(app); | ||
1530 | 528 | } | ||
1531 | 529 | else | ||
1532 | 530 | { | ||
1533 | 531 | this->active_application_changed.emit(nullptr); | ||
1534 | 532 | } | ||
1537 | 533 | }); | 566 | }); |
1538 | 534 | } | 567 | } |
1539 | 535 | 568 | ||
1540 | @@ -546,81 +579,79 @@ | |||
1541 | 546 | { | 579 | { |
1542 | 547 | auto *app_ptr = bamf_matcher_get_application_for_xid(matcher_, xid); | 580 | auto *app_ptr = bamf_matcher_get_application_for_xid(matcher_, xid); |
1543 | 548 | 581 | ||
1549 | 549 | if (BAMF_IS_APPLICATION(app_ptr)) | 582 | if (ApplicationPtr const& app = pool::EnsureApplication(*this, reinterpret_cast<BamfView*>(app_ptr))) |
1550 | 550 | { | 583 | return app; |
1546 | 551 | glib::Object<BamfApplication> app(app_ptr, glib::AddRef()); | ||
1547 | 552 | return std::make_shared<Application>(*this, app); | ||
1548 | 553 | } | ||
1551 | 554 | } | 584 | } |
1552 | 555 | 585 | ||
1553 | 556 | return GetApplicationForDesktopFile(DesktopUtilities::GetDesktopPathById("compiz.desktop")); | 586 | return GetApplicationForDesktopFile(DesktopUtilities::GetDesktopPathById("compiz.desktop")); |
1554 | 557 | } | 587 | } |
1555 | 558 | 588 | ||
1556 | 589 | ApplicationPtr Manager::GetActiveApplication() const | ||
1557 | 590 | { | ||
1558 | 591 | auto *app_ptr = bamf_matcher_get_active_application(matcher_); | ||
1559 | 592 | return pool::EnsureApplication(*this, reinterpret_cast<BamfView*>(app_ptr)); | ||
1560 | 593 | } | ||
1561 | 594 | |||
1562 | 559 | ApplicationWindowPtr Manager::GetActiveWindow() const | 595 | ApplicationWindowPtr Manager::GetActiveWindow() const |
1563 | 560 | { | 596 | { |
1569 | 561 | // No transfer of ownership for bamf_matcher_get_active_window. | 597 | if (BamfWindow* active_win = bamf_matcher_get_active_window(matcher_)) |
1570 | 562 | BamfWindow* active_win = bamf_matcher_get_active_window(matcher_); | 598 | { |
1571 | 563 | 599 | if (bamf_window_get_window_type(active_win) != BAMF_WINDOW_DOCK) | |
1572 | 564 | if (!active_win) | 600 | return pool::EnsureWindow(*this, reinterpret_cast<BamfView*>(active_win)); |
1573 | 565 | return nullptr; | 601 | } |
1574 | 566 | 602 | ||
1575 | 567 | // If the active window is a dock type, then we want the first visible, non-dock type. | 603 | // If the active window is a dock type, then we want the first visible, non-dock type. |
1577 | 568 | if (bamf_window_get_window_type(active_win) == BAMF_WINDOW_DOCK) | 604 | LOG_DEBUG(logger) << "Is a dock, looking at the window stack."; |
1578 | 605 | |||
1579 | 606 | auto const& wins = GetWindowsForMonitor(); | ||
1580 | 607 | WindowManager& wm = WindowManager::Default(); | ||
1581 | 608 | |||
1582 | 609 | for (auto it = wins.rbegin(); it != wins.rend(); ++it) | ||
1583 | 569 | { | 610 | { |
1591 | 570 | LOG_DEBUG(logger) << "Is a dock, looking at the window stack."; | 611 | auto const& win = *it; |
1592 | 571 | 612 | auto xid = win->window_id(); | |
1593 | 572 | std::shared_ptr<GList> windows(bamf_matcher_get_window_stack_for_monitor(matcher_, -1), g_list_free); | 613 | |
1594 | 573 | WindowManager& wm = WindowManager::Default(); | 614 | if (win->visible() && |
1595 | 574 | active_win = nullptr; | 615 | win->type() != WindowType::DOCK && |
1596 | 575 | 616 | wm.IsWindowOnCurrentDesktop(xid) && | |
1597 | 576 | for (GList *l = windows.get(); l; l = l->next) | 617 | wm.IsWindowVisible(xid)) |
1598 | 577 | { | 618 | { |
1616 | 578 | if (!BAMF_IS_WINDOW(l->data)) | 619 | return win; |
1600 | 579 | { | ||
1601 | 580 | LOG_DEBUG(logger) << "Window stack returned something not a window, WTF?"; | ||
1602 | 581 | continue; | ||
1603 | 582 | } | ||
1604 | 583 | |||
1605 | 584 | auto win = static_cast<BamfWindow*>(l->data); | ||
1606 | 585 | auto view = static_cast<BamfView*>(l->data); | ||
1607 | 586 | auto xid = bamf_window_get_xid(win); | ||
1608 | 587 | |||
1609 | 588 | if (bamf_view_is_user_visible(view) && | ||
1610 | 589 | bamf_window_get_window_type(win) != BAMF_WINDOW_DOCK && | ||
1611 | 590 | wm.IsWindowOnCurrentDesktop(xid) && | ||
1612 | 591 | wm.IsWindowVisible(xid)) | ||
1613 | 592 | { | ||
1614 | 593 | active_win = win; | ||
1615 | 594 | } | ||
1617 | 595 | } | 620 | } |
1618 | 596 | } | 621 | } |
1619 | 597 | 622 | ||
1620 | 598 | if (active_win) | ||
1621 | 599 | { | ||
1622 | 600 | glib::Object<BamfWindow> win(active_win, glib::AddRef()); | ||
1623 | 601 | return std::make_shared<AppWindow>(*this, win); | ||
1624 | 602 | } | ||
1625 | 603 | |||
1626 | 604 | return nullptr; | 623 | return nullptr; |
1627 | 605 | } | 624 | } |
1628 | 606 | 625 | ||
1629 | 607 | ApplicationPtr Manager::GetApplicationForDesktopFile(std::string const& desktop_file) const | 626 | ApplicationPtr Manager::GetApplicationForDesktopFile(std::string const& desktop_file) const |
1630 | 608 | { | 627 | { |
1638 | 609 | glib::Object<BamfApplication> app(bamf_matcher_get_application_for_desktop_file( | 628 | auto* app = bamf_matcher_get_application_for_desktop_file(matcher_, desktop_file.c_str(), TRUE); |
1639 | 610 | matcher_, desktop_file.c_str(), TRUE), glib::AddRef()); | 629 | return pool::EnsureApplication(*this, reinterpret_cast<BamfView*>(app)); |
1633 | 611 | |||
1634 | 612 | if (app) | ||
1635 | 613 | return std::make_shared<Application>(*this, app); | ||
1636 | 614 | |||
1637 | 615 | return nullptr; | ||
1640 | 616 | } | 630 | } |
1641 | 617 | 631 | ||
1642 | 618 | ApplicationPtr Manager::GetApplicationForWindow(Window xid) const | 632 | ApplicationPtr Manager::GetApplicationForWindow(Window xid) const |
1643 | 619 | { | 633 | { |
1648 | 620 | glib::Object<BamfApplication> app(bamf_matcher_get_application_for_xid(matcher_, xid), | 634 | auto* app = bamf_matcher_get_application_for_xid(matcher_, xid); |
1649 | 621 | glib::AddRef()); | 635 | return pool::EnsureApplication(*this, reinterpret_cast<BamfView*>(app)); |
1650 | 622 | if (app) | 636 | } |
1651 | 623 | return std::make_shared<Application>(*this, app); | 637 | |
1652 | 638 | ApplicationWindowPtr Manager::GetWindowForId(Window xid) const | ||
1653 | 639 | { | ||
1654 | 640 | if (xid == 0) | ||
1655 | 641 | return nullptr; | ||
1656 | 642 | |||
1657 | 643 | std::shared_ptr<GList> windows(bamf_matcher_get_windows(matcher_), g_list_free); | ||
1658 | 644 | |||
1659 | 645 | for (GList* l = windows.get(); l; l = l->next) | ||
1660 | 646 | { | ||
1661 | 647 | if (!BAMF_IS_WINDOW(l->data)) | ||
1662 | 648 | continue; | ||
1663 | 649 | |||
1664 | 650 | auto win = static_cast<BamfWindow*>(l->data); | ||
1665 | 651 | |||
1666 | 652 | if (bamf_window_get_xid(win) == xid) | ||
1667 | 653 | return pool::EnsureWindow(*this, static_cast<BamfView*>(l->data)); | ||
1668 | 654 | } | ||
1669 | 624 | 655 | ||
1670 | 625 | return nullptr; | 656 | return nullptr; |
1671 | 626 | } | 657 | } |
1672 | @@ -638,26 +669,65 @@ | |||
1673 | 638 | continue; | 669 | continue; |
1674 | 639 | } | 670 | } |
1675 | 640 | 671 | ||
1680 | 641 | glib::Object<BamfApplication> bamf_app(static_cast<BamfApplication*>(l->data), glib::AddRef()); | 672 | result.push_back(pool::EnsureApplication(*this, static_cast<BamfView*>(l->data))); |
1677 | 642 | auto app = std::make_shared<Application>(*this, bamf_app); | ||
1678 | 643 | result.push_back(app); | ||
1679 | 644 | LOG_DEBUG(logger) << "Running app: " << app->title(); | ||
1681 | 645 | } | 673 | } |
1682 | 646 | return result; | 674 | return result; |
1683 | 647 | } | 675 | } |
1684 | 648 | 676 | ||
1685 | 677 | WindowList Manager::GetWindowsForMonitor(int monitor) const | ||
1686 | 678 | { | ||
1687 | 679 | WindowList wins; | ||
1688 | 680 | std::shared_ptr<GList> windows(bamf_matcher_get_window_stack_for_monitor(matcher_, monitor), g_list_free); | ||
1689 | 681 | |||
1690 | 682 | for (GList *l = windows.get(); l; l = l->next) | ||
1691 | 683 | { | ||
1692 | 684 | if (!BAMF_IS_WINDOW(l->data)) | ||
1693 | 685 | { | ||
1694 | 686 | LOG_DEBUG(logger) << "Window stack returned something not a window, WTF?"; | ||
1695 | 687 | continue; | ||
1696 | 688 | } | ||
1697 | 689 | |||
1698 | 690 | auto bamf_win = static_cast<BamfWindow*>(l->data); | ||
1699 | 691 | |||
1700 | 692 | if (bamf_window_get_window_type(bamf_win) != BAMF_WINDOW_DOCK) | ||
1701 | 693 | wins.push_back(pool::EnsureWindow(*this, static_cast<BamfView*>(l->data))); | ||
1702 | 694 | } | ||
1703 | 695 | |||
1704 | 696 | return wins; | ||
1705 | 697 | } | ||
1706 | 649 | 698 | ||
1707 | 650 | void Manager::OnViewOpened(BamfMatcher* matcher, BamfView* view) | 699 | void Manager::OnViewOpened(BamfMatcher* matcher, BamfView* view) |
1708 | 651 | { | 700 | { |
1709 | 652 | LOG_TRACE_BLOCK(logger); | 701 | LOG_TRACE_BLOCK(logger); |
1718 | 653 | if (!BAMF_IS_APPLICATION(view)) | 702 | if (BAMF_IS_APPLICATION(view)) |
1719 | 654 | { | 703 | { |
1720 | 655 | LOG_DEBUG(logger) << "view is not an app"; | 704 | if (ApplicationPtr const& app = pool::EnsureApplication(*this, view)) |
1721 | 656 | return; | 705 | application_started.emit(app); |
1722 | 657 | } | 706 | } |
1723 | 658 | 707 | else if (BAMF_IS_WINDOW(view)) | |
1724 | 659 | glib::Object<BamfView> app(view, glib::AddRef()); | 708 | { |
1725 | 660 | application_started.emit(std::make_shared<Application>(*this, app)); | 709 | if (ApplicationWindowPtr const& win = pool::EnsureWindow(*this, view)) |
1726 | 710 | window_opened.emit(win); | ||
1727 | 711 | } | ||
1728 | 712 | } | ||
1729 | 713 | |||
1730 | 714 | void Manager::OnViewClosed(BamfMatcher* matcher, BamfView* view) | ||
1731 | 715 | { | ||
1732 | 716 | LOG_TRACE_BLOCK(logger); | ||
1733 | 717 | if (BAMF_IS_APPLICATION(view)) | ||
1734 | 718 | { | ||
1735 | 719 | if (ApplicationPtr const& app = pool::EnsureApplication(*this, view)) | ||
1736 | 720 | application_stopped.emit(app); | ||
1737 | 721 | |||
1738 | 722 | pool::apps_.erase(view); | ||
1739 | 723 | } | ||
1740 | 724 | else if (BAMF_IS_WINDOW(view)) | ||
1741 | 725 | { | ||
1742 | 726 | if (ApplicationWindowPtr const& win = pool::EnsureWindow(*this, view)) | ||
1743 | 727 | window_closed.emit(win); | ||
1744 | 728 | |||
1745 | 729 | pool::wins_.erase(view); | ||
1746 | 730 | } | ||
1747 | 661 | } | 731 | } |
1748 | 662 | 732 | ||
1749 | 663 | } // namespace bamf | 733 | } // namespace bamf |
1750 | 664 | 734 | ||
1751 | === modified file 'unity-shared/BamfApplicationManager.h' | |||
1752 | --- unity-shared/BamfApplicationManager.h 2013-09-04 19:38:19 +0000 | |||
1753 | +++ unity-shared/BamfApplicationManager.h 2015-05-22 16:04:25 +0000 | |||
1754 | @@ -20,6 +20,7 @@ | |||
1755 | 20 | #ifndef UNITYSHARED_BAMF_APPLICATION_MANAGER_H | 20 | #ifndef UNITYSHARED_BAMF_APPLICATION_MANAGER_H |
1756 | 21 | #define UNITYSHARED_BAMF_APPLICATION_MANAGER_H | 21 | #define UNITYSHARED_BAMF_APPLICATION_MANAGER_H |
1757 | 22 | 22 | ||
1758 | 23 | #include <unordered_map> | ||
1759 | 23 | #include <libbamf/libbamf.h> | 24 | #include <libbamf/libbamf.h> |
1760 | 24 | #include <UnityCore/GLibWrapper.h> | 25 | #include <UnityCore/GLibWrapper.h> |
1761 | 25 | #include <UnityCore/GLibSignal.h> | 26 | #include <UnityCore/GLibSignal.h> |
1762 | @@ -39,7 +40,6 @@ | |||
1763 | 39 | 40 | ||
1764 | 40 | std::string GetTitle() const; | 41 | std::string GetTitle() const; |
1765 | 41 | std::string GetIcon() const; | 42 | std::string GetIcon() const; |
1766 | 42 | std::string type() const; | ||
1767 | 43 | 43 | ||
1768 | 44 | bool GetVisible() const; | 44 | bool GetVisible() const; |
1769 | 45 | bool GetActive() const; | 45 | bool GetActive() const; |
1770 | @@ -59,11 +59,15 @@ | |||
1771 | 59 | glib::Object<BamfView> const& window); | 59 | glib::Object<BamfView> const& window); |
1772 | 60 | 60 | ||
1773 | 61 | public: | 61 | public: |
1779 | 62 | virtual std::string type() const; // 'window' or 'tab' | 62 | bool Focus() const override; |
1780 | 63 | 63 | ||
1781 | 64 | virtual bool Focus() const; | 64 | bool operator==(unity::ApplicationWindow const& other) const override |
1782 | 65 | 65 | { | |
1783 | 66 | private: | 66 | return static_cast<WindowBase const*>(this)->bamf_view_ == static_cast<WindowBase const&>(other).bamf_view_; |
1784 | 67 | } | ||
1785 | 68 | bool operator!=(unity::ApplicationWindow const& other) const override { return !(operator==(other)); } | ||
1786 | 69 | |||
1787 | 70 | protected: | ||
1788 | 67 | glib::SignalManager signals_; | 71 | glib::SignalManager signals_; |
1789 | 68 | }; | 72 | }; |
1790 | 69 | 73 | ||
1791 | @@ -76,10 +80,12 @@ | |||
1792 | 76 | AppWindow(ApplicationManager const& manager, | 80 | AppWindow(ApplicationManager const& manager, |
1793 | 77 | glib::Object<BamfView> const& window); | 81 | glib::Object<BamfView> const& window); |
1794 | 78 | 82 | ||
1799 | 79 | virtual Window window_id() const; | 83 | WindowType type() const override; |
1800 | 80 | virtual int monitor() const; | 84 | Window window_id() const override; |
1801 | 81 | virtual ApplicationPtr application() const; | 85 | int monitor() const override; |
1802 | 82 | virtual void Quit() const; | 86 | ApplicationPtr application() const override; |
1803 | 87 | void Quit() const override; | ||
1804 | 88 | bool GetMaximized() const; | ||
1805 | 83 | 89 | ||
1806 | 84 | private: | 90 | private: |
1807 | 85 | glib::Object<BamfWindow> bamf_window_; | 91 | glib::Object<BamfWindow> bamf_window_; |
1808 | @@ -93,11 +99,12 @@ | |||
1809 | 93 | Tab(ApplicationManager const& manager, | 99 | Tab(ApplicationManager const& manager, |
1810 | 94 | glib::Object<BamfView> const& tab); | 100 | glib::Object<BamfView> const& tab); |
1811 | 95 | 101 | ||
1817 | 96 | virtual Window window_id() const; | 102 | WindowType type() const override; |
1818 | 97 | virtual int monitor() const; | 103 | Window window_id() const override; |
1819 | 98 | virtual ApplicationPtr application() const; | 104 | int monitor() const override; |
1820 | 99 | virtual bool Focus() const; | 105 | ApplicationPtr application() const override; |
1821 | 100 | virtual void Quit() const; | 106 | bool Focus() const override; |
1822 | 107 | void Quit() const override; | ||
1823 | 101 | 108 | ||
1824 | 102 | private: | 109 | private: |
1825 | 103 | glib::Object<BamfTab> bamf_tab_; | 110 | glib::Object<BamfTab> bamf_tab_; |
1826 | @@ -112,7 +119,7 @@ | |||
1827 | 112 | Application(ApplicationManager const& manager, | 119 | Application(ApplicationManager const& manager, |
1828 | 113 | glib::Object<BamfView> const& app); | 120 | glib::Object<BamfView> const& app); |
1829 | 114 | 121 | ||
1831 | 115 | virtual std::string type() const; | 122 | virtual AppType type() const; |
1832 | 116 | 123 | ||
1833 | 117 | virtual WindowList GetWindows() const; | 124 | virtual WindowList GetWindows() const; |
1834 | 118 | virtual bool OwnsWindow(Window window_id) const; | 125 | virtual bool OwnsWindow(Window window_id) const; |
1835 | @@ -128,9 +135,13 @@ | |||
1836 | 128 | 135 | ||
1837 | 129 | virtual std::string repr() const; | 136 | virtual std::string repr() const; |
1838 | 130 | 137 | ||
1839 | 138 | bool operator==(unity::Application const& other) const override | ||
1840 | 139 | { | ||
1841 | 140 | return static_cast<Application const*>(this)->bamf_app_ == static_cast<Application const&>(other).bamf_app_; | ||
1842 | 141 | } | ||
1843 | 142 | bool operator!=(unity::Application const& other) const override { return !(operator==(other)); } | ||
1844 | 143 | |||
1845 | 131 | private: // Property getters and setters | 144 | private: // Property getters and setters |
1846 | 132 | void HookUpEvents(); | ||
1847 | 133 | |||
1848 | 134 | std::string GetDesktopFile() const; | 145 | std::string GetDesktopFile() const; |
1849 | 135 | 146 | ||
1850 | 136 | bool GetSeen() const; | 147 | bool GetSeen() const; |
1851 | @@ -152,13 +163,20 @@ | |||
1852 | 152 | ~Manager(); | 163 | ~Manager(); |
1853 | 153 | 164 | ||
1854 | 154 | ApplicationPtr GetUnityApplication() const override; | 165 | ApplicationPtr GetUnityApplication() const override; |
1855 | 166 | ApplicationPtr GetActiveApplication() const override; | ||
1856 | 155 | ApplicationWindowPtr GetActiveWindow() const override; | 167 | ApplicationWindowPtr GetActiveWindow() const override; |
1857 | 156 | ApplicationPtr GetApplicationForDesktopFile(std::string const& desktop_file) const override; | 168 | ApplicationPtr GetApplicationForDesktopFile(std::string const& desktop_file) const override; |
1858 | 157 | ApplicationList GetRunningApplications() const override; | 169 | ApplicationList GetRunningApplications() const override; |
1859 | 170 | WindowList GetWindowsForMonitor(int monitor = -1) const override; | ||
1860 | 158 | ApplicationPtr GetApplicationForWindow(Window xid) const override; | 171 | ApplicationPtr GetApplicationForWindow(Window xid) const override; |
1861 | 172 | ApplicationWindowPtr GetWindowForId(Window xid) const override; | ||
1862 | 173 | |||
1863 | 174 | ApplicationPtr EnsureApplication(BamfView*) const; | ||
1864 | 175 | ApplicationWindowPtr EnsureWindow(BamfView*) const; | ||
1865 | 159 | 176 | ||
1866 | 160 | private: | 177 | private: |
1867 | 161 | void OnViewOpened(BamfMatcher* matcher, BamfView* view); | 178 | void OnViewOpened(BamfMatcher* matcher, BamfView* view); |
1868 | 179 | void OnViewClosed(BamfMatcher* matcher, BamfView* view); | ||
1869 | 162 | 180 | ||
1870 | 163 | private: | 181 | private: |
1871 | 164 | glib::Object<BamfMatcher> matcher_; | 182 | glib::Object<BamfMatcher> matcher_; |
1872 | 165 | 183 | ||
1873 | === modified file 'unity-shared/StandaloneAppManager.cpp' | |||
1874 | --- unity-shared/StandaloneAppManager.cpp 2014-07-30 00:49:35 +0000 | |||
1875 | +++ unity-shared/StandaloneAppManager.cpp 2015-05-22 16:04:25 +0000 | |||
1876 | @@ -33,6 +33,54 @@ | |||
1877 | 33 | 33 | ||
1878 | 34 | GMainLoop *loop; | 34 | GMainLoop *loop; |
1879 | 35 | 35 | ||
1880 | 36 | std::ostream& operator<<(std::ostream &os, AppType at) | ||
1881 | 37 | { | ||
1882 | 38 | switch (at) | ||
1883 | 39 | { | ||
1884 | 40 | case AppType::NORMAL: | ||
1885 | 41 | return os << "NORMAL"; | ||
1886 | 42 | case AppType::WEBAPP: | ||
1887 | 43 | return os << "WEBAPP"; | ||
1888 | 44 | case AppType::MOCK: | ||
1889 | 45 | return os << "MOCK"; | ||
1890 | 46 | case AppType::UNKNOWN: | ||
1891 | 47 | return os << "UNKNOWN"; | ||
1892 | 48 | } | ||
1893 | 49 | |||
1894 | 50 | return os; | ||
1895 | 51 | } | ||
1896 | 52 | |||
1897 | 53 | std::ostream& operator<<(std::ostream &os, WindowType wt) | ||
1898 | 54 | { | ||
1899 | 55 | switch (wt) | ||
1900 | 56 | { | ||
1901 | 57 | case WindowType::NORMAL: | ||
1902 | 58 | return os << "NORMAL"; | ||
1903 | 59 | case WindowType::DESKTOP: | ||
1904 | 60 | return os << "DESKTOP"; | ||
1905 | 61 | case WindowType::DOCK: | ||
1906 | 62 | return os << "DOCK"; | ||
1907 | 63 | case WindowType::DIALOG: | ||
1908 | 64 | return os << "DIALOG"; | ||
1909 | 65 | case WindowType::TOOLBAR: | ||
1910 | 66 | return os << "TOOLBAR"; | ||
1911 | 67 | case WindowType::MENU: | ||
1912 | 68 | return os << "MENU"; | ||
1913 | 69 | case WindowType::UTILITY: | ||
1914 | 70 | return os << "UTILITY"; | ||
1915 | 71 | case WindowType::SPLASHSCREEN: | ||
1916 | 72 | return os << "SPLASHSCREEN"; | ||
1917 | 73 | case WindowType::TAB: | ||
1918 | 74 | return os << "TAB"; | ||
1919 | 75 | case WindowType::MOCK: | ||
1920 | 76 | return os << "MOCK"; | ||
1921 | 77 | case WindowType::UNKNOWN: | ||
1922 | 78 | return os << "UNKNOWN"; | ||
1923 | 79 | } | ||
1924 | 80 | |||
1925 | 81 | return os; | ||
1926 | 82 | } | ||
1927 | 83 | |||
1928 | 36 | void dump_app(ApplicationPtr const& app, std::string const& prefix = "") | 84 | void dump_app(ApplicationPtr const& app, std::string const& prefix = "") |
1929 | 37 | { | 85 | { |
1930 | 38 | if (app) | 86 | if (app) |
1931 | @@ -55,6 +103,7 @@ | |||
1932 | 55 | std::cout << " Window: " << win->title() | 103 | std::cout << " Window: " << win->title() |
1933 | 56 | << ", window_id: " << win->window_id() | 104 | << ", window_id: " << win->window_id() |
1934 | 57 | << ", monitor: " << win->monitor() | 105 | << ", monitor: " << win->monitor() |
1935 | 106 | << ", maximized: " << win->maximized() | ||
1936 | 58 | << ", type: " << win->type() | 107 | << ", type: " << win->type() |
1937 | 59 | << endl; | 108 | << endl; |
1938 | 60 | } | 109 | } |
1939 | @@ -65,6 +114,8 @@ | |||
1940 | 65 | } | 114 | } |
1941 | 66 | } | 115 | } |
1942 | 67 | 116 | ||
1943 | 117 | std::vector<std::string> names; | ||
1944 | 118 | |||
1945 | 68 | void connect_events(ApplicationPtr const& app) | 119 | void connect_events(ApplicationPtr const& app) |
1946 | 69 | { | 120 | { |
1947 | 70 | if (app->seen()) | 121 | if (app->seen()) |
1948 | @@ -72,42 +123,57 @@ | |||
1949 | 72 | cout << "Already seen " << app->title() << ", skipping event connection.\n"; | 123 | cout << "Already seen " << app->title() << ", skipping event connection.\n"; |
1950 | 73 | return; | 124 | return; |
1951 | 74 | } | 125 | } |
1986 | 75 | std::string app_name = app->title(); | 126 | |
1987 | 76 | app->title.changed.connect([&app_name](std::string const& value) { | 127 | auto idx = names.empty() ? 0 : names.size()-1; |
1988 | 77 | cout << app_name << " changed name to: " << value << endl; | 128 | names.push_back(app->title()); |
1989 | 78 | app_name = value; | 129 | app->title.changed.connect([idx](std::string const& value) { |
1990 | 79 | }); | 130 | cout << names[idx] << " changed name to: " << value << endl; |
1991 | 80 | app->icon.changed.connect([&app_name](std::string const& value) { | 131 | names[idx] = value; |
1992 | 81 | cout << app_name << " icon changed: " << value << endl; | 132 | }); |
1993 | 82 | }); | 133 | app->icon.changed.connect([idx](std::string const& value) { |
1994 | 83 | app->desktop_file.changed.connect([&app_name](std::string const& value) { | 134 | cout << names[idx] << " icon changed: " << value << endl; |
1995 | 84 | cout << app_name << " desktop file changed: " << value << endl; | 135 | }); |
1996 | 85 | }); | 136 | app->desktop_file.changed.connect([idx](std::string const& value) { |
1997 | 86 | app->visible.changed.connect([&app_name](bool value) { | 137 | cout << names[idx] << " desktop file changed: " << value << endl; |
1998 | 87 | cout << app_name << " visibility changed: " << (value ? "yes" : "no") << endl; | 138 | }); |
1999 | 88 | }); | 139 | app->visible.changed.connect([idx](bool value) { |
2000 | 89 | app->running.changed.connect([&app_name](bool value) { | 140 | cout << names[idx] << " visibility changed: " << (value ? "yes" : "no") << endl; |
2001 | 90 | cout << app_name << " running changed: " << (value ? "yes" : "no") << endl; | 141 | }); |
2002 | 91 | }); | 142 | app->running.changed.connect([idx](bool value) { |
2003 | 92 | app->active.changed.connect([&app_name](bool value) { | 143 | cout << names[idx] << " running changed: " << (value ? "yes" : "no") << endl; |
2004 | 93 | cout << app_name << " active changed: " << (value ? "yes" : "no") << endl; | 144 | }); |
2005 | 94 | }); | 145 | app->active.changed.connect([idx](bool value) { |
2006 | 95 | app->urgent.changed.connect([&app_name](bool value) { | 146 | cout << names[idx] << " active changed: " << (value ? "yes" : "no") << endl; |
2007 | 96 | cout << app_name << " urgent changed: " << (value ? "yes" : "no") << endl; | 147 | }); |
2008 | 97 | }); | 148 | app->urgent.changed.connect([idx](bool value) { |
2009 | 98 | app->closed.connect([&app_name]() { | 149 | cout << names[idx] << " urgent changed: " << (value ? "yes" : "no") << endl; |
2010 | 99 | cout << app_name << " closed." << endl; | 150 | }); |
2011 | 100 | }); | 151 | app->closed.connect([idx]() { |
2012 | 101 | app->window_opened.connect([&app_name](ApplicationWindow const& window) { | 152 | cout << names[idx] << " closed." << endl; |
2013 | 102 | cout << "** " << app_name << " window opened: " << window.title() << endl; | 153 | }); |
2014 | 103 | }); | 154 | app->window_opened.connect([idx](ApplicationWindowPtr const& window) { |
2015 | 104 | app->window_closed.connect([&app_name]() { | 155 | cout << "** " << names[idx] << " window opened: " << window->title() << endl; |
2016 | 105 | cout << "** " << app_name << " window closed" << endl; | 156 | }); |
2017 | 106 | }); | 157 | app->window_closed.connect([idx](ApplicationWindowPtr const& window) { |
2018 | 107 | app->window_moved.connect([&app_name](ApplicationWindow const& window) { | 158 | cout << "** " << names[idx] << " window closed: " << window->title() << endl; |
2019 | 108 | cout << "** " << app_name << " window moved: " << window.title() << endl; | 159 | }); |
2020 | 160 | app->window_moved.connect([idx](ApplicationWindowPtr const& window) { | ||
2021 | 161 | cout << "** " << names[idx] << " window moved: " << window->title() << endl; | ||
2022 | 109 | }); | 162 | }); |
2023 | 110 | app->seen = true; | 163 | app->seen = true; |
2024 | 164 | |||
2025 | 165 | for (auto win : app->GetWindows()) | ||
2026 | 166 | { | ||
2027 | 167 | win->title.changed.connect([win] (std::string const& t) { | ||
2028 | 168 | std::cout << "Window "<< win->window_id()<< " title changed to "<< t << endl; | ||
2029 | 169 | }); | ||
2030 | 170 | win->maximized.changed.connect([win] (bool m) { | ||
2031 | 171 | std::cout << "Window "<< win->window_id()<< " maximized changed to "<< m << endl; | ||
2032 | 172 | }); | ||
2033 | 173 | win->active.changed.connect([win] (bool a) { | ||
2034 | 174 | std::cout << "Window "<< win->window_id()<< " active changed to "<< a << endl; | ||
2035 | 175 | }); | ||
2036 | 176 | } | ||
2037 | 111 | } | 177 | } |
2038 | 112 | 178 | ||
2039 | 113 | 179 |
FAILED: Continuous integration, rev:3969 jenkins. qa.ubuntu. com/job/ unity-ci/ 1150/ jenkins. qa.ubuntu. com/job/ unity-vivid- amd64-ci/ 37/console jenkins. qa.ubuntu. com/job/ unity-vivid- armhf-ci/ 37/console jenkins. qa.ubuntu. com/job/ unity-vivid- i386-ci/ 37/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- ci/1150/ rebuild
http://