Merge lp:~3v1n0/unity/panel-gradient-scaling into lp:unity
- panel-gradient-scaling
- Merge into trunk
Proposed by
Marco Trevisan (Treviño)
Status: | Superseded |
---|---|
Proposed branch: | lp:~3v1n0/unity/panel-gradient-scaling |
Merge into: | lp:unity |
Diff against target: |
2941 lines (+1320/-450) 59 files modified
CMakeLists.txt (+11/-1) debian/control (+22/-20) debian/libunity-core-6.0-9.install (+3/-2) debian/unity-services.install (+4/-1) debian/unity-services.links (+13/-0) debian/unity.install (+3/-0) decorations/DecoratedWindow.cpp (+2/-9) decorations/DecorationsMenuLayout.cpp (+35/-37) decorations/DecorationsMenuLayout.h (+3/-2) decorations/DecorationsPriv.h (+0/-1) launcher/EdgeBarrierController.cpp (+32/-115) launcher/EdgeBarrierControllerPrivate.h (+1/-6) lockscreen/KylinLockScreenShield.cpp (+1/-1) lockscreen/LockScreenBaseShield.cpp (+0/-2) lockscreen/LockScreenBaseShield.h (+3/-4) lockscreen/LockScreenController.cpp (+7/-3) lockscreen/LockScreenController.h (+4/-2) lockscreen/LockScreenPanel.cpp (+25/-56) lockscreen/LockScreenPanel.h (+5/-9) lockscreen/LockScreenShield.cpp (+7/-6) lockscreen/LockScreenShield.h (+4/-3) lockscreen/LockScreenShieldFactory.cpp (+2/-2) lockscreen/LockScreenShieldFactory.h (+3/-3) panel/PanelIndicatorEntryView.cpp (+10/-0) panel/PanelMenuView.cpp (+1/-7) panel/PanelMenuView.h (+0/-2) panel/PanelView.cpp (+6/-118) panel/PanelView.h (+3/-12) plugins/unityshell/src/unityshell.h (+2/-0) services/CMakeLists.txt (+31/-0) services/unity-panel-service-lockscreen.override (+1/-0) services/unity-panel-service-lockscreen.service.in (+7/-0) services/unity-panel-service.override (+1/-0) services/unity-panel-service.service.in (+9/-0) services/unity-screen-locked.target (+4/-0) tests/CMakeLists.txt (+1/-0) tests/test_edge_barrier_controller.cpp (+2/-0) tests/test_lockscreen_controller.cpp (+7/-4) tests/test_panel_controller.cpp (+2/-0) tests/test_panel_view.cpp (+2/-0) tests/test_systemd_wrapper.cpp (+111/-0) tools/CMakeLists.txt (+3/-0) tools/unity-compiz-profile-select.in (+25/-0) unity-shared/CMakeLists.txt (+2/-0) unity-shared/InputMonitor.cpp (+414/-0) unity-shared/InputMonitor.h (+67/-0) unity-shared/MenuManager.cpp (+162/-1) unity-shared/MenuManager.h (+4/-0) unity-shared/SigcSlotHash.h (+70/-0) unity-shared/StandaloneWindowManager.cpp (+3/-0) unity-shared/StandaloneWindowManager.h (+1/-0) unity-shared/SystemdWrapper.cpp (+103/-0) unity-shared/SystemdWrapper.h (+55/-0) unity-shared/WindowManager.h (+1/-0) unity-shared/XWindowManager.cpp (+6/-0) unity-shared/XWindowManager.h (+1/-0) unity7.conf.in (+1/-21) unity7.override (+1/-0) unity7.service.in (+11/-0) |
To merge this branch: | bzr merge lp:~3v1n0/unity/panel-gradient-scaling |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Unity Team | Pending | ||
Review via email: mp+304384@code.launchpad.net |
This proposal has been superseded by a proposal from 2016-08-30.
Commit message
PanelView: scale gradient refinement properly
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2016-07-21 13:01:59 +0000 | |||
3 | +++ CMakeLists.txt 2016-08-30 14:38:39 +0000 | |||
4 | @@ -429,5 +429,15 @@ | |||
5 | 429 | # | 429 | # |
6 | 430 | # Upstart | 430 | # Upstart |
7 | 431 | # | 431 | # |
9 | 432 | configure_file(unity7.conf.in ${CMAKE_CURRENT_BINARY_DIR}/unity7.conf) | 432 | |
10 | 433 | configure_file(unity7.conf.in ${CMAKE_CURRENT_BINARY_DIR}/unity7.conf @ONLY) | ||
11 | 433 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity7.conf DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/sessions) | 434 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity7.conf DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/sessions) |
12 | 435 | |||
13 | 436 | # | ||
14 | 437 | # Systemd | ||
15 | 438 | # | ||
16 | 439 | |||
17 | 440 | configure_file(unity7.service.in ${CMAKE_CURRENT_BINARY_DIR}/unity7.service @ONLY) | ||
18 | 441 | pkg_get_variable(SYSTEMD_USER_DIR systemd systemduserunitdir) | ||
19 | 442 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity7.service DESTINATION ${SYSTEMD_USER_DIR}) | ||
20 | 443 | install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/unity7.override DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/systemd-session/upstart) | ||
21 | 434 | 444 | ||
22 | === modified file 'debian/control' | |||
23 | --- debian/control 2016-07-25 18:20:16 +0000 | |||
24 | +++ debian/control 2016-08-30 14:38:39 +0000 | |||
25 | @@ -53,6 +53,7 @@ | |||
26 | 53 | python3 (>= 3.4), | 53 | python3 (>= 3.4), |
27 | 54 | python-setuptools, | 54 | python-setuptools, |
28 | 55 | quilt, | 55 | quilt, |
29 | 56 | systemd, | ||
30 | 56 | xserver-xorg-video-dummy, | 57 | xserver-xorg-video-dummy, |
31 | 57 | xsltproc, | 58 | xsltproc, |
32 | 58 | Standards-Version: 3.9.5 | 59 | Standards-Version: 3.9.5 |
33 | @@ -81,12 +82,31 @@ | |||
34 | 81 | libxfixes3 (>= 1:5.0.1-1), | 82 | libxfixes3 (>= 1:5.0.1-1), |
35 | 82 | libxi6 (>= 2:1.7.1.901), | 83 | libxi6 (>= 2:1.7.1.901), |
36 | 83 | unity-scope-home, | 84 | unity-scope-home, |
37 | 84 | Provides: indicator-renderer | ||
38 | 85 | Recommends: unity-control-center, | 85 | Recommends: unity-control-center, |
39 | 86 | ${unity-default-masterscopes} | 86 | ${unity-default-masterscopes} |
40 | 87 | nautilus, | 87 | nautilus, |
41 | 88 | gnome-disk-utility, | 88 | gnome-disk-utility, |
43 | 89 | indicator-appmenu (>= 15.02.0), | 89 | hud, |
44 | 90 | session-shortcuts, | ||
45 | 91 | Breaks: unity-lens-applications (<< 5.12.0-0ubuntu2), | ||
46 | 92 | unity-lens-files (<< 5.10.0-0ubuntu2), | ||
47 | 93 | unity-lens-music (<< 6.0.0), | ||
48 | 94 | unity-lens-video (<< 0.3.6-0ubuntu2), | ||
49 | 95 | Description: Interface designed for efficiency of space and interaction. | ||
50 | 96 | Unity is a desktop experience that sings. Designed by Canonical and the Ayatana | ||
51 | 97 | community, Unity is all about the combination of familiarity and the future. We | ||
52 | 98 | bring together visual design, analysis of user experience testing, modern | ||
53 | 99 | graphics technologies and a deep understanding of the free software landscape | ||
54 | 100 | to produce what we hope will be the lightest, most elegant and most delightful | ||
55 | 101 | way to use your PC. | ||
56 | 102 | |||
57 | 103 | Package: unity-services | ||
58 | 104 | Architecture: any | ||
59 | 105 | Depends: ${shlibs:Depends}, | ||
60 | 106 | ${misc:Depends}, | ||
61 | 107 | indicator-common, | ||
62 | 108 | Provides: indicator-renderer | ||
63 | 109 | Recommends: indicator-appmenu (>= 15.02.0), | ||
64 | 90 | indicator-application, | 110 | indicator-application, |
65 | 91 | indicator-sound, | 111 | indicator-sound, |
66 | 92 | indicator-bluetooth, | 112 | indicator-bluetooth, |
67 | @@ -96,24 +116,6 @@ | |||
68 | 96 | indicator-printers, | 116 | indicator-printers, |
69 | 97 | indicator-power, | 117 | indicator-power, |
70 | 98 | indicator-session, | 118 | indicator-session, |
71 | 99 | hud, | ||
72 | 100 | session-shortcuts, | ||
73 | 101 | Breaks: unity-lens-applications (<< 5.12.0-0ubuntu2), | ||
74 | 102 | unity-lens-files (<< 5.10.0-0ubuntu2), | ||
75 | 103 | unity-lens-music (<< 6.0.0), | ||
76 | 104 | unity-lens-video (<< 0.3.6-0ubuntu2), | ||
77 | 105 | Description: Interface designed for efficiency of space and interaction. | ||
78 | 106 | Unity is a desktop experience that sings. Designed by Canonical and the Ayatana | ||
79 | 107 | community, Unity is all about the combination of familiarity and the future. We | ||
80 | 108 | bring together visual design, analysis of user experience testing, modern | ||
81 | 109 | graphics technologies and a deep understanding of the free software landscape | ||
82 | 110 | to produce what we hope will be the lightest, most elegant and most delightful | ||
83 | 111 | way to use your PC. | ||
84 | 112 | |||
85 | 113 | Package: unity-services | ||
86 | 114 | Architecture: any | ||
87 | 115 | Depends: ${shlibs:Depends}, | ||
88 | 116 | ${misc:Depends}, | ||
89 | 117 | Description: Services for the Unity interface | 119 | Description: Services for the Unity interface |
90 | 118 | Unity is a desktop experience that sings. Designed by Canonical and the Ayatana | 120 | Unity is a desktop experience that sings. Designed by Canonical and the Ayatana |
91 | 119 | community, Unity is all about the combination of familiarity and the future. We | 121 | community, Unity is all about the combination of familiarity and the future. We |
92 | 120 | 122 | ||
93 | === modified file 'debian/libunity-core-6.0-9.install' | |||
94 | --- debian/libunity-core-6.0-9.install 2016-07-26 16:45:34 +0000 | |||
95 | +++ debian/libunity-core-6.0-9.install 2016-08-30 14:38:39 +0000 | |||
96 | @@ -2,8 +2,9 @@ | |||
97 | 2 | usr/lib/*/unity/*.py | 2 | usr/lib/*/unity/*.py |
98 | 3 | usr/share/ccsm | 3 | usr/share/ccsm |
99 | 4 | usr/share/gnome-control-center/ | 4 | usr/share/gnome-control-center/ |
102 | 5 | usr/share/unity | 5 | usr/share/unity/icons |
103 | 6 | usr/share/upstart/sessions/unity7.conf | 6 | usr/share/unity/themes |
104 | 7 | debian/unity-crashdb.conf etc/apport/crashdb.conf.d/ | 7 | debian/unity-crashdb.conf etc/apport/crashdb.conf.d/ |
105 | 8 | debian/source_unity.py usr/share/apport/package-hooks | 8 | debian/source_unity.py usr/share/apport/package-hooks |
106 | 9 | tools/convert-files/* usr/lib/compiz/migration/ | 9 | tools/convert-files/* usr/lib/compiz/migration/ |
107 | 10 | usr/share/upstart/sessions/unity7.conf | ||
108 | 10 | 11 | ||
109 | === modified file 'debian/unity-services.install' | |||
110 | --- debian/unity-services.install 2016-07-26 13:58:14 +0000 | |||
111 | +++ debian/unity-services.install 2016-08-30 14:38:39 +0000 | |||
112 | @@ -1,3 +1,6 @@ | |||
113 | 1 | usr/lib/*/unity/*service | 1 | usr/lib/*/unity/*service |
115 | 2 | usr/share/upstart/sessions/unity-panel-service*.conf | 2 | usr/share/upstart/sessions/unity-panel* |
116 | 3 | usr/share/upstart/systemd-session/upstart/unity-panel* | ||
117 | 4 | usr/lib/systemd/user/unity-panel* | ||
118 | 5 | usr/lib/systemd/user/unity-screen-locked.target | ||
119 | 3 | usr/share/man/*/unity-panel-service.1 | 6 | usr/share/man/*/unity-panel-service.1 |
120 | 4 | 7 | ||
121 | === added file 'debian/unity-services.links' | |||
122 | --- debian/unity-services.links 1970-01-01 00:00:00 +0000 | |||
123 | +++ debian/unity-services.links 2016-08-30 14:38:39 +0000 | |||
124 | @@ -0,0 +1,13 @@ | |||
125 | 1 | /usr/lib/systemd/user/indicator-application.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-application.service | ||
126 | 2 | /usr/lib/systemd/user/indicator-bluetooth.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-bluetooth.service | ||
127 | 3 | /usr/lib/systemd/user/indicator-datetime.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-datetime.service | ||
128 | 4 | /usr/lib/systemd/user/indicator-keyboard.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-keyboard.service | ||
129 | 5 | /usr/lib/systemd/user/indicator-messages.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-messages.service | ||
130 | 6 | /usr/lib/systemd/user/indicator-power.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-power.service | ||
131 | 7 | /usr/lib/systemd/user/indicator-session.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-session.service | ||
132 | 8 | /usr/lib/systemd/user/indicator-sound.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-sound.service | ||
133 | 9 | /usr/lib/systemd/user/indicator-datetime.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-datetime.service | ||
134 | 10 | /usr/lib/systemd/user/indicator-keyboard.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-keyboard.service | ||
135 | 11 | /usr/lib/systemd/user/indicator-power.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-power.service | ||
136 | 12 | /usr/lib/systemd/user/indicator-session.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-session.service | ||
137 | 13 | /usr/lib/systemd/user/indicator-sound.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-sound.service | ||
138 | 0 | 14 | ||
139 | === modified file 'debian/unity.install' | |||
140 | --- debian/unity.install 2016-07-26 16:45:34 +0000 | |||
141 | +++ debian/unity.install 2016-08-30 14:38:39 +0000 | |||
142 | @@ -2,6 +2,9 @@ | |||
143 | 2 | usr/bin | 2 | usr/bin |
144 | 3 | usr/lib/*/compiz/libunity*.so | 3 | usr/lib/*/compiz/libunity*.so |
145 | 4 | usr/lib/*/unity/unity-active-plugins-safety-check | 4 | usr/lib/*/unity/unity-active-plugins-safety-check |
146 | 5 | usr/lib/*/unity/unity-compiz-profile-select | ||
147 | 5 | usr/share/man/*/unity.1 | 6 | usr/share/man/*/unity.1 |
148 | 6 | usr/share/compiz | 7 | usr/share/compiz |
149 | 7 | usr/share/locale | 8 | usr/share/locale |
150 | 9 | usr/lib/systemd/user/unity7.service | ||
151 | 10 | usr/share/upstart/systemd-session/upstart/unity7.override | ||
152 | 8 | 11 | ||
153 | === modified file 'decorations/DecoratedWindow.cpp' | |||
154 | --- decorations/DecoratedWindow.cpp 2016-08-06 16:24:45 +0000 | |||
155 | +++ decorations/DecoratedWindow.cpp 2016-08-30 14:38:39 +0000 | |||
156 | @@ -37,7 +37,6 @@ | |||
157 | 37 | { | 37 | { |
158 | 38 | namespace | 38 | namespace |
159 | 39 | { | 39 | { |
160 | 40 | const std::string MENUS_PANEL_NAME = "WindowLIM"; | ||
161 | 41 | const int SHADOW_BLUR_MARGIN_FACTOR = 2; | 40 | const int SHADOW_BLUR_MARGIN_FACTOR = 2; |
162 | 42 | } | 41 | } |
163 | 43 | 42 | ||
164 | @@ -55,7 +54,6 @@ | |||
165 | 55 | , deco_elements_(cu::DecorationElement::NONE) | 54 | , deco_elements_(cu::DecorationElement::NONE) |
166 | 56 | , last_mwm_decor_(win_->mwmDecor()) | 55 | , last_mwm_decor_(win_->mwmDecor()) |
167 | 57 | , last_actions_(win_->actions()) | 56 | , last_actions_(win_->actions()) |
168 | 58 | , panel_id_(MENUS_PANEL_NAME + std::to_string(win_->id())) | ||
169 | 59 | , cv_(Settings::Instance().em()) | 57 | , cv_(Settings::Instance().em()) |
170 | 60 | { | 58 | { |
171 | 61 | active.changed.connect([this] (bool active) { | 59 | active.changed.connect([this] (bool active) { |
172 | @@ -932,18 +930,13 @@ | |||
173 | 932 | sliding_layout->mouse_owner = grab_edge_->mouse_owner(); | 930 | sliding_layout->mouse_owner = grab_edge_->mouse_owner(); |
174 | 933 | } | 931 | } |
175 | 934 | 932 | ||
176 | 935 | inline std::string const& Window::Impl::GetMenusPanelID() const | ||
177 | 936 | { | ||
178 | 937 | return panel_id_; | ||
179 | 938 | } | ||
180 | 939 | |||
181 | 940 | void Window::Impl::UnsetAppMenu() | 933 | void Window::Impl::UnsetAppMenu() |
182 | 941 | { | 934 | { |
183 | 942 | if (!menus_) | 935 | if (!menus_) |
184 | 943 | return; | 936 | return; |
185 | 944 | 937 | ||
186 | 945 | auto const& indicators = manager_->impl_->menu_manager_->Indicators(); | 938 | auto const& indicators = manager_->impl_->menu_manager_->Indicators(); |
188 | 946 | indicators->SyncGeometries(GetMenusPanelID(), indicator::EntryLocationMap()); | 939 | indicators->SyncGeometries(menus_->MenubarId(), indicator::EntryLocationMap()); |
189 | 947 | sliding_layout_->SetInputItem(nullptr); | 940 | sliding_layout_->SetInputItem(nullptr); |
190 | 948 | grab_mouse_changed_->disconnect(); | 941 | grab_mouse_changed_->disconnect(); |
191 | 949 | } | 942 | } |
192 | @@ -956,7 +949,7 @@ | |||
193 | 956 | auto const& indicators = manager_->impl_->menu_manager_->Indicators(); | 949 | auto const& indicators = manager_->impl_->menu_manager_->Indicators(); |
194 | 957 | indicator::EntryLocationMap map; | 950 | indicator::EntryLocationMap map; |
195 | 958 | menus_->ChildrenGeometries(map); | 951 | menus_->ChildrenGeometries(map); |
197 | 959 | indicators->SyncGeometries(GetMenusPanelID(), map); | 952 | indicators->SyncGeometries(menus_->MenubarId(), map); |
198 | 960 | } | 953 | } |
199 | 961 | 954 | ||
200 | 962 | bool Window::Impl::ActivateMenu(std::string const& entry_id) | 955 | bool Window::Impl::ActivateMenu(std::string const& entry_id) |
201 | 963 | 956 | ||
202 | === modified file 'decorations/DecorationsMenuLayout.cpp' | |||
203 | --- decorations/DecorationsMenuLayout.cpp 2015-02-03 10:04:17 +0000 | |||
204 | +++ decorations/DecorationsMenuLayout.cpp 2016-08-30 14:38:39 +0000 | |||
205 | @@ -25,6 +25,10 @@ | |||
206 | 25 | { | 25 | { |
207 | 26 | namespace decoration | 26 | namespace decoration |
208 | 27 | { | 27 | { |
209 | 28 | namespace | ||
210 | 29 | { | ||
211 | 30 | const std::string MENUS_PANEL_NAME = "WindowLIM"; | ||
212 | 31 | } | ||
213 | 28 | 32 | ||
214 | 29 | using namespace indicator; | 33 | using namespace indicator; |
215 | 30 | 34 | ||
216 | @@ -33,8 +37,8 @@ | |||
217 | 33 | , show_now(false) | 37 | , show_now(false) |
218 | 34 | , menu_manager_(menu) | 38 | , menu_manager_(menu) |
219 | 35 | , win_(win) | 39 | , win_(win) |
220 | 36 | , last_pointer_(-1, -1) | ||
221 | 37 | , dropdown_(std::make_shared<MenuDropdown>(menu_manager_->Indicators(), win)) | 40 | , dropdown_(std::make_shared<MenuDropdown>(menu_manager_->Indicators(), win)) |
222 | 41 | , menubar_id_(MENUS_PANEL_NAME + std::to_string(win_->id())) | ||
223 | 38 | { | 42 | { |
224 | 39 | visible = false; | 43 | visible = false; |
225 | 40 | } | 44 | } |
226 | @@ -91,6 +95,11 @@ | |||
227 | 91 | Relayout(); | 95 | Relayout(); |
228 | 92 | } | 96 | } |
229 | 93 | 97 | ||
230 | 98 | std::string const& MenuLayout::MenubarId() const | ||
231 | 99 | { | ||
232 | 100 | return menubar_id_; | ||
233 | 101 | } | ||
234 | 102 | |||
235 | 94 | bool MenuLayout::ActivateMenu(std::string const& entry_id) | 103 | bool MenuLayout::ActivateMenu(std::string const& entry_id) |
236 | 95 | { | 104 | { |
237 | 96 | MenuEntry::Ptr target; | 105 | MenuEntry::Ptr target; |
238 | @@ -117,16 +126,29 @@ | |||
239 | 117 | if (!activated) | 126 | if (!activated) |
240 | 118 | activated = dropdown_->ActivateChild(target); | 127 | activated = dropdown_->ActivateChild(target); |
241 | 119 | 128 | ||
242 | 120 | if (activated) | ||
243 | 121 | { | ||
244 | 122 | // Since this generally happens on keyboard activation we need to avoid that | ||
245 | 123 | // the mouse position would interfere with this | ||
246 | 124 | last_pointer_.set(pointerX, pointerY); | ||
247 | 125 | } | ||
248 | 126 | |||
249 | 127 | return activated; | 129 | return activated; |
250 | 128 | } | 130 | } |
251 | 129 | 131 | ||
252 | 132 | bool MenuLayout::ActivateMenu(CompPoint const& pos) | ||
253 | 133 | { | ||
254 | 134 | if (!Geometry().contains(pos)) | ||
255 | 135 | return false; | ||
256 | 136 | |||
257 | 137 | for (auto const& item : items_) | ||
258 | 138 | { | ||
259 | 139 | if (!item->visible() || !item->sensitive()) | ||
260 | 140 | continue; | ||
261 | 141 | |||
262 | 142 | if (item->Geometry().contains(pos)) | ||
263 | 143 | { | ||
264 | 144 | std::static_pointer_cast<MenuEntry>(item)->ShowMenu(1); | ||
265 | 145 | return true; | ||
266 | 146 | } | ||
267 | 147 | } | ||
268 | 148 | |||
269 | 149 | return false; | ||
270 | 150 | } | ||
271 | 151 | |||
272 | 130 | void MenuLayout::OnEntryMouseOwnershipChanged(bool owner) | 152 | void MenuLayout::OnEntryMouseOwnershipChanged(bool owner) |
273 | 131 | { | 153 | { |
274 | 132 | mouse_owner = owner; | 154 | mouse_owner = owner; |
275 | @@ -154,39 +176,15 @@ | |||
276 | 154 | { | 176 | { |
277 | 155 | active = actived; | 177 | active = actived; |
278 | 156 | 178 | ||
280 | 157 | if (active && !pointer_tracker_ && items_.size() > 1) | 179 | if (active && items_.size() > 1) |
281 | 158 | { | 180 | { |
309 | 159 | pointer_tracker_.reset(new glib::Timeout(16)); | 181 | menu_manager_->RegisterTracker(menubar_id_, (sigc::track_obj([this] (int x, int y, double speed) { |
310 | 160 | pointer_tracker_->Run([this] { | 182 | ActivateMenu(CompPoint(x, y)); |
311 | 161 | Window win; | 183 | }, *this))); |
285 | 162 | int i, x, y; | ||
286 | 163 | unsigned int ui; | ||
287 | 164 | |||
288 | 165 | XQueryPointer(screen->dpy(), screen->root(), &win, &win, &x, &y, &i, &i, &ui); | ||
289 | 166 | |||
290 | 167 | if (last_pointer_.x() != x || last_pointer_.y() != y) | ||
291 | 168 | { | ||
292 | 169 | last_pointer_.set(x, y); | ||
293 | 170 | |||
294 | 171 | for (auto const& item : items_) | ||
295 | 172 | { | ||
296 | 173 | if (!item->visible() || !item->sensitive()) | ||
297 | 174 | continue; | ||
298 | 175 | |||
299 | 176 | if (item->Geometry().contains(last_pointer_)) | ||
300 | 177 | { | ||
301 | 178 | std::static_pointer_cast<MenuEntry>(item)->ShowMenu(1); | ||
302 | 179 | break; | ||
303 | 180 | } | ||
304 | 181 | } | ||
305 | 182 | } | ||
306 | 183 | |||
307 | 184 | return true; | ||
308 | 185 | }); | ||
312 | 186 | } | 184 | } |
313 | 187 | else if (!active) | 185 | else if (!active) |
314 | 188 | { | 186 | { |
316 | 189 | pointer_tracker_.reset(); | 187 | menu_manager_->UnregisterTracker(menubar_id_); |
317 | 190 | } | 188 | } |
318 | 191 | } | 189 | } |
319 | 192 | 190 | ||
320 | 193 | 191 | ||
321 | === modified file 'decorations/DecorationsMenuLayout.h' | |||
322 | --- decorations/DecorationsMenuLayout.h 2014-02-13 03:01:30 +0000 | |||
323 | +++ decorations/DecorationsMenuLayout.h 2016-08-30 14:38:39 +0000 | |||
324 | @@ -42,7 +42,9 @@ | |||
325 | 42 | 42 | ||
326 | 43 | void Setup(); | 43 | void Setup(); |
327 | 44 | bool ActivateMenu(std::string const& entry_id); | 44 | bool ActivateMenu(std::string const& entry_id); |
328 | 45 | bool ActivateMenu(CompPoint const&); | ||
329 | 45 | void ChildrenGeometries(indicator::EntryLocationMap&) const; | 46 | void ChildrenGeometries(indicator::EntryLocationMap&) const; |
330 | 47 | std::string const& MenubarId() const; | ||
331 | 46 | 48 | ||
332 | 47 | protected: | 49 | protected: |
333 | 48 | void DoRelayout() override; | 50 | void DoRelayout() override; |
334 | @@ -55,10 +57,9 @@ | |||
335 | 55 | 57 | ||
336 | 56 | menu::Manager::Ptr menu_manager_; | 58 | menu::Manager::Ptr menu_manager_; |
337 | 57 | CompWindow* win_; | 59 | CompWindow* win_; |
338 | 58 | CompPoint last_pointer_; | ||
339 | 59 | glib::Source::UniquePtr pointer_tracker_; | ||
340 | 60 | glib::Source::UniquePtr show_now_timeout_; | 60 | glib::Source::UniquePtr show_now_timeout_; |
341 | 61 | std::shared_ptr<MenuDropdown> dropdown_; | 61 | std::shared_ptr<MenuDropdown> dropdown_; |
342 | 62 | std::string menubar_id_; | ||
343 | 62 | }; | 63 | }; |
344 | 63 | 64 | ||
345 | 64 | } // decoration namespace | 65 | } // decoration namespace |
346 | 65 | 66 | ||
347 | === modified file 'decorations/DecorationsPriv.h' | |||
348 | --- decorations/DecorationsPriv.h 2016-08-06 16:24:45 +0000 | |||
349 | +++ decorations/DecorationsPriv.h 2016-08-30 14:38:39 +0000 | |||
350 | @@ -162,7 +162,6 @@ | |||
351 | 162 | connection::Wrapper dpi_changed_; | 162 | connection::Wrapper dpi_changed_; |
352 | 163 | connection::Wrapper grab_mouse_changed_; | 163 | connection::Wrapper grab_mouse_changed_; |
353 | 164 | std::string last_title_; | 164 | std::string last_title_; |
354 | 165 | std::string panel_id_; | ||
355 | 166 | std::vector<cu::SimpleTextureQuad> bg_textures_; | 165 | std::vector<cu::SimpleTextureQuad> bg_textures_; |
356 | 167 | cu::PixmapTexture::Ptr shaped_shadow_pixmap_; | 166 | cu::PixmapTexture::Ptr shaped_shadow_pixmap_; |
357 | 168 | std::shared_ptr<ForceQuitDialog> force_quit_; | 167 | std::shared_ptr<ForceQuitDialog> force_quit_; |
358 | 169 | 168 | ||
359 | === modified file 'launcher/EdgeBarrierController.cpp' | |||
360 | --- launcher/EdgeBarrierController.cpp 2015-12-23 09:29:24 +0000 | |||
361 | +++ launcher/EdgeBarrierController.cpp 2016-08-30 14:38:39 +0000 | |||
362 | @@ -25,6 +25,7 @@ | |||
363 | 25 | #include <NuxCore/Logger.h> | 25 | #include <NuxCore/Logger.h> |
364 | 26 | #include "unity-shared/UnitySettings.h" | 26 | #include "unity-shared/UnitySettings.h" |
365 | 27 | #include "unity-shared/UScreen.h" | 27 | #include "unity-shared/UScreen.h" |
366 | 28 | #include "unity-shared/InputMonitor.h" | ||
367 | 28 | #include "UnityCore/GLibSource.h" | 29 | #include "UnityCore/GLibSource.h" |
368 | 29 | 30 | ||
369 | 30 | namespace unity | 31 | namespace unity |
370 | @@ -36,50 +37,12 @@ | |||
371 | 36 | { | 37 | { |
372 | 37 | int const Y_BREAK_BUFFER = 20; | 38 | int const Y_BREAK_BUFFER = 20; |
373 | 38 | int const X_BREAK_BUFFER = 20; | 39 | int const X_BREAK_BUFFER = 20; |
374 | 39 | int const MAJOR = 2; | ||
375 | 40 | int const MINOR = 3; | ||
376 | 41 | } | 40 | } |
377 | 42 | 41 | ||
378 | 43 | DECLARE_LOGGER(logger, "unity.edge_barrier_controller"); | 42 | DECLARE_LOGGER(logger, "unity.edge_barrier_controller"); |
379 | 44 | 43 | ||
380 | 45 | int GetXI2OpCode() | ||
381 | 46 | { | ||
382 | 47 | Display *dpy = nux::GetGraphicsDisplay()->GetX11Display(); | ||
383 | 48 | |||
384 | 49 | int opcode, event_base, error_base; | ||
385 | 50 | if (!XQueryExtension(dpy, "XFIXES", | ||
386 | 51 | &opcode, | ||
387 | 52 | &event_base, | ||
388 | 53 | &error_base)) | ||
389 | 54 | { | ||
390 | 55 | LOG_ERROR(logger) << "Missing XFixes"; | ||
391 | 56 | return -1; | ||
392 | 57 | } | ||
393 | 58 | |||
394 | 59 | if (!XQueryExtension (dpy, "XInputExtension", | ||
395 | 60 | &opcode, | ||
396 | 61 | &event_base, | ||
397 | 62 | &error_base)) | ||
398 | 63 | { | ||
399 | 64 | LOG_ERROR(logger) << "Missing XInput"; | ||
400 | 65 | return -1; | ||
401 | 66 | } | ||
402 | 67 | |||
403 | 68 | int maj = MAJOR; | ||
404 | 69 | int min = MINOR; | ||
405 | 70 | |||
406 | 71 | if (XIQueryVersion(dpy, &maj, &min) == BadRequest) | ||
407 | 72 | { | ||
408 | 73 | LOG_ERROR(logger) << "Need XInput version 2.3"; | ||
409 | 74 | return -1; | ||
410 | 75 | } | ||
411 | 76 | |||
412 | 77 | return opcode; | ||
413 | 78 | } | ||
414 | 79 | |||
415 | 80 | EdgeBarrierController::Impl::Impl(EdgeBarrierController *parent) | 44 | EdgeBarrierController::Impl::Impl(EdgeBarrierController *parent) |
418 | 81 | : xi2_opcode_(-1) | 45 | : edge_overcome_pressure_(0) |
417 | 82 | , edge_overcome_pressure_(0) | ||
419 | 83 | , parent_(parent) | 46 | , parent_(parent) |
420 | 84 | { | 47 | { |
421 | 85 | UScreen *uscreen = UScreen::GetDefault(); | 48 | UScreen *uscreen = UScreen::GetDefault(); |
422 | @@ -119,8 +82,6 @@ | |||
423 | 119 | options->option_changed.connect(sigc::mem_fun(this, &EdgeBarrierController::Impl::OnOptionsChanged)); | 82 | options->option_changed.connect(sigc::mem_fun(this, &EdgeBarrierController::Impl::OnOptionsChanged)); |
424 | 120 | SetupBarriers(UScreen::GetDefault()->GetMonitors()); | 83 | SetupBarriers(UScreen::GetDefault()->GetMonitors()); |
425 | 121 | }); | 84 | }); |
426 | 122 | |||
427 | 123 | xi2_opcode_ = GetXI2OpCode(); | ||
428 | 124 | } | 85 | } |
429 | 125 | 86 | ||
430 | 126 | EdgeBarrierController::Impl::~Impl() | 87 | EdgeBarrierController::Impl::~Impl() |
431 | @@ -202,36 +163,30 @@ | |||
432 | 202 | } | 163 | } |
433 | 203 | } | 164 | } |
434 | 204 | 165 | ||
435 | 205 | void SetupXI2Events() | ||
436 | 206 | { | ||
437 | 207 | Display *dpy = nux::GetGraphicsDisplay()->GetX11Display(); | ||
438 | 208 | |||
439 | 209 | unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 }; | ||
440 | 210 | XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits }; | ||
441 | 211 | |||
442 | 212 | XISetMask(mask.mask, XI_BarrierHit); | ||
443 | 213 | XISetMask(mask.mask, XI_BarrierLeave); | ||
444 | 214 | XISelectEvents (dpy, DefaultRootWindow(dpy), &mask, 1); | ||
445 | 215 | } | ||
446 | 216 | |||
447 | 217 | void EdgeBarrierController::Impl::SetupBarriers(std::vector<nux::Geometry> const& layout) | 166 | void EdgeBarrierController::Impl::SetupBarriers(std::vector<nux::Geometry> const& layout) |
448 | 218 | { | 167 | { |
449 | 219 | if (parent_->force_disable()) | 168 | if (parent_->force_disable()) |
450 | 220 | return; | 169 | return; |
451 | 221 | 170 | ||
452 | 171 | size_t monitors_size = layout.size(); | ||
453 | 172 | auto launcher_position = Settings::Instance().launcher_position(); | ||
454 | 222 | bool edge_resist = parent_->sticky_edges(); | 173 | bool edge_resist = parent_->sticky_edges(); |
458 | 223 | auto launcher_position = Settings::Instance().launcher_position(); | 174 | bool needs_barrier = edge_resist && monitors_size > 1; |
459 | 224 | 175 | bool needs_vertical_barrier = needs_barrier; | |
460 | 225 | for (unsigned i = 0; i < layout.size(); i++) | 176 | |
461 | 177 | if (parent_->options()->hide_mode() != launcher::LauncherHideMode::LAUNCHER_HIDE_NEVER) | ||
462 | 178 | needs_vertical_barrier = true; | ||
463 | 179 | |||
464 | 180 | for (unsigned i = 0; i < layout.size(); ++i) | ||
465 | 226 | { | 181 | { |
469 | 227 | auto vertical_barrier = vertical_barriers_[i]; | 182 | auto const& vertical_barrier = vertical_barriers_[i]; |
470 | 228 | auto horizontal_barrier = horizontal_barriers_[i]; | 183 | auto const& horizontal_barrier = horizontal_barriers_[i]; |
471 | 229 | auto monitor = layout[i]; | 184 | auto const& monitor = layout[i]; |
472 | 230 | 185 | ||
473 | 231 | vertical_barrier->DestroyBarrier(); | 186 | vertical_barrier->DestroyBarrier(); |
474 | 232 | horizontal_barrier->DestroyBarrier(); | 187 | horizontal_barrier->DestroyBarrier(); |
475 | 233 | 188 | ||
477 | 234 | if (edge_resist) | 189 | if (needs_barrier) |
478 | 235 | { | 190 | { |
479 | 236 | horizontal_barrier->x1 = monitor.x; | 191 | horizontal_barrier->x1 = monitor.x; |
480 | 237 | horizontal_barrier->x2 = monitor.x + monitor.width; | 192 | horizontal_barrier->x2 = monitor.x + monitor.width; |
481 | @@ -246,7 +201,7 @@ | |||
482 | 246 | horizontal_barrier->ConstructBarrier(); | 201 | horizontal_barrier->ConstructBarrier(); |
483 | 247 | } | 202 | } |
484 | 248 | 203 | ||
486 | 249 | if (!edge_resist && parent_->options()->hide_mode() == launcher::LauncherHideMode::LAUNCHER_HIDE_NEVER) | 204 | if (!needs_vertical_barrier) |
487 | 250 | continue; | 205 | continue; |
488 | 251 | 206 | ||
489 | 252 | if (launcher_position == LauncherPosition::LEFT) | 207 | if (launcher_position == LauncherPosition::LEFT) |
490 | @@ -273,8 +228,10 @@ | |||
491 | 273 | vertical_barrier->ConstructBarrier(); | 228 | vertical_barrier->ConstructBarrier(); |
492 | 274 | } | 229 | } |
493 | 275 | 230 | ||
496 | 276 | SetupXI2Events(); | 231 | if (needs_barrier || needs_vertical_barrier) |
497 | 277 | AddEventFilter(); | 232 | input::Monitor::Get().RegisterClient(input::Events::BARRIER, sigc::mem_fun(this, &Impl::HandleEvent)); |
498 | 233 | else | ||
499 | 234 | input::Monitor::Get().UnregisterClient(sigc::mem_fun(this, &Impl::HandleEvent)); | ||
500 | 278 | 235 | ||
501 | 279 | float decay_responsiveness_mult = ((parent_->options()->edge_responsiveness() - 1) * .3f) + 1; | 236 | float decay_responsiveness_mult = ((parent_->options()->edge_responsiveness() - 1) * .3f) + 1; |
502 | 280 | decaymulator_.rate_of_decay = parent_->options()->edge_decay_rate() * decay_responsiveness_mult; | 237 | decaymulator_.rate_of_decay = parent_->options()->edge_decay_rate() * decay_responsiveness_mult; |
503 | @@ -283,65 +240,25 @@ | |||
504 | 283 | edge_overcome_pressure_ = parent_->options()->edge_overcome_pressure() * overcome_responsiveness_mult; | 240 | edge_overcome_pressure_ = parent_->options()->edge_overcome_pressure() * overcome_responsiveness_mult; |
505 | 284 | } | 241 | } |
506 | 285 | 242 | ||
557 | 286 | void EdgeBarrierController::Impl::AddEventFilter() | 243 | void EdgeBarrierController::Impl::HandleEvent(XEvent const& xevent) |
558 | 287 | { | 244 | { |
559 | 288 | // Remove an old one, if it exists | 245 | if (xevent.xcookie.evtype != XI_BarrierHit) |
560 | 289 | nux::GetGraphicsDisplay()->RemoveEventFilter(this); | 246 | return; |
561 | 290 | 247 | ||
562 | 291 | nux::GraphicsDisplay::EventFilterArg event_filter; | 248 | auto* barrier_event = reinterpret_cast<XIBarrierEvent*>(xevent.xcookie.data); |
563 | 292 | event_filter.filter = &HandleEventCB; | 249 | PointerBarrierWrapper::Ptr const& wrapper = FindBarrierEventOwner(barrier_event); |
564 | 293 | event_filter.data = this; | 250 | |
565 | 294 | 251 | if (wrapper) | |
566 | 295 | nux::GetGraphicsDisplay()->AddEventFilter(event_filter); | 252 | wrapper->HandleBarrierEvent(barrier_event); |
517 | 296 | } | ||
518 | 297 | |||
519 | 298 | bool EdgeBarrierController::Impl::HandleEvent(XEvent xevent) | ||
520 | 299 | { | ||
521 | 300 | Display *dpy = nux::GetGraphicsDisplay()->GetX11Display(); | ||
522 | 301 | XGenericEventCookie *cookie = &xevent.xcookie; | ||
523 | 302 | bool ret = false; | ||
524 | 303 | |||
525 | 304 | switch (cookie->evtype) | ||
526 | 305 | { | ||
527 | 306 | case (XI_BarrierHit): | ||
528 | 307 | { | ||
529 | 308 | if (XGetEventData(dpy, cookie)) | ||
530 | 309 | { | ||
531 | 310 | XIBarrierEvent* barrier_event = (XIBarrierEvent*)cookie->data; | ||
532 | 311 | PointerBarrierWrapper::Ptr wrapper = FindBarrierEventOwner(barrier_event); | ||
533 | 312 | |||
534 | 313 | if (wrapper) | ||
535 | 314 | ret = wrapper->HandleBarrierEvent(barrier_event); | ||
536 | 315 | } | ||
537 | 316 | |||
538 | 317 | XFreeEventData(dpy, cookie); | ||
539 | 318 | break; | ||
540 | 319 | } | ||
541 | 320 | default: | ||
542 | 321 | break; | ||
543 | 322 | } | ||
544 | 323 | |||
545 | 324 | return ret; | ||
546 | 325 | } | ||
547 | 326 | |||
548 | 327 | bool EdgeBarrierController::Impl::HandleEventCB(XEvent xevent, void* data) | ||
549 | 328 | { | ||
550 | 329 | auto edge_barrier_controller = static_cast<EdgeBarrierController::Impl*>(data); | ||
551 | 330 | int const xi2_opcode = edge_barrier_controller->xi2_opcode_; | ||
552 | 331 | |||
553 | 332 | if (xevent.type != GenericEvent || xevent.xcookie.extension != xi2_opcode) | ||
554 | 333 | return false; | ||
555 | 334 | |||
556 | 335 | return edge_barrier_controller->HandleEvent(xevent); | ||
567 | 336 | } | 253 | } |
568 | 337 | 254 | ||
569 | 338 | PointerBarrierWrapper::Ptr EdgeBarrierController::Impl::FindBarrierEventOwner(XIBarrierEvent* barrier_event) | 255 | PointerBarrierWrapper::Ptr EdgeBarrierController::Impl::FindBarrierEventOwner(XIBarrierEvent* barrier_event) |
570 | 339 | { | 256 | { |
572 | 340 | for (auto barrier : vertical_barriers_) | 257 | for (auto const& barrier : vertical_barriers_) |
573 | 341 | if (barrier->OwnsBarrierEvent(barrier_event->barrier)) | 258 | if (barrier->OwnsBarrierEvent(barrier_event->barrier)) |
574 | 342 | return barrier; | 259 | return barrier; |
575 | 343 | 260 | ||
577 | 344 | for (auto barrier : horizontal_barriers_) | 261 | for (auto const& barrier : horizontal_barriers_) |
578 | 345 | if (barrier->OwnsBarrierEvent(barrier_event->barrier)) | 262 | if (barrier->OwnsBarrierEvent(barrier_event->barrier)) |
579 | 346 | return barrier; | 263 | return barrier; |
580 | 347 | 264 | ||
581 | 348 | 265 | ||
582 | === modified file 'launcher/EdgeBarrierControllerPrivate.h' | |||
583 | --- launcher/EdgeBarrierControllerPrivate.h 2015-12-23 09:29:24 +0000 | |||
584 | +++ launcher/EdgeBarrierControllerPrivate.h 2016-08-30 14:38:39 +0000 | |||
585 | @@ -53,12 +53,8 @@ | |||
586 | 53 | bool EventIsInsideYBreakZone(BarrierEvent::Ptr const& event); | 53 | bool EventIsInsideYBreakZone(BarrierEvent::Ptr const& event); |
587 | 54 | bool EventIsInsideXBreakZone(BarrierEvent::Ptr const& event); | 54 | bool EventIsInsideXBreakZone(BarrierEvent::Ptr const& event); |
588 | 55 | 55 | ||
589 | 56 | void AddEventFilter(); | ||
590 | 57 | |||
591 | 58 | PointerBarrierWrapper::Ptr FindBarrierEventOwner(XIBarrierEvent* barrier_event); | 56 | PointerBarrierWrapper::Ptr FindBarrierEventOwner(XIBarrierEvent* barrier_event); |
595 | 59 | 57 | void HandleEvent(XEvent const&); | |
593 | 60 | static bool HandleEventCB(XEvent event, void* data); | ||
594 | 61 | bool HandleEvent(XEvent event); | ||
596 | 62 | 58 | ||
597 | 63 | std::vector<PointerBarrierWrapper::Ptr> vertical_barriers_; | 59 | std::vector<PointerBarrierWrapper::Ptr> vertical_barriers_; |
598 | 64 | std::vector<PointerBarrierWrapper::Ptr> horizontal_barriers_; | 60 | std::vector<PointerBarrierWrapper::Ptr> horizontal_barriers_; |
599 | @@ -68,7 +64,6 @@ | |||
600 | 68 | 64 | ||
601 | 69 | Decaymulator decaymulator_; | 65 | Decaymulator decaymulator_; |
602 | 70 | glib::Source::UniquePtr release_timeout_; | 66 | glib::Source::UniquePtr release_timeout_; |
603 | 71 | int xi2_opcode_; | ||
604 | 72 | float edge_overcome_pressure_; | 67 | float edge_overcome_pressure_; |
605 | 73 | EdgeBarrierController* parent_; | 68 | EdgeBarrierController* parent_; |
606 | 74 | }; | 69 | }; |
607 | 75 | 70 | ||
608 | === modified file 'lockscreen/KylinLockScreenShield.cpp' | |||
609 | --- lockscreen/KylinLockScreenShield.cpp 2015-12-07 03:09:28 +0000 | |||
610 | +++ lockscreen/KylinLockScreenShield.cpp 2016-08-30 14:38:39 +0000 | |||
611 | @@ -37,7 +37,7 @@ | |||
612 | 37 | Accelerators::Ptr const& accelerators, | 37 | Accelerators::Ptr const& accelerators, |
613 | 38 | nux::ObjectPtr<AbstractUserPromptView> const& prompt_view, | 38 | nux::ObjectPtr<AbstractUserPromptView> const& prompt_view, |
614 | 39 | int monitor_num, bool is_primary) | 39 | int monitor_num, bool is_primary) |
616 | 40 | : BaseShield(session_manager, nullptr, accelerators, prompt_view, monitor_num, is_primary) | 40 | : BaseShield(session_manager, accelerators, prompt_view, monitor_num, is_primary) |
617 | 41 | { | 41 | { |
618 | 42 | is_primary ? ShowPrimaryView() : ShowSecondaryView(); | 42 | is_primary ? ShowPrimaryView() : ShowSecondaryView(); |
619 | 43 | EnableInputWindow(true); | 43 | EnableInputWindow(true); |
620 | 44 | 44 | ||
621 | === modified file 'lockscreen/LockScreenBaseShield.cpp' | |||
622 | --- lockscreen/LockScreenBaseShield.cpp 2015-12-03 14:13:10 +0000 | |||
623 | +++ lockscreen/LockScreenBaseShield.cpp 2016-08-30 14:38:39 +0000 | |||
624 | @@ -38,7 +38,6 @@ | |||
625 | 38 | } | 38 | } |
626 | 39 | 39 | ||
627 | 40 | BaseShield::BaseShield(session::Manager::Ptr const& session, | 40 | BaseShield::BaseShield(session::Manager::Ptr const& session, |
628 | 41 | indicator::Indicators::Ptr const& indicators, | ||
629 | 42 | Accelerators::Ptr const& accelerators, | 41 | Accelerators::Ptr const& accelerators, |
630 | 43 | nux::ObjectPtr<AbstractUserPromptView> const& prompt_view, | 42 | nux::ObjectPtr<AbstractUserPromptView> const& prompt_view, |
631 | 44 | int monitor_num, bool is_primary) | 43 | int monitor_num, bool is_primary) |
632 | @@ -47,7 +46,6 @@ | |||
633 | 47 | , monitor(monitor_num) | 46 | , monitor(monitor_num) |
634 | 48 | , scale(1.0) | 47 | , scale(1.0) |
635 | 49 | , session_manager_(session) | 48 | , session_manager_(session) |
636 | 50 | , indicators_(indicators) | ||
637 | 51 | , accelerators_(accelerators) | 49 | , accelerators_(accelerators) |
638 | 52 | , prompt_view_(prompt_view) | 50 | , prompt_view_(prompt_view) |
639 | 53 | , bg_settings_(std::make_shared<BackgroundSettings>()) | 51 | , bg_settings_(std::make_shared<BackgroundSettings>()) |
640 | 54 | 52 | ||
641 | === modified file 'lockscreen/LockScreenBaseShield.h' | |||
642 | --- lockscreen/LockScreenBaseShield.h 2016-03-31 09:51:33 +0000 | |||
643 | +++ lockscreen/LockScreenBaseShield.h 2016-08-30 14:38:39 +0000 | |||
644 | @@ -21,8 +21,8 @@ | |||
645 | 21 | #define UNITY_LOCKSCREEN_BASE_SHIELD_H | 21 | #define UNITY_LOCKSCREEN_BASE_SHIELD_H |
646 | 22 | 22 | ||
647 | 23 | #include <NuxCore/Property.h> | 23 | #include <NuxCore/Property.h> |
648 | 24 | #include "UnityCore/ConnectionManager.h" | ||
649 | 24 | #include "UnityCore/SessionManager.h" | 25 | #include "UnityCore/SessionManager.h" |
650 | 25 | #include "UnityCore/Indicators.h" | ||
651 | 26 | #include "UnityCore/GLibSource.h" | 26 | #include "UnityCore/GLibSource.h" |
652 | 27 | #include "unity-shared/MockableBaseWindow.h" | 27 | #include "unity-shared/MockableBaseWindow.h" |
653 | 28 | 28 | ||
654 | @@ -39,8 +39,8 @@ | |||
655 | 39 | class BaseShield : public MockableBaseWindow | 39 | class BaseShield : public MockableBaseWindow |
656 | 40 | { | 40 | { |
657 | 41 | public: | 41 | public: |
660 | 42 | BaseShield(session::Manager::Ptr const&, indicator::Indicators::Ptr const&, | 42 | BaseShield(session::Manager::Ptr const&, Accelerators::Ptr const&, |
661 | 43 | Accelerators::Ptr const&, nux::ObjectPtr<AbstractUserPromptView> const&, | 43 | nux::ObjectPtr<AbstractUserPromptView> const&, |
662 | 44 | int monitor_num, bool is_primary); | 44 | int monitor_num, bool is_primary); |
663 | 45 | 45 | ||
664 | 46 | nux::Property<bool> primary; | 46 | nux::Property<bool> primary; |
665 | @@ -69,7 +69,6 @@ | |||
666 | 69 | void UpdateScale(); | 69 | void UpdateScale(); |
667 | 70 | 70 | ||
668 | 71 | session::Manager::Ptr session_manager_; | 71 | session::Manager::Ptr session_manager_; |
669 | 72 | indicator::Indicators::Ptr indicators_; | ||
670 | 73 | Accelerators::Ptr accelerators_; | 72 | Accelerators::Ptr accelerators_; |
671 | 74 | nux::ObjectPtr<AbstractUserPromptView> prompt_view_; | 73 | nux::ObjectPtr<AbstractUserPromptView> prompt_view_; |
672 | 75 | std::shared_ptr<BackgroundSettings> bg_settings_; | 74 | std::shared_ptr<BackgroundSettings> bg_settings_; |
673 | 76 | 75 | ||
674 | === modified file 'lockscreen/LockScreenController.cpp' | |||
675 | --- lockscreen/LockScreenController.cpp 2016-07-04 12:45:06 +0000 | |||
676 | +++ lockscreen/LockScreenController.cpp 2016-08-30 14:38:39 +0000 | |||
677 | @@ -56,6 +56,7 @@ | |||
678 | 56 | Controller::Controller(DBusManager::Ptr const& dbus_manager, | 56 | Controller::Controller(DBusManager::Ptr const& dbus_manager, |
679 | 57 | session::Manager::Ptr const& session_manager, | 57 | session::Manager::Ptr const& session_manager, |
680 | 58 | key::Grabber::Ptr const& key_grabber, | 58 | key::Grabber::Ptr const& key_grabber, |
681 | 59 | SystemdWrapper::Ptr const& systemd_wrapper, | ||
682 | 59 | UpstartWrapper::Ptr const& upstart_wrapper, | 60 | UpstartWrapper::Ptr const& upstart_wrapper, |
683 | 60 | ShieldFactoryInterface::Ptr const& shield_factory, | 61 | ShieldFactoryInterface::Ptr const& shield_factory, |
684 | 61 | bool test_mode) | 62 | bool test_mode) |
685 | @@ -63,6 +64,7 @@ | |||
686 | 63 | , dbus_manager_(dbus_manager) | 64 | , dbus_manager_(dbus_manager) |
687 | 64 | , session_manager_(session_manager) | 65 | , session_manager_(session_manager) |
688 | 65 | , key_grabber_(key_grabber) | 66 | , key_grabber_(key_grabber) |
689 | 67 | , systemd_wrapper_(systemd_wrapper) | ||
690 | 66 | , upstart_wrapper_(upstart_wrapper) | 68 | , upstart_wrapper_(upstart_wrapper) |
691 | 67 | , shield_factory_(shield_factory) | 69 | , shield_factory_(shield_factory) |
692 | 68 | , suspend_inhibitor_manager_(std::make_shared<SuspendInhibitorManager>()) | 70 | , suspend_inhibitor_manager_(std::make_shared<SuspendInhibitorManager>()) |
693 | @@ -129,8 +131,9 @@ | |||
694 | 129 | shields_.clear(); | 131 | shields_.clear(); |
695 | 130 | 132 | ||
696 | 131 | upstart_wrapper_->Emit("desktop-unlock"); | 133 | upstart_wrapper_->Emit("desktop-unlock"); |
697 | 134 | systemd_wrapper_->Stop("unity-screen-locked.target"); | ||
698 | 132 | accelerator_controller_.reset(); | 135 | accelerator_controller_.reset(); |
700 | 133 | indicators_.reset(); | 136 | menu_manager_.reset(); |
701 | 134 | } | 137 | } |
702 | 135 | else if (!prompt_activation_) | 138 | else if (!prompt_activation_) |
703 | 136 | { | 139 | { |
704 | @@ -252,7 +255,7 @@ | |||
705 | 252 | 255 | ||
706 | 253 | if (i >= shields_size) | 256 | if (i >= shields_size) |
707 | 254 | { | 257 | { |
709 | 255 | shield = shield_factory_->CreateShield(session_manager_, indicators_, accelerator_controller_->GetAccelerators(), prompt_view, i, i == primary); | 258 | shield = shield_factory_->CreateShield(session_manager_, menu_manager_, accelerator_controller_->GetAccelerators(), prompt_view, i, i == primary); |
710 | 256 | is_new = true; | 259 | is_new = true; |
711 | 257 | } | 260 | } |
712 | 258 | 261 | ||
713 | @@ -462,8 +465,9 @@ | |||
714 | 462 | 465 | ||
715 | 463 | void Controller::LockScreen() | 466 | void Controller::LockScreen() |
716 | 464 | { | 467 | { |
718 | 465 | indicators_ = std::make_shared<indicator::LockScreenDBusIndicators>(); | 468 | menu_manager_ = std::make_shared<menu::Manager>(std::make_shared<indicator::LockScreenDBusIndicators>(), key_grabber_); |
719 | 466 | upstart_wrapper_->Emit("desktop-lock"); | 469 | upstart_wrapper_->Emit("desktop-lock"); |
720 | 470 | systemd_wrapper_->Stop("unity-screen-locked.target"); | ||
721 | 467 | 471 | ||
722 | 468 | accelerator_controller_ = std::make_shared<AcceleratorController>(key_grabber_); | 472 | accelerator_controller_ = std::make_shared<AcceleratorController>(key_grabber_); |
723 | 469 | auto activate_key = WindowManager::Default().activate_indicators_key(); | 473 | auto activate_key = WindowManager::Default().activate_indicators_key(); |
724 | 470 | 474 | ||
725 | === modified file 'lockscreen/LockScreenController.h' | |||
726 | --- lockscreen/LockScreenController.h 2016-06-21 01:28:26 +0000 | |||
727 | +++ lockscreen/LockScreenController.h 2016-08-30 14:38:39 +0000 | |||
728 | @@ -30,7 +30,7 @@ | |||
729 | 30 | #include "SuspendInhibitorManager.h" | 30 | #include "SuspendInhibitorManager.h" |
730 | 31 | #include "ScreenSaverDBusManager.h" | 31 | #include "ScreenSaverDBusManager.h" |
731 | 32 | #include "unity-shared/BackgroundEffectHelper.h" | 32 | #include "unity-shared/BackgroundEffectHelper.h" |
733 | 33 | #include "unity-shared/KeyGrabber.h" | 33 | #include "unity-shared/SystemdWrapper.h" |
734 | 34 | #include "unity-shared/UpstartWrapper.h" | 34 | #include "unity-shared/UpstartWrapper.h" |
735 | 35 | 35 | ||
736 | 36 | namespace unity | 36 | namespace unity |
737 | @@ -46,6 +46,7 @@ | |||
738 | 46 | typedef std::shared_ptr<Controller> Ptr; | 46 | typedef std::shared_ptr<Controller> Ptr; |
739 | 47 | 47 | ||
740 | 48 | Controller(DBusManager::Ptr const&, session::Manager::Ptr const&, key::Grabber::Ptr const&, | 48 | Controller(DBusManager::Ptr const&, session::Manager::Ptr const&, key::Grabber::Ptr const&, |
741 | 49 | SystemdWrapper::Ptr const& systemd_wrapper = std::make_shared<SystemdWrapper>(), | ||
742 | 49 | UpstartWrapper::Ptr const& upstart_wrapper = std::make_shared<UpstartWrapper>(), | 50 | UpstartWrapper::Ptr const& upstart_wrapper = std::make_shared<UpstartWrapper>(), |
743 | 50 | ShieldFactoryInterface::Ptr const& shield_factory = std::make_shared<ShieldFactory>(), | 51 | ShieldFactoryInterface::Ptr const& shield_factory = std::make_shared<ShieldFactory>(), |
744 | 51 | bool test_mode = false); | 52 | bool test_mode = false); |
745 | @@ -85,9 +86,10 @@ | |||
746 | 85 | 86 | ||
747 | 86 | DBusManager::Ptr dbus_manager_; | 87 | DBusManager::Ptr dbus_manager_; |
748 | 87 | session::Manager::Ptr session_manager_; | 88 | session::Manager::Ptr session_manager_; |
749 | 89 | menu::Manager::Ptr menu_manager_; | ||
750 | 88 | key::Grabber::Ptr key_grabber_; | 90 | key::Grabber::Ptr key_grabber_; |
751 | 89 | indicator::Indicators::Ptr indicators_; | ||
752 | 90 | AcceleratorController::Ptr accelerator_controller_; | 91 | AcceleratorController::Ptr accelerator_controller_; |
753 | 92 | SystemdWrapper::Ptr systemd_wrapper_; | ||
754 | 91 | UpstartWrapper::Ptr upstart_wrapper_; | 93 | UpstartWrapper::Ptr upstart_wrapper_; |
755 | 92 | ShieldFactoryInterface::Ptr shield_factory_; | 94 | ShieldFactoryInterface::Ptr shield_factory_; |
756 | 93 | SuspendInhibitorManager::Ptr suspend_inhibitor_manager_; | 95 | SuspendInhibitorManager::Ptr suspend_inhibitor_manager_; |
757 | 94 | 96 | ||
758 | === modified file 'lockscreen/LockScreenPanel.cpp' | |||
759 | --- lockscreen/LockScreenPanel.cpp 2015-11-05 14:55:54 +0000 | |||
760 | +++ lockscreen/LockScreenPanel.cpp 2016-08-30 14:38:39 +0000 | |||
761 | @@ -24,7 +24,7 @@ | |||
762 | 24 | 24 | ||
763 | 25 | #include "LockScreenSettings.h" | 25 | #include "LockScreenSettings.h" |
764 | 26 | #include "panel/PanelIndicatorsView.h" | 26 | #include "panel/PanelIndicatorsView.h" |
766 | 27 | #include "unity-shared/CairoTexture.h" | 27 | #include "unity-shared/InputMonitor.h" |
767 | 28 | #include "unity-shared/StaticCairoText.h" | 28 | #include "unity-shared/StaticCairoText.h" |
768 | 29 | #include "unity-shared/PanelStyle.h" | 29 | #include "unity-shared/PanelStyle.h" |
769 | 30 | #include "unity-shared/RawPixel.h" | 30 | #include "unity-shared/RawPixel.h" |
770 | @@ -38,24 +38,24 @@ | |||
771 | 38 | namespace | 38 | namespace |
772 | 39 | { | 39 | { |
773 | 40 | const RawPixel PADDING = 5_em; | 40 | const RawPixel PADDING = 5_em; |
774 | 41 | const nux::Color BG_COLOR(0.1, 0.1, 0.1, 0.4); | ||
775 | 41 | } | 42 | } |
776 | 42 | 43 | ||
777 | 43 | using namespace indicator; | 44 | using namespace indicator; |
778 | 44 | using namespace panel; | 45 | using namespace panel; |
779 | 45 | 46 | ||
781 | 46 | Panel::Panel(int monitor_, Indicators::Ptr const& indicators, session::Manager::Ptr const& session_manager) | 47 | Panel::Panel(int monitor_, menu::Manager::Ptr const& menu_manager, session::Manager::Ptr const& session_manager) |
782 | 47 | : nux::View(NUX_TRACKER_LOCATION) | 48 | : nux::View(NUX_TRACKER_LOCATION) |
783 | 48 | , active(false) | 49 | , active(false) |
784 | 49 | , monitor(monitor_) | 50 | , monitor(monitor_) |
786 | 50 | , indicators_(indicators) | 51 | , menu_manager_(menu_manager) |
787 | 51 | , needs_geo_sync_(true) | 52 | , needs_geo_sync_(true) |
788 | 52 | { | 53 | { |
789 | 53 | double scale = unity::Settings::Instance().em(monitor)->DPIScale(); | 54 | double scale = unity::Settings::Instance().em(monitor)->DPIScale(); |
790 | 54 | auto* layout = new nux::HLayout(); | 55 | auto* layout = new nux::HLayout(); |
791 | 55 | layout->SetLeftAndRightPadding(PADDING.CP(scale), 0); | 56 | layout->SetLeftAndRightPadding(PADDING.CP(scale), 0); |
792 | 56 | SetLayout(layout); | 57 | SetLayout(layout); |
795 | 57 | 58 | UpdateSize(); | |
794 | 58 | BuildTexture(); | ||
796 | 59 | 59 | ||
797 | 60 | // Add setting | 60 | // Add setting |
798 | 61 | auto *hostname = new StaticCairoText(session_manager->HostName()); | 61 | auto *hostname = new StaticCairoText(session_manager->HostName()); |
799 | @@ -72,34 +72,33 @@ | |||
800 | 72 | indicators_view_->on_indicator_updated.connect(sigc::mem_fun(this, &Panel::OnIndicatorViewUpdated)); | 72 | indicators_view_->on_indicator_updated.connect(sigc::mem_fun(this, &Panel::OnIndicatorViewUpdated)); |
801 | 73 | layout->AddView(indicators_view_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); | 73 | layout->AddView(indicators_view_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); |
802 | 74 | 74 | ||
804 | 75 | for (auto const& indicator : indicators_->GetIndicators()) | 75 | auto indicators = menu_manager_->Indicators(); |
805 | 76 | menu_manager_->RegisterTracker(GetPanelName(), (sigc::track_obj([this] (int x, int y, double speed) { | ||
806 | 77 | indicators_view_->ActivateEntryAt(x, y); | ||
807 | 78 | }, *this))); | ||
808 | 79 | |||
809 | 80 | for (auto const& indicator : indicators->GetIndicators()) | ||
810 | 76 | AddIndicator(indicator); | 81 | AddIndicator(indicator); |
811 | 77 | 82 | ||
817 | 78 | indicators_->on_object_added.connect(sigc::mem_fun(this, &Panel::AddIndicator)); | 83 | indicators->on_object_added.connect(sigc::mem_fun(this, &Panel::AddIndicator)); |
818 | 79 | indicators_->on_object_removed.connect(sigc::mem_fun(this, &Panel::RemoveIndicator)); | 84 | indicators->on_object_removed.connect(sigc::mem_fun(this, &Panel::RemoveIndicator)); |
819 | 80 | indicators_->on_entry_show_menu.connect(sigc::mem_fun(this, &Panel::OnEntryShowMenu)); | 85 | indicators->on_entry_show_menu.connect(sigc::mem_fun(this, &Panel::OnEntryShowMenu)); |
820 | 81 | indicators_->on_entry_activated.connect(sigc::mem_fun(this, &Panel::OnEntryActivated)); | 86 | indicators->on_entry_activated.connect(sigc::mem_fun(this, &Panel::OnEntryActivated)); |
821 | 82 | indicators_->on_entry_activate_request.connect(sigc::mem_fun(this, &Panel::OnEntryActivateRequest)); | 87 | indicators->on_entry_activate_request.connect(sigc::mem_fun(this, &Panel::OnEntryActivateRequest)); |
822 | 83 | 88 | ||
823 | 84 | monitor.changed.connect([this, hostname] (int monitor) { | 89 | monitor.changed.connect([this, hostname] (int monitor) { |
824 | 85 | double scale = unity::Settings::Instance().em(monitor)->DPIScale(); | 90 | double scale = unity::Settings::Instance().em(monitor)->DPIScale(); |
825 | 86 | hostname->SetScale(scale); | 91 | hostname->SetScale(scale); |
826 | 87 | static_cast<nux::HLayout*>(GetLayout())->SetLeftAndRightPadding(PADDING.CP(scale), 0); | 92 | static_cast<nux::HLayout*>(GetLayout())->SetLeftAndRightPadding(PADDING.CP(scale), 0); |
827 | 88 | indicators_view_->SetMonitor(monitor); | 93 | indicators_view_->SetMonitor(monitor); |
829 | 89 | BuildTexture(); | 94 | UpdateSize(); |
830 | 90 | QueueRelayout(); | 95 | QueueRelayout(); |
831 | 91 | }); | 96 | }); |
832 | 92 | } | 97 | } |
833 | 93 | 98 | ||
835 | 94 | void Panel::BuildTexture() | 99 | void Panel::UpdateSize() |
836 | 95 | { | 100 | { |
837 | 96 | int height = panel::Style::Instance().PanelHeight(monitor); | 101 | int height = panel::Style::Instance().PanelHeight(monitor); |
838 | 97 | nux::CairoGraphics context(CAIRO_FORMAT_ARGB32, 1, height); | ||
839 | 98 | auto* cr = context.GetInternalContext(); | ||
840 | 99 | cairo_set_source_rgb(cr, 0.1, 0.1, 0.1); | ||
841 | 100 | cairo_paint_with_alpha(cr, 0.4); | ||
842 | 101 | bg_texture_ = texture_ptr_from_cairo_graphics(context); | ||
843 | 102 | |||
844 | 103 | view_layout_->SetMinimumHeight(height); | 102 | view_layout_->SetMinimumHeight(height); |
845 | 104 | view_layout_->SetMaximumHeight(height); | 103 | view_layout_->SetMaximumHeight(height); |
846 | 105 | } | 104 | } |
847 | @@ -165,12 +164,7 @@ | |||
848 | 165 | if (!GetInputEventSensitivity()) | 164 | if (!GetInputEventSensitivity()) |
849 | 166 | return; | 165 | return; |
850 | 167 | 166 | ||
857 | 168 | if (!active) | 167 | active = true; |
852 | 169 | { | ||
853 | 170 | // This is ugly... But Nux fault! | ||
854 | 171 | WindowManager::Default().UnGrabMousePointer(CurrentTime, button, x, y); | ||
855 | 172 | active = true; | ||
856 | 173 | } | ||
858 | 174 | } | 168 | } |
859 | 175 | 169 | ||
860 | 176 | void Panel::OnEntryActivateRequest(std::string const& entry_id) | 170 | void Panel::OnEntryActivateRequest(std::string const& entry_id) |
861 | @@ -184,36 +178,16 @@ | |||
862 | 184 | if (!GetInputEventSensitivity() || (!panel.empty() && panel != GetPanelName())) | 178 | if (!GetInputEventSensitivity() || (!panel.empty() && panel != GetPanelName())) |
863 | 185 | return; | 179 | return; |
864 | 186 | 180 | ||
866 | 187 | bool active = !entry_id.empty(); | 181 | bool valid_entry = !entry_id.empty(); |
867 | 188 | 182 | ||
869 | 189 | if (active && !WindowManager::Default().IsScreenGrabbed()) | 183 | if (valid_entry && !WindowManager::Default().IsScreenGrabbed()) |
870 | 190 | { | 184 | { |
871 | 191 | // The menu didn't grab the keyboard, let's take it back. | 185 | // The menu didn't grab the keyboard, let's take it back. |
872 | 192 | nux::GetWindowCompositor().GrabKeyboardAdd(static_cast<nux::BaseWindow*>(GetTopLevelViewWindow())); | 186 | nux::GetWindowCompositor().GrabKeyboardAdd(static_cast<nux::BaseWindow*>(GetTopLevelViewWindow())); |
873 | 193 | } | 187 | } |
874 | 194 | 188 | ||
897 | 195 | if (active && !track_menu_pointer_timeout_) | 189 | if (!valid_entry) |
898 | 196 | { | 190 | active = valid_entry; |
877 | 197 | track_menu_pointer_timeout_.reset(new glib::Timeout(16)); | ||
878 | 198 | track_menu_pointer_timeout_->Run([this] { | ||
879 | 199 | nux::Point const& mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord(); | ||
880 | 200 | if (tracked_pointer_pos_ != mouse) | ||
881 | 201 | { | ||
882 | 202 | if (GetAbsoluteGeometry().IsPointInside(mouse.x, mouse.y)) | ||
883 | 203 | indicators_view_->ActivateEntryAt(mouse.x, mouse.y); | ||
884 | 204 | |||
885 | 205 | tracked_pointer_pos_ = mouse; | ||
886 | 206 | } | ||
887 | 207 | |||
888 | 208 | return true; | ||
889 | 209 | }); | ||
890 | 210 | } | ||
891 | 211 | else if (!active) | ||
892 | 212 | { | ||
893 | 213 | track_menu_pointer_timeout_.reset(); | ||
894 | 214 | tracked_pointer_pos_ = {-1, -1}; | ||
895 | 215 | this->active = false; | ||
896 | 216 | } | ||
899 | 217 | } | 191 | } |
900 | 218 | 192 | ||
901 | 219 | void Panel::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) | 193 | void Panel::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) |
902 | @@ -227,12 +201,7 @@ | |||
903 | 227 | graphics_engine.PushClippingRectangle(geo); | 201 | graphics_engine.PushClippingRectangle(geo); |
904 | 228 | nux::GetPainter().PaintBackground(graphics_engine, geo); | 202 | nux::GetPainter().PaintBackground(graphics_engine, geo); |
905 | 229 | 203 | ||
912 | 230 | nux::TexCoordXForm texxform; | 204 | graphics_engine.QRP_Color(geo.x, geo.y, geo.width, geo.height, BG_COLOR); |
907 | 231 | texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_CLAMP); | ||
908 | 232 | graphics_engine.QRP_1Tex(geo.x, geo.y, geo.width, geo.height, | ||
909 | 233 | bg_texture_->GetDeviceTexture(), texxform, | ||
910 | 234 | nux::color::White); | ||
911 | 235 | |||
913 | 236 | view_layout_->ProcessDraw(graphics_engine, force_draw); | 205 | view_layout_->ProcessDraw(graphics_engine, force_draw); |
914 | 237 | 206 | ||
915 | 238 | graphics_engine.PopClippingRectangle(); | 207 | graphics_engine.PopClippingRectangle(); |
916 | @@ -242,7 +211,7 @@ | |||
917 | 242 | { | 211 | { |
918 | 243 | EntryLocationMap locations; | 212 | EntryLocationMap locations; |
919 | 244 | indicators_view_->GetGeometryForSync(locations); | 213 | indicators_view_->GetGeometryForSync(locations); |
921 | 245 | indicators_->SyncGeometries(GetPanelName(), locations); | 214 | menu_manager_->Indicators()->SyncGeometries(GetPanelName(), locations); |
922 | 246 | needs_geo_sync_ = false; | 215 | needs_geo_sync_ = false; |
923 | 247 | } | 216 | } |
924 | 248 | } | 217 | } |
925 | 249 | 218 | ||
926 | === modified file 'lockscreen/LockScreenPanel.h' | |||
927 | --- lockscreen/LockScreenPanel.h 2016-03-31 09:51:33 +0000 | |||
928 | +++ lockscreen/LockScreenPanel.h 2016-08-30 14:38:39 +0000 | |||
929 | @@ -22,9 +22,9 @@ | |||
930 | 22 | 22 | ||
931 | 23 | #include <Nux/Nux.h> | 23 | #include <Nux/Nux.h> |
932 | 24 | #include <Nux/View.h> | 24 | #include <Nux/View.h> |
933 | 25 | #include "UnityCore/Indicators.h" | ||
934 | 26 | #include "UnityCore/GLibSource.h" | 25 | #include "UnityCore/GLibSource.h" |
935 | 27 | #include "UnityCore/SessionManager.h" | 26 | #include "UnityCore/SessionManager.h" |
936 | 27 | #include "unity-shared/MenuManager.h" | ||
937 | 28 | 28 | ||
938 | 29 | namespace unity | 29 | namespace unity |
939 | 30 | { | 30 | { |
940 | @@ -39,7 +39,7 @@ | |||
941 | 39 | class Panel : public nux::View | 39 | class Panel : public nux::View |
942 | 40 | { | 40 | { |
943 | 41 | public: | 41 | public: |
945 | 42 | Panel(int monitor, indicator::Indicators::Ptr const&, session::Manager::Ptr const&); | 42 | Panel(int monitor, menu::Manager::Ptr const&, session::Manager::Ptr const&); |
946 | 43 | 43 | ||
947 | 44 | nux::Property<bool> active; | 44 | nux::Property<bool> active; |
948 | 45 | nux::Property<int> monitor; | 45 | nux::Property<int> monitor; |
949 | @@ -55,20 +55,16 @@ | |||
950 | 55 | void AddIndicator(indicator::Indicator::Ptr const&); | 55 | void AddIndicator(indicator::Indicator::Ptr const&); |
951 | 56 | void RemoveIndicator(indicator::Indicator::Ptr const&); | 56 | void RemoveIndicator(indicator::Indicator::Ptr const&); |
952 | 57 | void OnIndicatorViewUpdated(); | 57 | void OnIndicatorViewUpdated(); |
954 | 58 | void OnEntryActivated(std::string const& panel, std::string const& entry_id, nux::Rect const& geo); | 58 | void OnEntryActivated(std::string const& panel, std::string const& entry_id, nux::Rect const&); |
955 | 59 | void OnEntryShowMenu(std::string const& entry_id, unsigned xid, int x, int y, unsigned button); | 59 | void OnEntryShowMenu(std::string const& entry_id, unsigned xid, int x, int y, unsigned button); |
956 | 60 | void OnEntryActivateRequest(std::string const& entry_id); | 60 | void OnEntryActivateRequest(std::string const& entry_id); |
957 | 61 | 61 | ||
959 | 62 | void BuildTexture(); | 62 | void UpdateSize(); |
960 | 63 | std::string GetPanelName() const; | 63 | std::string GetPanelName() const; |
961 | 64 | 64 | ||
963 | 65 | indicator::Indicators::Ptr indicators_; | 65 | menu::Manager::Ptr menu_manager_; |
964 | 66 | panel::PanelIndicatorsView* indicators_view_; | 66 | panel::PanelIndicatorsView* indicators_view_; |
965 | 67 | nux::ObjectPtr<nux::BaseTexture> bg_texture_; | ||
966 | 68 | |||
967 | 69 | bool needs_geo_sync_; | 67 | bool needs_geo_sync_; |
968 | 70 | nux::Point tracked_pointer_pos_; | ||
969 | 71 | glib::Source::UniquePtr track_menu_pointer_timeout_; | ||
970 | 72 | }; | 68 | }; |
971 | 73 | 69 | ||
972 | 74 | } // lockscreen namespace | 70 | } // lockscreen namespace |
973 | 75 | 71 | ||
974 | === modified file 'lockscreen/LockScreenShield.cpp' | |||
975 | --- lockscreen/LockScreenShield.cpp 2015-12-03 14:13:10 +0000 | |||
976 | +++ lockscreen/LockScreenShield.cpp 2016-08-30 14:38:39 +0000 | |||
977 | @@ -32,11 +32,12 @@ | |||
978 | 32 | { | 32 | { |
979 | 33 | 33 | ||
980 | 34 | Shield::Shield(session::Manager::Ptr const& session_manager, | 34 | Shield::Shield(session::Manager::Ptr const& session_manager, |
982 | 35 | indicator::Indicators::Ptr const& indicators, | 35 | menu::Manager::Ptr const& menu_manager, |
983 | 36 | Accelerators::Ptr const& accelerators, | 36 | Accelerators::Ptr const& accelerators, |
984 | 37 | nux::ObjectPtr<AbstractUserPromptView> const& prompt_view, | 37 | nux::ObjectPtr<AbstractUserPromptView> const& prompt_view, |
985 | 38 | int monitor_num, bool is_primary) | 38 | int monitor_num, bool is_primary) |
987 | 39 | : BaseShield(session_manager, indicators, accelerators, prompt_view, monitor_num, is_primary) | 39 | : BaseShield(session_manager, accelerators, prompt_view, monitor_num, is_primary) |
988 | 40 | , menu_manager_(menu_manager) | ||
989 | 40 | , panel_view_(nullptr) | 41 | , panel_view_(nullptr) |
990 | 41 | { | 42 | { |
991 | 42 | is_primary ? ShowPrimaryView() : ShowSecondaryView(); | 43 | is_primary ? ShowPrimaryView() : ShowSecondaryView(); |
992 | @@ -91,11 +92,11 @@ | |||
993 | 91 | 92 | ||
994 | 92 | Panel* Shield::CreatePanel() | 93 | Panel* Shield::CreatePanel() |
995 | 93 | { | 94 | { |
997 | 94 | if (!indicators_ || !session_manager_) | 95 | if (!menu_manager_ || !session_manager_) |
998 | 95 | return nullptr; | 96 | return nullptr; |
999 | 96 | 97 | ||
1002 | 97 | panel_view_ = new Panel(monitor, indicators_, session_manager_); | 98 | panel_view_ = new Panel(monitor, menu_manager_, session_manager_); |
1003 | 98 | panel_active_conn_ = panel_view_->active.changed.connect([this] (bool active) { | 99 | panel_view_->active.changed.connect(sigc::track_obj([this] (bool active) { |
1004 | 99 | if (primary()) | 100 | if (primary()) |
1005 | 100 | { | 101 | { |
1006 | 101 | if (active) | 102 | if (active) |
1007 | @@ -109,7 +110,7 @@ | |||
1008 | 109 | GrabScreen(false); | 110 | GrabScreen(false); |
1009 | 110 | } | 111 | } |
1010 | 111 | } | 112 | } |
1012 | 112 | }); | 113 | }, *this)); |
1013 | 113 | 114 | ||
1014 | 114 | return panel_view_; | 115 | return panel_view_; |
1015 | 115 | } | 116 | } |
1016 | 116 | 117 | ||
1017 | === modified file 'lockscreen/LockScreenShield.h' | |||
1018 | --- lockscreen/LockScreenShield.h 2015-12-03 14:13:10 +0000 | |||
1019 | +++ lockscreen/LockScreenShield.h 2016-08-30 14:38:39 +0000 | |||
1020 | @@ -20,8 +20,9 @@ | |||
1021 | 20 | #ifndef UNITY_LOCKSCREEN_SHIELD_H | 20 | #ifndef UNITY_LOCKSCREEN_SHIELD_H |
1022 | 21 | #define UNITY_LOCKSCREEN_SHIELD_H | 21 | #define UNITY_LOCKSCREEN_SHIELD_H |
1023 | 22 | 22 | ||
1024 | 23 | #include <UnityCore/ConnectionManager.h> | ||
1025 | 24 | #include "LockScreenBaseShield.h" | 23 | #include "LockScreenBaseShield.h" |
1026 | 24 | #include "unity-shared/MenuManager.h" | ||
1027 | 25 | |||
1028 | 25 | 26 | ||
1029 | 26 | namespace unity | 27 | namespace unity |
1030 | 27 | { | 28 | { |
1031 | @@ -35,7 +36,7 @@ | |||
1032 | 35 | { | 36 | { |
1033 | 36 | public: | 37 | public: |
1034 | 37 | Shield(session::Manager::Ptr const&, | 38 | Shield(session::Manager::Ptr const&, |
1036 | 38 | indicator::Indicators::Ptr const&, | 39 | menu::Manager::Ptr const&, |
1037 | 39 | Accelerators::Ptr const&, | 40 | Accelerators::Ptr const&, |
1038 | 40 | nux::ObjectPtr<AbstractUserPromptView> const&, | 41 | nux::ObjectPtr<AbstractUserPromptView> const&, |
1039 | 41 | int monitor, bool is_primary); | 42 | int monitor, bool is_primary); |
1040 | @@ -50,7 +51,7 @@ | |||
1041 | 50 | void ShowPrimaryView() override; | 51 | void ShowPrimaryView() override; |
1042 | 51 | Panel* CreatePanel(); | 52 | Panel* CreatePanel(); |
1043 | 52 | 53 | ||
1045 | 53 | connection::Wrapper panel_active_conn_; | 54 | menu::Manager::Ptr menu_manager_; |
1046 | 54 | Panel* panel_view_; | 55 | Panel* panel_view_; |
1047 | 55 | }; | 56 | }; |
1048 | 56 | 57 | ||
1049 | 57 | 58 | ||
1050 | === modified file 'lockscreen/LockScreenShieldFactory.cpp' | |||
1051 | --- lockscreen/LockScreenShieldFactory.cpp 2015-12-04 08:17:46 +0000 | |||
1052 | +++ lockscreen/LockScreenShieldFactory.cpp 2016-08-30 14:38:39 +0000 | |||
1053 | @@ -28,7 +28,7 @@ | |||
1054 | 28 | { | 28 | { |
1055 | 29 | 29 | ||
1056 | 30 | nux::ObjectPtr<BaseShield> ShieldFactory::CreateShield(session::Manager::Ptr const& session_manager, | 30 | nux::ObjectPtr<BaseShield> ShieldFactory::CreateShield(session::Manager::Ptr const& session_manager, |
1058 | 31 | indicator::Indicators::Ptr const& indicators, | 31 | menu::Manager::Ptr const& menu_manager, |
1059 | 32 | Accelerators::Ptr const& accelerators, | 32 | Accelerators::Ptr const& accelerators, |
1060 | 33 | nux::ObjectPtr<AbstractUserPromptView> const& prompt_view, | 33 | nux::ObjectPtr<AbstractUserPromptView> const& prompt_view, |
1061 | 34 | int monitor, bool is_primary) | 34 | int monitor, bool is_primary) |
1062 | @@ -38,7 +38,7 @@ | |||
1063 | 38 | if (Settings::Instance().desktop_type() == DesktopType::UBUNTUKYLIN) | 38 | if (Settings::Instance().desktop_type() == DesktopType::UBUNTUKYLIN) |
1064 | 39 | shield = new KylinShield(session_manager, accelerators, prompt_view, monitor, is_primary); | 39 | shield = new KylinShield(session_manager, accelerators, prompt_view, monitor, is_primary); |
1065 | 40 | else | 40 | else |
1067 | 41 | shield = new Shield(session_manager, indicators, accelerators, prompt_view, monitor, is_primary); | 41 | shield = new Shield(session_manager, menu_manager, accelerators, prompt_view, monitor, is_primary); |
1068 | 42 | 42 | ||
1069 | 43 | return shield; | 43 | return shield; |
1070 | 44 | } | 44 | } |
1071 | 45 | 45 | ||
1072 | === modified file 'lockscreen/LockScreenShieldFactory.h' | |||
1073 | --- lockscreen/LockScreenShieldFactory.h 2016-03-31 09:51:33 +0000 | |||
1074 | +++ lockscreen/LockScreenShieldFactory.h 2016-08-30 14:38:39 +0000 | |||
1075 | @@ -22,7 +22,7 @@ | |||
1076 | 22 | 22 | ||
1077 | 23 | #include <NuxCore/NuxCore.h> | 23 | #include <NuxCore/NuxCore.h> |
1078 | 24 | #include "UnityCore/SessionManager.h" | 24 | #include "UnityCore/SessionManager.h" |
1080 | 25 | #include "UnityCore/Indicators.h" | 25 | #include "unity-shared/MenuManager.h" |
1081 | 26 | #include "LockScreenAccelerators.h" | 26 | #include "LockScreenAccelerators.h" |
1082 | 27 | 27 | ||
1083 | 28 | namespace unity | 28 | namespace unity |
1084 | @@ -41,7 +41,7 @@ | |||
1085 | 41 | virtual ~ShieldFactoryInterface() = default; | 41 | virtual ~ShieldFactoryInterface() = default; |
1086 | 42 | 42 | ||
1087 | 43 | virtual nux::ObjectPtr<BaseShield> CreateShield(session::Manager::Ptr const&, | 43 | virtual nux::ObjectPtr<BaseShield> CreateShield(session::Manager::Ptr const&, |
1089 | 44 | indicator::Indicators::Ptr const&, | 44 | menu::Manager::Ptr const&, |
1090 | 45 | Accelerators::Ptr const&, | 45 | Accelerators::Ptr const&, |
1091 | 46 | nux::ObjectPtr<AbstractUserPromptView> const&, | 46 | nux::ObjectPtr<AbstractUserPromptView> const&, |
1092 | 47 | int monitor, bool is_primary) = 0; | 47 | int monitor, bool is_primary) = 0; |
1093 | @@ -50,7 +50,7 @@ | |||
1094 | 50 | struct ShieldFactory : ShieldFactoryInterface | 50 | struct ShieldFactory : ShieldFactoryInterface |
1095 | 51 | { | 51 | { |
1096 | 52 | nux::ObjectPtr<BaseShield> CreateShield(session::Manager::Ptr const&, | 52 | nux::ObjectPtr<BaseShield> CreateShield(session::Manager::Ptr const&, |
1098 | 53 | indicator::Indicators::Ptr const&, | 53 | menu::Manager::Ptr const&, |
1099 | 54 | Accelerators::Ptr const&, | 54 | Accelerators::Ptr const&, |
1100 | 55 | nux::ObjectPtr<AbstractUserPromptView> const&, | 55 | nux::ObjectPtr<AbstractUserPromptView> const&, |
1101 | 56 | int monitor, bool is_primary) override; | 56 | int monitor, bool is_primary) override; |
1102 | 57 | 57 | ||
1103 | === modified file 'panel/PanelIndicatorEntryView.cpp' | |||
1104 | --- panel/PanelIndicatorEntryView.cpp 2016-02-17 13:14:37 +0000 | |||
1105 | +++ panel/PanelIndicatorEntryView.cpp 2016-08-30 14:38:39 +0000 | |||
1106 | @@ -33,6 +33,8 @@ | |||
1107 | 33 | #include "unity-shared/RawPixel.h" | 33 | #include "unity-shared/RawPixel.h" |
1108 | 34 | #include "unity-shared/WindowManager.h" | 34 | #include "unity-shared/WindowManager.h" |
1109 | 35 | #include "unity-shared/ThemeSettings.h" | 35 | #include "unity-shared/ThemeSettings.h" |
1110 | 36 | #include "unity-shared/UBusWrapper.h" | ||
1111 | 37 | #include "unity-shared/UBusMessages.h" | ||
1112 | 36 | #include "unity-shared/UnitySettings.h" | 38 | #include "unity-shared/UnitySettings.h" |
1113 | 37 | 39 | ||
1114 | 38 | namespace unity | 40 | namespace unity |
1115 | @@ -117,6 +119,9 @@ | |||
1116 | 117 | } | 119 | } |
1117 | 118 | else | 120 | else |
1118 | 119 | { | 121 | { |
1119 | 122 | if (overlay_showing_) | ||
1120 | 123 | UBusManager::SendMessage(UBUS_OVERLAY_CLOSE_REQUEST); | ||
1121 | 124 | |||
1122 | 120 | WindowManager& wm = WindowManager::Default(); | 125 | WindowManager& wm = WindowManager::Default(); |
1123 | 121 | 126 | ||
1124 | 122 | if (wm.IsExpoActive()) | 127 | if (wm.IsExpoActive()) |
1125 | @@ -140,6 +145,11 @@ | |||
1126 | 140 | wm.TerminateScale(); | 145 | wm.TerminateScale(); |
1127 | 141 | } | 146 | } |
1128 | 142 | 147 | ||
1129 | 148 | // This is ugly... But Nux fault! | ||
1130 | 149 | auto const& abs_geo = GetAbsoluteGeometry(); | ||
1131 | 150 | guint64 timestamp = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp; | ||
1132 | 151 | WindowManager::Default().UnGrabMousePointer(timestamp, button, abs_geo.x, abs_geo.y); | ||
1133 | 152 | |||
1134 | 143 | Activate(button); | 153 | Activate(button); |
1135 | 144 | } | 154 | } |
1136 | 145 | } | 155 | } |
1137 | 146 | 156 | ||
1138 | === modified file 'panel/PanelMenuView.cpp' | |||
1139 | --- panel/PanelMenuView.cpp 2015-12-16 15:12:05 +0000 | |||
1140 | +++ panel/PanelMenuView.cpp 2016-08-30 14:38:39 +0000 | |||
1141 | @@ -102,7 +102,6 @@ | |||
1142 | 102 | , ignore_menu_visibility_(false) | 102 | , ignore_menu_visibility_(false) |
1143 | 103 | , integrated_menus_(menu_manager_->integrated_menus()) | 103 | , integrated_menus_(menu_manager_->integrated_menus()) |
1144 | 104 | , always_show_menus_(menu_manager_->always_show_menus()) | 104 | , always_show_menus_(menu_manager_->always_show_menus()) |
1145 | 105 | , ignore_leave_events_(false) | ||
1146 | 106 | , desktop_name_(get_current_desktop()) | 105 | , desktop_name_(get_current_desktop()) |
1147 | 107 | { | 106 | { |
1148 | 108 | if (ApplicationWindowPtr const& win = ApplicationManager::Default().GetActiveWindow()) | 107 | if (ApplicationWindowPtr const& win = ApplicationManager::Default().GetActiveWindow()) |
1149 | @@ -1814,14 +1813,9 @@ | |||
1150 | 1814 | } | 1813 | } |
1151 | 1815 | } | 1814 | } |
1152 | 1816 | 1815 | ||
1153 | 1817 | void PanelMenuView::IgnoreLeaveEvents(bool ignore) | ||
1154 | 1818 | { | ||
1155 | 1819 | ignore_leave_events_ = ignore; | ||
1156 | 1820 | } | ||
1157 | 1821 | |||
1158 | 1822 | void PanelMenuView::OnPanelViewMouseLeave(int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state) | 1816 | void PanelMenuView::OnPanelViewMouseLeave(int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state) |
1159 | 1823 | { | 1817 | { |
1161 | 1824 | if (always_show_menus_ || ignore_leave_events_) | 1818 | if (always_show_menus_) |
1162 | 1825 | return; | 1819 | return; |
1163 | 1826 | 1820 | ||
1164 | 1827 | if (is_inside_) | 1821 | if (is_inside_) |
1165 | 1828 | 1822 | ||
1166 | === modified file 'panel/PanelMenuView.h' | |||
1167 | --- panel/PanelMenuView.h 2015-11-05 14:54:13 +0000 | |||
1168 | +++ panel/PanelMenuView.h 2016-08-30 14:38:39 +0000 | |||
1169 | @@ -56,7 +56,6 @@ | |||
1170 | 56 | bool HasKeyActivableMenus() const; | 56 | bool HasKeyActivableMenus() const; |
1171 | 57 | 57 | ||
1172 | 58 | void NotifyAllMenusClosed(); | 58 | void NotifyAllMenusClosed(); |
1173 | 59 | void IgnoreLeaveEvents(bool); | ||
1174 | 60 | 59 | ||
1175 | 61 | virtual void AddIndicator(indicator::Indicator::Ptr const& indicator); | 60 | virtual void AddIndicator(indicator::Indicator::Ptr const& indicator); |
1176 | 62 | 61 | ||
1177 | @@ -192,7 +191,6 @@ | |||
1178 | 192 | bool ignore_menu_visibility_; | 191 | bool ignore_menu_visibility_; |
1179 | 193 | bool integrated_menus_; | 192 | bool integrated_menus_; |
1180 | 194 | bool always_show_menus_; | 193 | bool always_show_menus_; |
1181 | 195 | bool ignore_leave_events_; | ||
1182 | 196 | 194 | ||
1183 | 197 | nux::Geometry monitor_geo_; | 195 | nux::Geometry monitor_geo_; |
1184 | 198 | const std::string desktop_name_; | 196 | const std::string desktop_name_; |
1185 | 199 | 197 | ||
1186 | === modified file 'panel/PanelView.cpp' | |||
1187 | --- panel/PanelView.cpp 2016-08-12 13:57:19 +0000 | |||
1188 | +++ panel/PanelView.cpp 2016-08-30 14:38:39 +0000 | |||
1189 | @@ -42,7 +42,8 @@ | |||
1190 | 42 | namespace | 42 | namespace |
1191 | 43 | { | 43 | { |
1192 | 44 | const RawPixel TRIANGLE_THRESHOLD = 5_em; | 44 | const RawPixel TRIANGLE_THRESHOLD = 5_em; |
1194 | 45 | const int refine_gradient_midpoint = 959; | 45 | const double SCRUB_VELOCITY_THRESHOLD = 0.05; |
1195 | 46 | const RawPixel REFINE_GRADIENT_MIDPOINT = 959; | ||
1196 | 46 | } | 47 | } |
1197 | 47 | 48 | ||
1198 | 48 | 49 | ||
1199 | @@ -113,10 +114,9 @@ | |||
1200 | 113 | 114 | ||
1201 | 114 | remote_->on_object_added.connect(sigc::mem_fun(this, &PanelView::OnObjectAdded)); | 115 | remote_->on_object_added.connect(sigc::mem_fun(this, &PanelView::OnObjectAdded)); |
1202 | 115 | remote_->on_object_removed.connect(sigc::mem_fun(this, &PanelView::OnObjectRemoved)); | 116 | remote_->on_object_removed.connect(sigc::mem_fun(this, &PanelView::OnObjectRemoved)); |
1203 | 116 | remote_->on_entry_activated.connect(sigc::mem_fun(this, &PanelView::OnEntryActivated)); | ||
1204 | 117 | remote_->on_entry_show_menu.connect(sigc::mem_fun(this, &PanelView::OnEntryShowMenu)); | ||
1205 | 118 | menus->key_activate_entry.connect(sigc::mem_fun(this, &PanelView::ActivateEntry)); | 117 | menus->key_activate_entry.connect(sigc::mem_fun(this, &PanelView::ActivateEntry)); |
1206 | 119 | menus->open_first.connect(sigc::mem_fun(this, &PanelView::ActivateFirstSensitive)); | 118 | menus->open_first.connect(sigc::mem_fun(this, &PanelView::ActivateFirstSensitive)); |
1207 | 119 | menus->RegisterTracker(GetPanelName(), sigc::mem_fun(this, &PanelView::OnMenuPointerMoved)); | ||
1208 | 120 | 120 | ||
1209 | 121 | ubus_manager_.RegisterInterest(UBUS_OVERLAY_HIDDEN, sigc::mem_fun(this, &PanelView::OnOverlayHidden)); | 121 | ubus_manager_.RegisterInterest(UBUS_OVERLAY_HIDDEN, sigc::mem_fun(this, &PanelView::OnOverlayHidden)); |
1210 | 122 | ubus_manager_.RegisterInterest(UBUS_OVERLAY_SHOWN, sigc::mem_fun(this, &PanelView::OnOverlayShown)); | 122 | ubus_manager_.RegisterInterest(UBUS_OVERLAY_SHOWN, sigc::mem_fun(this, &PanelView::OnOverlayShown)); |
1211 | @@ -374,7 +374,7 @@ | |||
1212 | 374 | GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); | 374 | GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
1213 | 375 | nux::TexCoordXForm refine_texxform; | 375 | nux::TexCoordXForm refine_texxform; |
1214 | 376 | 376 | ||
1216 | 377 | int refine_x_pos = geo.x + (stored_dash_width_ - refine_gradient_midpoint); | 377 | int refine_x_pos = geo.x + (stored_dash_width_ - REFINE_GRADIENT_MIDPOINT.CP(Settings::Instance().em(monitor_))); |
1217 | 378 | 378 | ||
1218 | 379 | if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) | 379 | if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) |
1219 | 380 | refine_x_pos += unity::Settings::Instance().LauncherSize(monitor_); | 380 | refine_x_pos += unity::Settings::Instance().LauncherSize(monitor_); |
1220 | @@ -473,7 +473,7 @@ | |||
1221 | 473 | 473 | ||
1222 | 474 | nux::Geometry refine_geo = geo; | 474 | nux::Geometry refine_geo = geo; |
1223 | 475 | 475 | ||
1225 | 476 | int refine_x_pos = geo.x + (stored_dash_width_ - refine_gradient_midpoint); | 476 | int refine_x_pos = geo.x + (stored_dash_width_ - REFINE_GRADIENT_MIDPOINT.CP(Settings::Instance().em(monitor_))); |
1226 | 477 | if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) | 477 | if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) |
1227 | 478 | refine_x_pos += unity::Settings::Instance().LauncherSize(monitor_); | 478 | refine_x_pos += unity::Settings::Instance().LauncherSize(monitor_); |
1228 | 479 | 479 | ||
1229 | @@ -627,7 +627,7 @@ | |||
1230 | 627 | QueueDraw(); | 627 | QueueDraw(); |
1231 | 628 | } | 628 | } |
1232 | 629 | 629 | ||
1234 | 630 | void PanelView::OnMenuPointerMoved(int x, int y) | 630 | void PanelView::OnMenuPointerMoved(int x, int y, double speed) |
1235 | 631 | { | 631 | { |
1236 | 632 | nux::Geometry const& geo = GetAbsoluteGeometry(); | 632 | nux::Geometry const& geo = GetAbsoluteGeometry(); |
1237 | 633 | 633 | ||
1238 | @@ -648,116 +648,6 @@ | |||
1239 | 648 | } | 648 | } |
1240 | 649 | } | 649 | } |
1241 | 650 | 650 | ||
1242 | 651 | static bool PointInTriangle(nux::Point const& p, nux::Point const& t0, nux::Point const& t1, nux::Point const& t2) | ||
1243 | 652 | { | ||
1244 | 653 | int s = t0.y * t2.x - t0.x * t2.y + (t2.y - t0.y) * p.x + (t0.x - t2.x) * p.y; | ||
1245 | 654 | int t = t0.x * t1.y - t0.y * t1.x + (t0.y - t1.y) * p.x + (t1.x - t0.x) * p.y; | ||
1246 | 655 | |||
1247 | 656 | if ((s < 0) != (t < 0)) | ||
1248 | 657 | return false; | ||
1249 | 658 | |||
1250 | 659 | int A = -t1.y * t2.x + t0.y * (t2.x - t1.x) + t0.x * (t1.y - t2.y) + t1.x * t2.y; | ||
1251 | 660 | if (A < 0) | ||
1252 | 661 | { | ||
1253 | 662 | s = -s; | ||
1254 | 663 | t = -t; | ||
1255 | 664 | A = -A; | ||
1256 | 665 | } | ||
1257 | 666 | |||
1258 | 667 | return s > 0 && t > 0 && (s + t) < A; | ||
1259 | 668 | } | ||
1260 | 669 | |||
1261 | 670 | static double GetMouseVelocity(nux::Point const& p0, nux::Point const& p1, util::Timer &timer) | ||
1262 | 671 | { | ||
1263 | 672 | int dx, dy; | ||
1264 | 673 | double speed; | ||
1265 | 674 | auto millis = timer.ElapsedMicroSeconds(); | ||
1266 | 675 | |||
1267 | 676 | if (millis == 0) | ||
1268 | 677 | return 1; | ||
1269 | 678 | |||
1270 | 679 | dx = p0.x - p1.x; | ||
1271 | 680 | dy = p0.y - p1.y; | ||
1272 | 681 | |||
1273 | 682 | speed = sqrt(dx * dx + dy * dy) / millis * 1000; | ||
1274 | 683 | |||
1275 | 684 | return speed; | ||
1276 | 685 | } | ||
1277 | 686 | |||
1278 | 687 | bool PanelView::TrackMenuPointer() | ||
1279 | 688 | { | ||
1280 | 689 | nux::Point const& mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord(); | ||
1281 | 690 | double speed = GetMouseVelocity(mouse, tracked_pointer_pos_, mouse_tracker_timer_); | ||
1282 | 691 | |||
1283 | 692 | mouse_tracker_timer_.Reset(); | ||
1284 | 693 | tracked_pointer_pos_ = mouse; | ||
1285 | 694 | |||
1286 | 695 | double scale = Settings::Instance().em(monitor_)->DPIScale(); | ||
1287 | 696 | if (speed > 0 && PointInTriangle(mouse, | ||
1288 | 697 | nux::Point(triangle_top_corner_.x, std::max(triangle_top_corner_.y - TRIANGLE_THRESHOLD.CP(scale), 0)), | ||
1289 | 698 | nux::Point(menu_geo_.x, menu_geo_.y), | ||
1290 | 699 | nux::Point(menu_geo_.x + menu_geo_.width, menu_geo_.y))) | ||
1291 | 700 | { | ||
1292 | 701 | return true; | ||
1293 | 702 | } | ||
1294 | 703 | |||
1295 | 704 | if (mouse != triangle_top_corner_) | ||
1296 | 705 | { | ||
1297 | 706 | triangle_top_corner_ = mouse; | ||
1298 | 707 | OnMenuPointerMoved(mouse.x, mouse.y); | ||
1299 | 708 | } | ||
1300 | 709 | |||
1301 | 710 | return true; | ||
1302 | 711 | } | ||
1303 | 712 | |||
1304 | 713 | void PanelView::OnEntryActivated(std::string const& panel, std::string const& entry_id, nux::Rect const& menu_geo) | ||
1305 | 714 | { | ||
1306 | 715 | if (!panel.empty() && panel != GetPanelName()) | ||
1307 | 716 | return; | ||
1308 | 717 | |||
1309 | 718 | menu_geo_ = menu_geo; | ||
1310 | 719 | |||
1311 | 720 | bool active = !entry_id.empty(); | ||
1312 | 721 | if (active && !track_menu_pointer_timeout_) | ||
1313 | 722 | { | ||
1314 | 723 | // | ||
1315 | 724 | // Track menus being scrubbed at 60Hz (about every 16 millisec) | ||
1316 | 725 | // It might sound ugly, but it's far nicer (and more responsive) than the | ||
1317 | 726 | // code it replaces which used to capture motion events in another process | ||
1318 | 727 | // (unity-panel-service) and send them to us over dbus. | ||
1319 | 728 | // NOTE: The reason why we have to use a timer instead of tracking motion | ||
1320 | 729 | // events is because the motion events will never be delivered to this | ||
1321 | 730 | // process. All the motion events will go to unity-panel-service while | ||
1322 | 731 | // scrubbing because the active panel menu has (needs) the pointer grab. | ||
1323 | 732 | // | ||
1324 | 733 | mouse_tracker_timer_.Reset(); | ||
1325 | 734 | triangle_top_corner_ = nux::GetGraphicsDisplay()->GetMouseScreenCoord(); | ||
1326 | 735 | track_menu_pointer_timeout_.reset(new glib::Timeout(16)); | ||
1327 | 736 | track_menu_pointer_timeout_->Run(sigc::mem_fun(this, &PanelView::TrackMenuPointer)); | ||
1328 | 737 | } | ||
1329 | 738 | else if (!active) | ||
1330 | 739 | { | ||
1331 | 740 | track_menu_pointer_timeout_.reset(); | ||
1332 | 741 | menu_view_->NotifyAllMenusClosed(); | ||
1333 | 742 | tracked_pointer_pos_ = {-1, -1}; | ||
1334 | 743 | } | ||
1335 | 744 | |||
1336 | 745 | if (overlay_is_open_) | ||
1337 | 746 | ubus_manager_.SendMessage(UBUS_OVERLAY_CLOSE_REQUEST); | ||
1338 | 747 | } | ||
1339 | 748 | |||
1340 | 749 | void PanelView::OnEntryShowMenu(std::string const& entry_id, unsigned xid, | ||
1341 | 750 | int x, int y, unsigned button) | ||
1342 | 751 | { | ||
1343 | 752 | if (!track_menu_pointer_timeout_) | ||
1344 | 753 | { | ||
1345 | 754 | // This is ugly... But Nux fault! | ||
1346 | 755 | menu_view_->IgnoreLeaveEvents(true); | ||
1347 | 756 | WindowManager::Default().UnGrabMousePointer(CurrentTime, button, x, y); | ||
1348 | 757 | menu_view_->IgnoreLeaveEvents(false); | ||
1349 | 758 | } | ||
1350 | 759 | } | ||
1351 | 760 | |||
1352 | 761 | bool PanelView::ActivateFirstSensitive() | 651 | bool PanelView::ActivateFirstSensitive() |
1353 | 762 | { | 652 | { |
1354 | 763 | if (!IsActive()) | 653 | if (!IsActive()) |
1355 | @@ -768,7 +658,6 @@ | |||
1356 | 768 | { | 658 | { |
1357 | 769 | // Since this only happens on keyboard events, we need to prevent that the | 659 | // Since this only happens on keyboard events, we need to prevent that the |
1358 | 770 | // pointer tracker would select another entry. | 660 | // pointer tracker would select another entry. |
1359 | 771 | tracked_pointer_pos_ = nux::GetGraphicsDisplay()->GetMouseScreenCoord(); | ||
1360 | 772 | return true; | 661 | return true; |
1361 | 773 | } | 662 | } |
1362 | 774 | 663 | ||
1363 | @@ -785,7 +674,6 @@ | |||
1364 | 785 | { | 674 | { |
1365 | 786 | // Since this only happens on keyboard events, we need to prevent that the | 675 | // Since this only happens on keyboard events, we need to prevent that the |
1366 | 787 | // pointer tracker would select another entry. | 676 | // pointer tracker would select another entry. |
1367 | 788 | tracked_pointer_pos_ = nux::GetGraphicsDisplay()->GetMouseScreenCoord(); | ||
1368 | 789 | return true; | 677 | return true; |
1369 | 790 | } | 678 | } |
1370 | 791 | 679 | ||
1371 | 792 | 680 | ||
1372 | === modified file 'panel/PanelView.h' | |||
1373 | --- panel/PanelView.h 2016-03-30 18:18:07 +0000 | |||
1374 | +++ panel/PanelView.h 2016-08-30 14:38:39 +0000 | |||
1375 | @@ -35,7 +35,6 @@ | |||
1376 | 35 | #include "unity-shared/Introspectable.h" | 35 | #include "unity-shared/Introspectable.h" |
1377 | 36 | #include "unity-shared/MenuManager.h" | 36 | #include "unity-shared/MenuManager.h" |
1378 | 37 | #include "unity-shared/MockableBaseWindow.h" | 37 | #include "unity-shared/MockableBaseWindow.h" |
1379 | 38 | #include "unity-shared/Timer.h" | ||
1380 | 39 | #include "PanelMenuView.h" | 38 | #include "PanelMenuView.h" |
1381 | 40 | #include "PanelTray.h" | 39 | #include "PanelTray.h" |
1382 | 41 | #include "PanelIndicatorsView.h" | 40 | #include "PanelIndicatorsView.h" |
1383 | @@ -88,9 +87,6 @@ | |||
1384 | 88 | void OnObjectAdded(indicator::Indicator::Ptr const& proxy); | 87 | void OnObjectAdded(indicator::Indicator::Ptr const& proxy); |
1385 | 89 | void OnObjectRemoved(indicator::Indicator::Ptr const& proxy); | 88 | void OnObjectRemoved(indicator::Indicator::Ptr const& proxy); |
1386 | 90 | void OnIndicatorViewUpdated(); | 89 | void OnIndicatorViewUpdated(); |
1387 | 91 | void OnMenuPointerMoved(int x, int y); | ||
1388 | 92 | void OnEntryActivated(std::string const& panel, std::string const& entry_id, nux::Rect const& geo); | ||
1389 | 93 | void OnEntryShowMenu(std::string const& entry_id, unsigned xid, int x, int y, unsigned button); | ||
1390 | 94 | 90 | ||
1391 | 95 | private: | 91 | private: |
1392 | 96 | std::string GetPanelName() const; | 92 | std::string GetPanelName() const; |
1393 | @@ -100,6 +96,8 @@ | |||
1394 | 100 | void OnSpreadInitiate(); | 96 | void OnSpreadInitiate(); |
1395 | 101 | void OnSpreadTerminate(); | 97 | void OnSpreadTerminate(); |
1396 | 102 | void OnLowGfxChanged(); | 98 | void OnLowGfxChanged(); |
1397 | 99 | void OnMenuPointerMoved(int x, int y, double speed); | ||
1398 | 100 | void OnActiveEntryEvent(XEvent const&); | ||
1399 | 103 | void EnableOverlayMode(bool); | 101 | void EnableOverlayMode(bool); |
1400 | 104 | void LoadTextures(); | 102 | void LoadTextures(); |
1401 | 105 | 103 | ||
1402 | @@ -109,7 +107,6 @@ | |||
1403 | 109 | bool IsTransparent(); | 107 | bool IsTransparent(); |
1404 | 110 | void UpdateBackground(); | 108 | void UpdateBackground(); |
1405 | 111 | void ForceUpdateBackground(); | 109 | void ForceUpdateBackground(); |
1406 | 112 | bool TrackMenuPointer(); | ||
1407 | 113 | void SyncGeometries(); | 110 | void SyncGeometries(); |
1408 | 114 | void AddPanelView(PanelIndicatorsView* child, unsigned int stretchFactor); | 111 | void AddPanelView(PanelIndicatorsView* child, unsigned int stretchFactor); |
1409 | 115 | 112 | ||
1410 | @@ -133,10 +130,6 @@ | |||
1411 | 133 | BaseTexturePtr bg_refine_single_column_tex_; | 130 | BaseTexturePtr bg_refine_single_column_tex_; |
1412 | 134 | std::unique_ptr<nux::AbstractPaintLayer> bg_refine_single_column_layer_; | 131 | std::unique_ptr<nux::AbstractPaintLayer> bg_refine_single_column_layer_; |
1413 | 135 | 132 | ||
1414 | 136 | std::string active_overlay_; | ||
1415 | 137 | nux::Point tracked_pointer_pos_, triangle_top_corner_; | ||
1416 | 138 | util::Timer mouse_tracker_timer_; | ||
1417 | 139 | |||
1418 | 140 | bool is_dirty_; | 133 | bool is_dirty_; |
1419 | 141 | bool opacity_maximized_toggle_; | 134 | bool opacity_maximized_toggle_; |
1420 | 142 | bool needs_geo_sync_; | 135 | bool needs_geo_sync_; |
1421 | @@ -144,15 +137,13 @@ | |||
1422 | 144 | float opacity_; | 137 | float opacity_; |
1423 | 145 | int monitor_; | 138 | int monitor_; |
1424 | 146 | int stored_dash_width_; | 139 | int stored_dash_width_; |
1427 | 147 | 140 | std::string active_overlay_; | |
1426 | 148 | nux::Geometry menu_geo_; | ||
1428 | 149 | 141 | ||
1429 | 150 | connection::Manager on_indicator_updated_connections_; | 142 | connection::Manager on_indicator_updated_connections_; |
1430 | 151 | connection::Manager maximized_opacity_toggle_connections_; | 143 | connection::Manager maximized_opacity_toggle_connections_; |
1431 | 152 | BackgroundEffectHelper bg_effect_helper_; | 144 | BackgroundEffectHelper bg_effect_helper_; |
1432 | 153 | nux::ObjectPtr<nux::IOpenGLBaseTexture> bg_blur_texture_; | 145 | nux::ObjectPtr<nux::IOpenGLBaseTexture> bg_blur_texture_; |
1433 | 154 | UBusManager ubus_manager_; | 146 | UBusManager ubus_manager_; |
1434 | 155 | glib::Source::UniquePtr track_menu_pointer_timeout_; | ||
1435 | 156 | }; | 147 | }; |
1436 | 157 | 148 | ||
1437 | 158 | } // namespace panel | 149 | } // namespace panel |
1438 | 159 | 150 | ||
1439 | === modified file 'plugins/unityshell/src/unityshell.h' | |||
1440 | --- plugins/unityshell/src/unityshell.h 2016-08-12 11:21:48 +0000 | |||
1441 | +++ plugins/unityshell/src/unityshell.h 2016-08-30 14:38:39 +0000 | |||
1442 | @@ -56,6 +56,7 @@ | |||
1443 | 56 | #include "DashStyle.h" | 56 | #include "DashStyle.h" |
1444 | 57 | #include "EdgeBarrierController.h" | 57 | #include "EdgeBarrierController.h" |
1445 | 58 | #include "FavoriteStoreGSettings.h" | 58 | #include "FavoriteStoreGSettings.h" |
1446 | 59 | #include "InputMonitor.h" | ||
1447 | 59 | #include "ShortcutController.h" | 60 | #include "ShortcutController.h" |
1448 | 60 | #include "LauncherController.h" | 61 | #include "LauncherController.h" |
1449 | 61 | #include "LockScreenController.h" | 62 | #include "LockScreenController.h" |
1450 | @@ -317,6 +318,7 @@ | |||
1451 | 317 | internal::FavoriteStoreGSettings favorite_store_; | 318 | internal::FavoriteStoreGSettings favorite_store_; |
1452 | 318 | ThumbnailGenerator thumbnail_generator_; | 319 | ThumbnailGenerator thumbnail_generator_; |
1453 | 319 | lockscreen::Settings lockscreen_settings_; | 320 | lockscreen::Settings lockscreen_settings_; |
1454 | 321 | input::Monitor input_monitor_; | ||
1455 | 320 | 322 | ||
1456 | 321 | /* The window thread should be the last thing removed, as c++ does it in reverse order */ | 323 | /* The window thread should be the last thing removed, as c++ does it in reverse order */ |
1457 | 322 | std::unique_ptr<nux::WindowThread> wt; | 324 | std::unique_ptr<nux::WindowThread> wt; |
1458 | 323 | 325 | ||
1459 | === modified file 'services/CMakeLists.txt' | |||
1460 | --- services/CMakeLists.txt 2016-02-09 01:26:22 +0000 | |||
1461 | +++ services/CMakeLists.txt 2016-08-30 14:38:39 +0000 | |||
1462 | @@ -58,3 +58,34 @@ | |||
1463 | 58 | 58 | ||
1464 | 59 | configure_file(unity-panel-service-lockscreen.conf.in ${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.conf) | 59 | configure_file(unity-panel-service-lockscreen.conf.in ${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.conf) |
1465 | 60 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.conf DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/sessions) | 60 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.conf DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/sessions) |
1466 | 61 | |||
1467 | 62 | ## | ||
1468 | 63 | ## Systemd Unit Files | ||
1469 | 64 | ## | ||
1470 | 65 | |||
1471 | 66 | # where to install | ||
1472 | 67 | # Uncomment when we drop Vivid | ||
1473 | 68 | # pkg_get_variable(SYSTEMD_USER_DIR systemd systemduserunitdir) | ||
1474 | 69 | set (SYSTEMD_USER_DIR "/usr/lib/systemd/user") | ||
1475 | 70 | message (STATUS "${SYSTEMD_USER_DIR} is the systemd user unit file install dir") | ||
1476 | 71 | |||
1477 | 72 | configure_file (unity-panel-service.service.in "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service.service") | ||
1478 | 73 | configure_file (unity-panel-service-lockscreen.service.in "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.service") | ||
1479 | 74 | |||
1480 | 75 | install( FILES | ||
1481 | 76 | "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service.service" | ||
1482 | 77 | "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.service" | ||
1483 | 78 | "${CMAKE_CURRENT_SOURCE_DIR}/unity-screen-locked.target" | ||
1484 | 79 | DESTINATION "${SYSTEMD_USER_DIR}") | ||
1485 | 80 | |||
1486 | 81 | ## | ||
1487 | 82 | ## Upstart systemd override Job File | ||
1488 | 83 | ## | ||
1489 | 84 | |||
1490 | 85 | set (UPSTART_SYSTEMD_OVERRIDE_DIR "${CMAKE_INSTALL_FULL_DATADIR}/upstart/systemd-session/upstart") | ||
1491 | 86 | message (STATUS "${UPSTART_SYSTEMD_OVERRIDE_DIR} is the Upstart override Job File for systemd dir") | ||
1492 | 87 | |||
1493 | 88 | install (FILES | ||
1494 | 89 | unity-panel-service.override | ||
1495 | 90 | unity-panel-service-lockscreen.override | ||
1496 | 91 | DESTINATION "${UPSTART_SYSTEMD_OVERRIDE_DIR}") | ||
1497 | 61 | 92 | ||
1498 | === added file 'services/unity-panel-service-lockscreen.override' | |||
1499 | --- services/unity-panel-service-lockscreen.override 1970-01-01 00:00:00 +0000 | |||
1500 | +++ services/unity-panel-service-lockscreen.override 2016-08-30 14:38:39 +0000 | |||
1501 | @@ -0,0 +1,1 @@ | |||
1502 | 1 | manual | ||
1503 | 0 | 2 | ||
1504 | === added file 'services/unity-panel-service-lockscreen.service.in' | |||
1505 | --- services/unity-panel-service-lockscreen.service.in 1970-01-01 00:00:00 +0000 | |||
1506 | +++ services/unity-panel-service-lockscreen.service.in 2016-08-30 14:38:39 +0000 | |||
1507 | @@ -0,0 +1,7 @@ | |||
1508 | 1 | [Unit] | ||
1509 | 2 | Description=Backing Service for the Unity Panel in Lockscreen mode | ||
1510 | 3 | PartOf=unity-screen-locked.target | ||
1511 | 4 | |||
1512 | 5 | [Service] | ||
1513 | 6 | ExecStart=${CMAKE_INSTALL_FULL_LIBDIR}/unity/unity-panel-service --lockscreen-mode | ||
1514 | 7 | Restart=on-failure | ||
1515 | 0 | 8 | ||
1516 | === added file 'services/unity-panel-service.override' | |||
1517 | --- services/unity-panel-service.override 1970-01-01 00:00:00 +0000 | |||
1518 | +++ services/unity-panel-service.override 2016-08-30 14:38:39 +0000 | |||
1519 | @@ -0,0 +1,1 @@ | |||
1520 | 1 | manual | ||
1521 | 0 | 2 | ||
1522 | === added file 'services/unity-panel-service.service.in' | |||
1523 | --- services/unity-panel-service.service.in 1970-01-01 00:00:00 +0000 | |||
1524 | +++ services/unity-panel-service.service.in 2016-08-30 14:38:39 +0000 | |||
1525 | @@ -0,0 +1,9 @@ | |||
1526 | 1 | [Unit] | ||
1527 | 2 | Description=Backing Service for the Unity Panel | ||
1528 | 3 | After=unity7.service | ||
1529 | 4 | PartOf=graphical-session.target | ||
1530 | 5 | BindsTo=indicators-pre.target | ||
1531 | 6 | |||
1532 | 7 | [Service] | ||
1533 | 8 | ExecStart=${CMAKE_INSTALL_FULL_LIBDIR}/unity/unity-panel-service | ||
1534 | 9 | Restart=on-failure | ||
1535 | 0 | 10 | ||
1536 | === added file 'services/unity-screen-locked.target' | |||
1537 | --- services/unity-screen-locked.target 1970-01-01 00:00:00 +0000 | |||
1538 | +++ services/unity-screen-locked.target 2016-08-30 14:38:39 +0000 | |||
1539 | @@ -0,0 +1,4 @@ | |||
1540 | 1 | [Unit] | ||
1541 | 2 | Description=A target that, when running, represents the screen being locked | ||
1542 | 3 | Wants=ubuntu-panel-service-lock.service | ||
1543 | 4 | PartOf=graphical-session.target | ||
1544 | 0 | 5 | ||
1545 | === modified file 'tests/CMakeLists.txt' | |||
1546 | --- tests/CMakeLists.txt 2015-12-17 22:32:37 +0000 | |||
1547 | +++ tests/CMakeLists.txt 2016-08-30 14:38:39 +0000 | |||
1548 | @@ -286,6 +286,7 @@ | |||
1549 | 286 | test_switcher_controller_class.cpp | 286 | test_switcher_controller_class.cpp |
1550 | 287 | test_switcher_model.cpp | 287 | test_switcher_model.cpp |
1551 | 288 | test_switcher_view.cpp | 288 | test_switcher_view.cpp |
1552 | 289 | test_systemd_wrapper.cpp | ||
1553 | 289 | test_tabiterator.cpp | 290 | test_tabiterator.cpp |
1554 | 290 | test_texture_cache.cpp | 291 | test_texture_cache.cpp |
1555 | 291 | test_text_input.cpp | 292 | test_text_input.cpp |
1556 | 292 | 293 | ||
1557 | === modified file 'tests/test_edge_barrier_controller.cpp' | |||
1558 | --- tests/test_edge_barrier_controller.cpp 2015-01-15 15:02:24 +0000 | |||
1559 | +++ tests/test_edge_barrier_controller.cpp 2016-08-30 14:38:39 +0000 | |||
1560 | @@ -25,6 +25,7 @@ | |||
1561 | 25 | 25 | ||
1562 | 26 | #include "EdgeBarrierController.h" | 26 | #include "EdgeBarrierController.h" |
1563 | 27 | #include "EdgeBarrierControllerPrivate.h" | 27 | #include "EdgeBarrierControllerPrivate.h" |
1564 | 28 | #include "InputMonitor.h" | ||
1565 | 28 | 29 | ||
1566 | 29 | using namespace unity; | 30 | using namespace unity; |
1567 | 30 | using namespace unity::ui; | 31 | using namespace unity::ui; |
1568 | @@ -108,6 +109,7 @@ | |||
1569 | 108 | 109 | ||
1570 | 109 | TestBarrierSubscriber horizontal_subscribers_[monitors::MAX]; | 110 | TestBarrierSubscriber horizontal_subscribers_[monitors::MAX]; |
1571 | 110 | TestBarrierSubscriber vertical_subscribers_[monitors::MAX]; | 111 | TestBarrierSubscriber vertical_subscribers_[monitors::MAX]; |
1572 | 112 | input::Monitor im; | ||
1573 | 111 | MockUScreen uscreen; | 113 | MockUScreen uscreen; |
1574 | 112 | EdgeBarrierController bc; | 114 | EdgeBarrierController bc; |
1575 | 113 | }; | 115 | }; |
1576 | 114 | 116 | ||
1577 | === modified file 'tests/test_lockscreen_controller.cpp' | |||
1578 | --- tests/test_lockscreen_controller.cpp 2016-06-21 14:40:26 +0000 | |||
1579 | +++ tests/test_lockscreen_controller.cpp 2016-08-30 14:38:39 +0000 | |||
1580 | @@ -55,7 +55,7 @@ | |||
1581 | 55 | struct MockShield : BaseShield | 55 | struct MockShield : BaseShield |
1582 | 56 | { | 56 | { |
1583 | 57 | MockShield() | 57 | MockShield() |
1585 | 58 | : BaseShield(nullptr, nullptr, nullptr, nux::ObjectPtr<AbstractUserPromptView>(), 0, false) | 58 | : BaseShield(nullptr, nullptr, nux::ObjectPtr<AbstractUserPromptView>(), 0, false) |
1586 | 59 | {} | 59 | {} |
1587 | 60 | 60 | ||
1588 | 61 | MOCK_CONST_METHOD0(IsIndicatorOpen, bool()); | 61 | MOCK_CONST_METHOD0(IsIndicatorOpen, bool()); |
1589 | @@ -67,7 +67,7 @@ | |||
1590 | 67 | struct ShieldFactoryMock : ShieldFactoryInterface | 67 | struct ShieldFactoryMock : ShieldFactoryInterface |
1591 | 68 | { | 68 | { |
1592 | 69 | nux::ObjectPtr<BaseShield> CreateShield(session::Manager::Ptr const&, | 69 | nux::ObjectPtr<BaseShield> CreateShield(session::Manager::Ptr const&, |
1594 | 70 | indicator::Indicators::Ptr const&, | 70 | menu::Manager::Ptr const&, |
1595 | 71 | Accelerators::Ptr const&, | 71 | Accelerators::Ptr const&, |
1596 | 72 | nux::ObjectPtr<AbstractUserPromptView> const&, | 72 | nux::ObjectPtr<AbstractUserPromptView> const&, |
1597 | 73 | int, bool) override | 73 | int, bool) override |
1598 | @@ -83,9 +83,10 @@ | |||
1599 | 83 | , session_manager(std::make_shared<NiceMock<session::MockManager>>()) | 83 | , session_manager(std::make_shared<NiceMock<session::MockManager>>()) |
1600 | 84 | , key_grabber(std::make_shared<key::MockGrabber::Nice>()) | 84 | , key_grabber(std::make_shared<key::MockGrabber::Nice>()) |
1601 | 85 | , dbus_manager(std::make_shared<DBusManager>(session_manager)) | 85 | , dbus_manager(std::make_shared<DBusManager>(session_manager)) |
1602 | 86 | , systemd_wrapper(std::make_shared<SystemdWrapper>()) | ||
1603 | 86 | , upstart_wrapper(std::make_shared<UpstartWrapper>()) | 87 | , upstart_wrapper(std::make_shared<UpstartWrapper>()) |
1604 | 87 | , shield_factory(std::make_shared<ShieldFactoryMock>()) | 88 | , shield_factory(std::make_shared<ShieldFactoryMock>()) |
1606 | 88 | , controller(dbus_manager, session_manager, key_grabber, upstart_wrapper, shield_factory) | 89 | , controller(dbus_manager, session_manager, key_grabber, systemd_wrapper, upstart_wrapper, shield_factory) |
1607 | 89 | {} | 90 | {} |
1608 | 90 | 91 | ||
1609 | 91 | struct ControllerWrap : Controller | 92 | struct ControllerWrap : Controller |
1610 | @@ -93,9 +94,10 @@ | |||
1611 | 93 | ControllerWrap(DBusManager::Ptr const& dbus_manager, | 94 | ControllerWrap(DBusManager::Ptr const& dbus_manager, |
1612 | 94 | session::Manager::Ptr const& session_manager, | 95 | session::Manager::Ptr const& session_manager, |
1613 | 95 | key::Grabber::Ptr const& key_grabber, | 96 | key::Grabber::Ptr const& key_grabber, |
1614 | 97 | SystemdWrapper::Ptr const& systemd_wrapper, | ||
1615 | 96 | UpstartWrapper::Ptr const& upstart_wrapper, | 98 | UpstartWrapper::Ptr const& upstart_wrapper, |
1616 | 97 | ShieldFactoryInterface::Ptr const& shield_factory) | 99 | ShieldFactoryInterface::Ptr const& shield_factory) |
1618 | 98 | : Controller(dbus_manager, session_manager, key_grabber, upstart_wrapper, shield_factory, /* test_mode */ true) | 100 | : Controller(dbus_manager, session_manager, key_grabber, systemd_wrapper, upstart_wrapper, shield_factory, /* test_mode */ true) |
1619 | 99 | {} | 101 | {} |
1620 | 100 | 102 | ||
1621 | 101 | using Controller::shields_; | 103 | using Controller::shields_; |
1622 | @@ -112,6 +114,7 @@ | |||
1623 | 112 | session::MockManager::Ptr session_manager; | 114 | session::MockManager::Ptr session_manager; |
1624 | 113 | key::MockGrabber::Ptr key_grabber; | 115 | key::MockGrabber::Ptr key_grabber; |
1625 | 114 | DBusManager::Ptr dbus_manager; | 116 | DBusManager::Ptr dbus_manager; |
1626 | 117 | unity::SystemdWrapper::Ptr systemd_wrapper; | ||
1627 | 115 | unity::UpstartWrapper::Ptr upstart_wrapper; | 118 | unity::UpstartWrapper::Ptr upstart_wrapper; |
1628 | 116 | 119 | ||
1629 | 117 | ShieldFactoryMock::Ptr shield_factory; | 120 | ShieldFactoryMock::Ptr shield_factory; |
1630 | 118 | 121 | ||
1631 | === modified file 'tests/test_panel_controller.cpp' | |||
1632 | --- tests/test_panel_controller.cpp 2014-03-21 04:40:12 +0000 | |||
1633 | +++ tests/test_panel_controller.cpp 2016-08-30 14:38:39 +0000 | |||
1634 | @@ -19,6 +19,7 @@ | |||
1635 | 19 | 19 | ||
1636 | 20 | #include <gmock/gmock.h> | 20 | #include <gmock/gmock.h> |
1637 | 21 | 21 | ||
1638 | 22 | #include "InputMonitor.h" | ||
1639 | 22 | #include "PanelController.h" | 23 | #include "PanelController.h" |
1640 | 23 | #include "PanelStyle.h" | 24 | #include "PanelStyle.h" |
1641 | 24 | #include "PanelView.h" | 25 | #include "PanelView.h" |
1642 | @@ -46,6 +47,7 @@ | |||
1643 | 46 | menu::MockManager::Ptr menus; | 47 | menu::MockManager::Ptr menus; |
1644 | 47 | ui::EdgeBarrierController::Ptr edge_barriers; | 48 | ui::EdgeBarrierController::Ptr edge_barriers; |
1645 | 48 | launcher::Options::Ptr options; | 49 | launcher::Options::Ptr options; |
1646 | 50 | input::Monitor im; | ||
1647 | 49 | }; | 51 | }; |
1648 | 50 | 52 | ||
1649 | 51 | TEST_F(TestPanelController, Construction) | 53 | TEST_F(TestPanelController, Construction) |
1650 | 52 | 54 | ||
1651 | === modified file 'tests/test_panel_view.cpp' | |||
1652 | --- tests/test_panel_view.cpp 2014-12-12 22:33:24 +0000 | |||
1653 | +++ tests/test_panel_view.cpp 2016-08-30 14:38:39 +0000 | |||
1654 | @@ -25,6 +25,7 @@ | |||
1655 | 25 | #include "unity-shared/PanelStyle.h" | 25 | #include "unity-shared/PanelStyle.h" |
1656 | 26 | #include "unity-shared/UBusMessages.h" | 26 | #include "unity-shared/UBusMessages.h" |
1657 | 27 | #include "unity-shared/UBusWrapper.h" | 27 | #include "unity-shared/UBusWrapper.h" |
1658 | 28 | #include "InputMonitor.h" | ||
1659 | 28 | 29 | ||
1660 | 29 | #include "mock_menu_manager.h" | 30 | #include "mock_menu_manager.h" |
1661 | 30 | #include "test_standalone_wm.h" | 31 | #include "test_standalone_wm.h" |
1662 | @@ -43,6 +44,7 @@ | |||
1663 | 43 | nux::ObjectPtr<MockableBaseWindow> window_; | 44 | nux::ObjectPtr<MockableBaseWindow> window_; |
1664 | 44 | nux::ObjectPtr<PanelView> panel_view_; | 45 | nux::ObjectPtr<PanelView> panel_view_; |
1665 | 45 | testwrapper::StandaloneWM WM; | 46 | testwrapper::StandaloneWM WM; |
1666 | 47 | input::Monitor im; | ||
1667 | 46 | 48 | ||
1668 | 47 | TestPanelView() | 49 | TestPanelView() |
1669 | 48 | : window_(new MockableBaseWindow()) | 50 | : window_(new MockableBaseWindow()) |
1670 | 49 | 51 | ||
1671 | === added file 'tests/test_systemd_wrapper.cpp' | |||
1672 | --- tests/test_systemd_wrapper.cpp 1970-01-01 00:00:00 +0000 | |||
1673 | +++ tests/test_systemd_wrapper.cpp 2016-08-30 14:38:39 +0000 | |||
1674 | @@ -0,0 +1,111 @@ | |||
1675 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
1676 | 2 | /* | ||
1677 | 3 | * Copyright (c) 2016 Canonical Ltd | ||
1678 | 4 | * | ||
1679 | 5 | * This program is free software: you can redistribute it and/or modify | ||
1680 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
1681 | 7 | * published by the Free Software Foundation. | ||
1682 | 8 | * | ||
1683 | 9 | * This program is distributed in the hope that it will be useful, | ||
1684 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1685 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1686 | 12 | * GNU General Public License for more details. | ||
1687 | 13 | * | ||
1688 | 14 | * You should have received a copy of the GNU General Public License | ||
1689 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1690 | 16 | * | ||
1691 | 17 | * Authored by: Ted Gould <ted@canonical.com> | ||
1692 | 18 | */ | ||
1693 | 19 | |||
1694 | 20 | #include <gtest/gtest.h> | ||
1695 | 21 | using namespace testing; | ||
1696 | 22 | |||
1697 | 23 | #include "unity-shared/SystemdWrapper.h" | ||
1698 | 24 | |||
1699 | 25 | #include <UnityCore/GLibDBusServer.h> | ||
1700 | 26 | #include <UnityCore/Variant.h> | ||
1701 | 27 | |||
1702 | 28 | #include "test_utils.h" | ||
1703 | 29 | |||
1704 | 30 | namespace | ||
1705 | 31 | { | ||
1706 | 32 | |||
1707 | 33 | const std::string SYSTEMD = | ||
1708 | 34 | R"(<node> | ||
1709 | 35 | <interface name="org.freedesktop.systemd1.Manager"> | ||
1710 | 36 | <method name="StartUnit"> | ||
1711 | 37 | <arg name="name" type="s" direction="in" /> | ||
1712 | 38 | <arg name="mode" type="s" direction="in" /> | ||
1713 | 39 | <arg name="job" type="o" direction="out" /> | ||
1714 | 40 | </method> | ||
1715 | 41 | <method name="StopUnit"> | ||
1716 | 42 | <arg name="name" type="s" direction="in" /> | ||
1717 | 43 | <arg name="mode" type="s" direction="in" /> | ||
1718 | 44 | <arg name="job" type="o" direction="out" /> | ||
1719 | 45 | </method> | ||
1720 | 46 | </interface> | ||
1721 | 47 | </node>)"; | ||
1722 | 48 | |||
1723 | 49 | struct MockSystemdWrapper : unity::SystemdWrapper { | ||
1724 | 50 | MockSystemdWrapper() | ||
1725 | 51 | : SystemdWrapper(SystemdWrapper::TestMode()) | ||
1726 | 52 | {} | ||
1727 | 53 | }; | ||
1728 | 54 | |||
1729 | 55 | struct TestSystemdWrapper : public Test | ||
1730 | 56 | { | ||
1731 | 57 | TestSystemdWrapper() | ||
1732 | 58 | { | ||
1733 | 59 | systemd_server_ = std::make_shared<unity::glib::DBusServer>("com.canonical.Unity.Test.Systemd"); | ||
1734 | 60 | systemd_server_->AddObjects(SYSTEMD, "/org/freedesktop/systemd1"); | ||
1735 | 61 | |||
1736 | 62 | Utils::WaitUntilMSec([this] { return systemd_server_->IsConnected(); }); | ||
1737 | 63 | Utils::WaitUntilMSec([this] { return systemd_wrapper_.IsConnected(); }); | ||
1738 | 64 | } | ||
1739 | 65 | |||
1740 | 66 | unity::glib::DBusServer::Ptr systemd_server_; | ||
1741 | 67 | MockSystemdWrapper systemd_wrapper_; | ||
1742 | 68 | }; | ||
1743 | 69 | |||
1744 | 70 | |||
1745 | 71 | TEST_F(TestSystemdWrapper, Start) | ||
1746 | 72 | { | ||
1747 | 73 | bool start_sent = false; | ||
1748 | 74 | |||
1749 | 75 | systemd_server_->GetObjects().front()->SetMethodsCallsHandler([&] (std::string const& method, GVariant* par) -> GVariant* { | ||
1750 | 76 | if (method == "StartUnit") | ||
1751 | 77 | { | ||
1752 | 78 | start_sent = true; | ||
1753 | 79 | |||
1754 | 80 | std::string event_name = glib::Variant(g_variant_get_child_value(par, 0)).GetString(); | ||
1755 | 81 | EXPECT_EQ("unity-screen-locked", event_name); | ||
1756 | 82 | } | ||
1757 | 83 | |||
1758 | 84 | return nullptr; | ||
1759 | 85 | }); | ||
1760 | 86 | |||
1761 | 87 | systemd_wrapper_.Start("unity-screen-locked"); | ||
1762 | 88 | Utils::WaitUntil(start_sent); | ||
1763 | 89 | } | ||
1764 | 90 | |||
1765 | 91 | TEST_F(TestSystemdWrapper, Stop) | ||
1766 | 92 | { | ||
1767 | 93 | bool stop_sent = false; | ||
1768 | 94 | |||
1769 | 95 | systemd_server_->GetObjects().front()->SetMethodsCallsHandler([&] (std::string const& method, GVariant* par) -> GVariant* { | ||
1770 | 96 | if (method == "StopUnit") | ||
1771 | 97 | { | ||
1772 | 98 | stop_sent = true; | ||
1773 | 99 | |||
1774 | 100 | std::string event_name = glib::Variant(g_variant_get_child_value(par, 0)).GetString(); | ||
1775 | 101 | EXPECT_EQ("unity-screen-locked", event_name); | ||
1776 | 102 | } | ||
1777 | 103 | |||
1778 | 104 | return nullptr; | ||
1779 | 105 | }); | ||
1780 | 106 | |||
1781 | 107 | systemd_wrapper_.Stop("unity-screen-locked"); | ||
1782 | 108 | Utils::WaitUntil(stop_sent); | ||
1783 | 109 | } | ||
1784 | 110 | |||
1785 | 111 | } | ||
1786 | 0 | 112 | ||
1787 | === modified file 'tools/CMakeLists.txt' | |||
1788 | --- tools/CMakeLists.txt 2016-07-18 17:26:01 +0000 | |||
1789 | +++ tools/CMakeLists.txt 2016-08-30 14:38:39 +0000 | |||
1790 | @@ -28,3 +28,6 @@ | |||
1791 | 28 | add_executable(unity-active-plugins-safety-check unity_active_plugins_safety_check.cpp) | 28 | add_executable(unity-active-plugins-safety-check unity_active_plugins_safety_check.cpp) |
1792 | 29 | target_link_libraries(unity-active-plugins-safety-check ${LIBS}) | 29 | target_link_libraries(unity-active-plugins-safety-check ${LIBS}) |
1793 | 30 | install(TARGETS unity-active-plugins-safety-check DESTINATION ${CMAKE_INSTALL_LIBDIR}/unity/) | 30 | install(TARGETS unity-active-plugins-safety-check DESTINATION ${CMAKE_INSTALL_LIBDIR}/unity/) |
1794 | 31 | |||
1795 | 32 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/unity-compiz-profile-select.in ${CMAKE_CURRENT_BINARY_DIR}/unity-compiz-profile-select @ONLY) | ||
1796 | 33 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity-compiz-profile-select DESTINATION ${CMAKE_INSTALL_LIBDIR}/unity/) | ||
1797 | 31 | 34 | ||
1798 | === added file 'tools/unity-compiz-profile-select.in' | |||
1799 | --- tools/unity-compiz-profile-select.in 1970-01-01 00:00:00 +0000 | |||
1800 | +++ tools/unity-compiz-profile-select.in 2016-08-30 14:38:39 +0000 | |||
1801 | @@ -0,0 +1,25 @@ | |||
1802 | 1 | #!/bin/bash | ||
1803 | 2 | |||
1804 | 3 | set -e | ||
1805 | 4 | |||
1806 | 5 | # If gnome-session is going to start compiz, | ||
1807 | 6 | # we don't want to be the ones doing it. | ||
1808 | 7 | |||
1809 | 8 | if grep -q compiz /usr/share/gnome-session/sessions/ubuntu.session ; then | ||
1810 | 9 | echo "GNOME Session is starting Compiz" | ||
1811 | 10 | stop ; exit 0 | ||
1812 | 11 | fi | ||
1813 | 12 | |||
1814 | 13 | compiz_profile="ubuntu" | ||
1815 | 14 | |||
1816 | 15 | if ! /usr/lib/nux/unity_support_test -p; then | ||
1817 | 16 | compiz_profile="ubuntu-lowgfx" | ||
1818 | 17 | fi | ||
1819 | 18 | |||
1820 | 19 | echo "Using compiz profile '$compiz_profile'" | ||
1821 | 20 | |||
1822 | 21 | initctl set-env -g COMPIZ_CONFIG_PROFILE="$compiz_profile" | ||
1823 | 22 | systemctl set-environment --user COMPIZ_CONFIG_PROFILE="$compiz_profile" | ||
1824 | 23 | |||
1825 | 24 | export COMPIZ_CONFIG_PROFILE="$compiz_profile" | ||
1826 | 25 | exec @CMAKE_INSTALL_LIBDIR@/unity/unity-active-plugins-safety-check | ||
1827 | 0 | 26 | ||
1828 | === modified file 'unity-shared/CMakeLists.txt' | |||
1829 | --- unity-shared/CMakeLists.txt 2016-08-12 11:21:48 +0000 | |||
1830 | +++ unity-shared/CMakeLists.txt 2016-08-30 14:38:39 +0000 | |||
1831 | @@ -60,6 +60,7 @@ | |||
1832 | 60 | SpreadFilter.cpp | 60 | SpreadFilter.cpp |
1833 | 61 | SpreadWidgets.cpp | 61 | SpreadWidgets.cpp |
1834 | 62 | StaticCairoText.cpp | 62 | StaticCairoText.cpp |
1835 | 63 | SystemdWrapper.cpp | ||
1836 | 63 | TextureCache.cpp | 64 | TextureCache.cpp |
1837 | 64 | TextInput.cpp | 65 | TextInput.cpp |
1838 | 65 | TextureThumbnailProvider.cpp | 66 | TextureThumbnailProvider.cpp |
1839 | @@ -82,6 +83,7 @@ | |||
1840 | 82 | set (UNITY_SHARED_SOURCES | 83 | set (UNITY_SHARED_SOURCES |
1841 | 83 | XKeyboardUtil.cpp | 84 | XKeyboardUtil.cpp |
1842 | 84 | XWindowManager.cpp | 85 | XWindowManager.cpp |
1843 | 86 | InputMonitor.cpp | ||
1844 | 85 | ${UNITY_SHARED_SOURCES} | 87 | ${UNITY_SHARED_SOURCES} |
1845 | 86 | ) | 88 | ) |
1846 | 87 | else() | 89 | else() |
1847 | 88 | 90 | ||
1848 | === added file 'unity-shared/InputMonitor.cpp' | |||
1849 | --- unity-shared/InputMonitor.cpp 1970-01-01 00:00:00 +0000 | |||
1850 | +++ unity-shared/InputMonitor.cpp 2016-08-30 14:38:39 +0000 | |||
1851 | @@ -0,0 +1,414 @@ | |||
1852 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
1853 | 2 | /* | ||
1854 | 3 | * Copyright (C) 2014 Canonical Ltd | ||
1855 | 4 | * | ||
1856 | 5 | * This program is free software: you can redistribute it and/or modify | ||
1857 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
1858 | 7 | * published by the Free Software Foundation. | ||
1859 | 8 | * | ||
1860 | 9 | * This program is distributed in the hope that it will be useful, | ||
1861 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1862 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1863 | 12 | * GNU General Public License for more details. | ||
1864 | 13 | * | ||
1865 | 14 | * You should have received a copy of the GNU General Public License | ||
1866 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1867 | 16 | * | ||
1868 | 17 | * Authored by: Marco Trevisan <marco.trevisan@canonical.com> | ||
1869 | 18 | */ | ||
1870 | 19 | |||
1871 | 20 | #include "InputMonitor.h" | ||
1872 | 21 | #include "SigcSlotHash.h" | ||
1873 | 22 | |||
1874 | 23 | #include <Nux/Nux.h> | ||
1875 | 24 | #include <NuxCore/Logger.h> | ||
1876 | 25 | #include <X11/extensions/XInput2.h> | ||
1877 | 26 | #include <UnityCore/GLibSource.h> | ||
1878 | 27 | #include <unordered_set> | ||
1879 | 28 | #include <gdk/gdkx.h> | ||
1880 | 29 | #include <glib.h> | ||
1881 | 30 | |||
1882 | 31 | namespace unity | ||
1883 | 32 | { | ||
1884 | 33 | namespace input | ||
1885 | 34 | { | ||
1886 | 35 | namespace | ||
1887 | 36 | { | ||
1888 | 37 | DECLARE_LOGGER(logger, "unity.input.monitor"); | ||
1889 | 38 | |||
1890 | 39 | Monitor* instance_ = nullptr; | ||
1891 | 40 | |||
1892 | 41 | const unsigned XINPUT_MAJOR_VERSION = 2; | ||
1893 | 42 | const unsigned XINPUT_MINOR_VERSION = 3; | ||
1894 | 43 | |||
1895 | 44 | bool operator&(Events l, Events r) | ||
1896 | 45 | { | ||
1897 | 46 | typedef std::underlying_type<Events>::type ut; | ||
1898 | 47 | return static_cast<ut>(static_cast<ut>(l) & static_cast<ut>(r)); | ||
1899 | 48 | } | ||
1900 | 49 | |||
1901 | 50 | Events& operator|=(Events& l, Events r) | ||
1902 | 51 | { | ||
1903 | 52 | typedef std::underlying_type<Events>::type ut; | ||
1904 | 53 | return l = static_cast<Events>(static_cast<ut>(l) | static_cast<ut>(r)); | ||
1905 | 54 | } | ||
1906 | 55 | |||
1907 | 56 | template <typename EVENT> | ||
1908 | 57 | void initialize_event_common(EVENT* ev, XIDeviceEvent* xiev) | ||
1909 | 58 | { | ||
1910 | 59 | ev->serial = xiev->serial; | ||
1911 | 60 | ev->send_event = xiev->send_event; | ||
1912 | 61 | ev->display = xiev->display; | ||
1913 | 62 | ev->window = xiev->event; | ||
1914 | 63 | ev->root = xiev->root; | ||
1915 | 64 | ev->subwindow = xiev->child; | ||
1916 | 65 | ev->time = xiev->time; | ||
1917 | 66 | ev->x = std::round(xiev->event_x); | ||
1918 | 67 | ev->y = std::round(xiev->event_y); | ||
1919 | 68 | ev->x_root = std::round(xiev->root_x); | ||
1920 | 69 | ev->y_root = std::round(xiev->root_y); | ||
1921 | 70 | ev->state = xiev->mods.effective; | ||
1922 | 71 | ev->same_screen = True; | ||
1923 | 72 | } | ||
1924 | 73 | |||
1925 | 74 | template <typename EVENT_TYPE, typename NATIVE_TYPE> | ||
1926 | 75 | void initialize_event(XEvent* ev, NATIVE_TYPE* xiev); | ||
1927 | 76 | |||
1928 | 77 | template <> | ||
1929 | 78 | void initialize_event<XButtonEvent>(XEvent* ev, XIDeviceEvent* xiev) | ||
1930 | 79 | { | ||
1931 | 80 | XButtonEvent* bev = &ev->xbutton; | ||
1932 | 81 | ev->type = (xiev->evtype == XI_ButtonPress) ? ButtonPress : ButtonRelease; | ||
1933 | 82 | initialize_event_common(bev, xiev); | ||
1934 | 83 | bev->button = xiev->detail; | ||
1935 | 84 | } | ||
1936 | 85 | |||
1937 | 86 | template <> | ||
1938 | 87 | void initialize_event<XKeyEvent>(XEvent* ev, XIDeviceEvent* xiev) | ||
1939 | 88 | { | ||
1940 | 89 | XKeyEvent* kev = &ev->xkey; | ||
1941 | 90 | ev->type = (xiev->evtype == XI_KeyPress) ? KeyPress : KeyRelease; | ||
1942 | 91 | initialize_event_common(kev, xiev); | ||
1943 | 92 | kev->keycode = xiev->detail; | ||
1944 | 93 | } | ||
1945 | 94 | |||
1946 | 95 | template <> | ||
1947 | 96 | void initialize_event<XMotionEvent>(XEvent* ev, XIDeviceEvent* xiev) | ||
1948 | 97 | { | ||
1949 | 98 | XMotionEvent* mev = &ev->xmotion; | ||
1950 | 99 | ev->type = MotionNotify; | ||
1951 | 100 | initialize_event_common(mev, xiev); | ||
1952 | 101 | mev->is_hint = NotifyNormal; | ||
1953 | 102 | |||
1954 | 103 | for (int i = 0; i < xiev->buttons.mask_len * 8; ++i) | ||
1955 | 104 | { | ||
1956 | 105 | if (XIMaskIsSet(xiev->buttons.mask, i)) | ||
1957 | 106 | { | ||
1958 | 107 | mev->is_hint = NotifyHint; | ||
1959 | 108 | break; | ||
1960 | 109 | } | ||
1961 | 110 | } | ||
1962 | 111 | } | ||
1963 | 112 | |||
1964 | 113 | template <> | ||
1965 | 114 | void initialize_event<XGenericEventCookie>(XEvent* ev, XIBarrierEvent* xiev) | ||
1966 | 115 | { | ||
1967 | 116 | XGenericEventCookie* cev = &ev->xcookie; | ||
1968 | 117 | cev->type = GenericEvent; | ||
1969 | 118 | cev->serial = xiev->serial; | ||
1970 | 119 | cev->send_event = xiev->send_event; | ||
1971 | 120 | cev->display = xiev->display; | ||
1972 | 121 | cev->evtype = xiev->evtype; | ||
1973 | 122 | cev->data = xiev; | ||
1974 | 123 | } | ||
1975 | 124 | } | ||
1976 | 125 | |||
1977 | 126 | struct Monitor::Impl | ||
1978 | 127 | { | ||
1979 | 128 | #if __GNUC__ < 6 | ||
1980 | 129 | using EventCallbackSet = std::unordered_set<EventCallback>; | ||
1981 | 130 | #else | ||
1982 | 131 | using EventCallbackSet = std::unordered_set<EventCallback, std::hash<sigc::slot_base>>; | ||
1983 | 132 | #endif | ||
1984 | 133 | |||
1985 | 134 | Impl() | ||
1986 | 135 | : xi_opcode_(0) | ||
1987 | 136 | , event_filter_set_(false) | ||
1988 | 137 | , invoking_callbacks_(false) | ||
1989 | 138 | { | ||
1990 | 139 | Display *dpy = gdk_x11_get_default_xdisplay(); | ||
1991 | 140 | int event_base, error_base; | ||
1992 | 141 | |||
1993 | 142 | if (XQueryExtension(dpy, "XInputExtension", &xi_opcode_, &event_base, &error_base)) | ||
1994 | 143 | { | ||
1995 | 144 | int maj = XINPUT_MAJOR_VERSION; | ||
1996 | 145 | int min = XINPUT_MINOR_VERSION; | ||
1997 | 146 | |||
1998 | 147 | if (XIQueryVersion(dpy, &maj, &min) == BadRequest) | ||
1999 | 148 | { | ||
2000 | 149 | LOG_ERROR(logger) << "Need XInput version "<< maj << "." << min << ", " | ||
2001 | 150 | << "impossible, to setup an InputMonitor"; | ||
2002 | 151 | } | ||
2003 | 152 | } | ||
2004 | 153 | else | ||
2005 | 154 | { | ||
2006 | 155 | LOG_ERROR(logger) << "Missing XInput, impossible to setup an InputMonitor"; | ||
2007 | 156 | } | ||
2008 | 157 | } | ||
2009 | 158 | |||
2010 | 159 | ~Impl() | ||
2011 | 160 | { | ||
2012 | 161 | if (event_filter_set_) | ||
2013 | 162 | { | ||
2014 | 163 | pointer_callbacks_.clear(); | ||
2015 | 164 | key_callbacks_.clear(); | ||
2016 | 165 | barrier_callbacks_.clear(); | ||
2017 | 166 | UpdateEventMonitor(); | ||
2018 | 167 | } | ||
2019 | 168 | } | ||
2020 | 169 | |||
2021 | 170 | bool RegisterClient(Events type, EventCallback const& cb) | ||
2022 | 171 | { | ||
2023 | 172 | bool added = false; | ||
2024 | 173 | |||
2025 | 174 | if (type & Events::POINTER) | ||
2026 | 175 | added = pointer_callbacks_.insert(cb).second || added; | ||
2027 | 176 | |||
2028 | 177 | if (type & Events::KEYS) | ||
2029 | 178 | added = key_callbacks_.insert(cb).second || added; | ||
2030 | 179 | |||
2031 | 180 | if (type & Events::BARRIER) | ||
2032 | 181 | added = barrier_callbacks_.insert(cb).second || added; | ||
2033 | 182 | |||
2034 | 183 | if (added) | ||
2035 | 184 | UpdateEventMonitor(); | ||
2036 | 185 | |||
2037 | 186 | return added; | ||
2038 | 187 | } | ||
2039 | 188 | |||
2040 | 189 | bool UnregisterClient(EventCallback const& cb) | ||
2041 | 190 | { | ||
2042 | 191 | if (invoking_callbacks_) | ||
2043 | 192 | { | ||
2044 | 193 | // Delay the event removal if we're currently invoking a callback | ||
2045 | 194 | // not to break the callbacks loop | ||
2046 | 195 | removal_queue_.insert(cb); | ||
2047 | 196 | return false; | ||
2048 | 197 | } | ||
2049 | 198 | |||
2050 | 199 | bool removed = false; | ||
2051 | 200 | removed = pointer_callbacks_.erase(cb) > 0 || removed; | ||
2052 | 201 | removed = key_callbacks_.erase(cb) > 0 || removed; | ||
2053 | 202 | removed = barrier_callbacks_.erase(cb) > 0 || removed; | ||
2054 | 203 | |||
2055 | 204 | if (removed) | ||
2056 | 205 | UpdateEventMonitor(); | ||
2057 | 206 | |||
2058 | 207 | return removed; | ||
2059 | 208 | } | ||
2060 | 209 | |||
2061 | 210 | Events RegisteredEvents(EventCallback const& cb) const | ||
2062 | 211 | { | ||
2063 | 212 | Events events = Events::NONE; | ||
2064 | 213 | |||
2065 | 214 | if (pointer_callbacks_.find(cb) != end(pointer_callbacks_)) | ||
2066 | 215 | events |= Events::POINTER; | ||
2067 | 216 | |||
2068 | 217 | if (key_callbacks_.find(cb) != end(key_callbacks_)) | ||
2069 | 218 | events |= Events::KEYS; | ||
2070 | 219 | |||
2071 | 220 | if (barrier_callbacks_.find(cb) != end(barrier_callbacks_)) | ||
2072 | 221 | events |= Events::BARRIER; | ||
2073 | 222 | |||
2074 | 223 | return events; | ||
2075 | 224 | } | ||
2076 | 225 | |||
2077 | 226 | void UpdateEventMonitor() | ||
2078 | 227 | { | ||
2079 | 228 | auto* dpy = nux::GetGraphicsDisplay()->GetX11Display(); | ||
2080 | 229 | Window root = DefaultRootWindow(dpy); | ||
2081 | 230 | |||
2082 | 231 | unsigned char master_dev_bits[XIMaskLen(XI_LASTEVENT)] = { 0 }; | ||
2083 | 232 | XIEventMask master_dev = { XIAllMasterDevices, sizeof(master_dev_bits), master_dev_bits }; | ||
2084 | 233 | |||
2085 | 234 | if (!barrier_callbacks_.empty()) | ||
2086 | 235 | { | ||
2087 | 236 | XISetMask(master_dev.mask, XI_BarrierHit); | ||
2088 | 237 | XISetMask(master_dev.mask, XI_BarrierLeave); | ||
2089 | 238 | } | ||
2090 | 239 | |||
2091 | 240 | unsigned char all_devs_bits[XIMaskLen(XI_LASTEVENT)] = { 0 }; | ||
2092 | 241 | XIEventMask all_devs = { XIAllDevices, sizeof(all_devs_bits), all_devs_bits }; | ||
2093 | 242 | |||
2094 | 243 | if (!pointer_callbacks_.empty()) | ||
2095 | 244 | { | ||
2096 | 245 | XISetMask(all_devs.mask, XI_Motion); | ||
2097 | 246 | XISetMask(all_devs.mask, XI_ButtonPress); | ||
2098 | 247 | XISetMask(all_devs.mask, XI_ButtonRelease); | ||
2099 | 248 | } | ||
2100 | 249 | |||
2101 | 250 | if (!key_callbacks_.empty()) | ||
2102 | 251 | { | ||
2103 | 252 | XISetMask(all_devs.mask, XI_KeyPress); | ||
2104 | 253 | XISetMask(all_devs.mask, XI_KeyRelease); | ||
2105 | 254 | } | ||
2106 | 255 | |||
2107 | 256 | XIEventMask selected[] = {master_dev, all_devs}; | ||
2108 | 257 | XISelectEvents(dpy, root, selected, G_N_ELEMENTS(selected)); | ||
2109 | 258 | XSync(dpy, False); | ||
2110 | 259 | |||
2111 | 260 | if (!pointer_callbacks_.empty() || !key_callbacks_.empty() || !barrier_callbacks_.empty()) | ||
2112 | 261 | { | ||
2113 | 262 | if (!event_filter_set_) | ||
2114 | 263 | { | ||
2115 | 264 | nux::GetGraphicsDisplay()->AddEventFilter({[] (XEvent event, void* data) { | ||
2116 | 265 | return static_cast<Impl*>(data)->HandleEvent(event); | ||
2117 | 266 | }, this}); | ||
2118 | 267 | |||
2119 | 268 | event_filter_set_ = true; | ||
2120 | 269 | } | ||
2121 | 270 | } | ||
2122 | 271 | else if (event_filter_set_) | ||
2123 | 272 | { | ||
2124 | 273 | nux::GetGraphicsDisplay()->RemoveEventFilter(this); | ||
2125 | 274 | event_filter_set_ = false; | ||
2126 | 275 | } | ||
2127 | 276 | } | ||
2128 | 277 | |||
2129 | 278 | bool HandleEvent(XEvent& event) | ||
2130 | 279 | { | ||
2131 | 280 | bool handled = false; | ||
2132 | 281 | |||
2133 | 282 | if (event.type != GenericEvent || event.xcookie.extension != xi_opcode_) | ||
2134 | 283 | return handled; | ||
2135 | 284 | |||
2136 | 285 | switch (event.xcookie.evtype) | ||
2137 | 286 | { | ||
2138 | 287 | case XI_ButtonPress: | ||
2139 | 288 | case XI_ButtonRelease: | ||
2140 | 289 | handled = InvokeCallbacks<XButtonEvent>(pointer_callbacks_, event); | ||
2141 | 290 | break; | ||
2142 | 291 | case XI_Motion: | ||
2143 | 292 | handled = InvokeCallbacks<XMotionEvent>(pointer_callbacks_, event); | ||
2144 | 293 | break; | ||
2145 | 294 | case XI_KeyPress: | ||
2146 | 295 | case XI_KeyRelease: | ||
2147 | 296 | handled = InvokeCallbacks<XKeyEvent>(key_callbacks_, event); | ||
2148 | 297 | break; | ||
2149 | 298 | case XI_BarrierHit: | ||
2150 | 299 | case XI_BarrierLeave: | ||
2151 | 300 | handled = InvokeCallbacks<XGenericEventCookie, XIBarrierEvent>(barrier_callbacks_, event); | ||
2152 | 301 | break; | ||
2153 | 302 | } | ||
2154 | 303 | |||
2155 | 304 | return handled; | ||
2156 | 305 | } | ||
2157 | 306 | |||
2158 | 307 | template <typename EVENT_TYPE, typename NATIVE_TYPE = XIDeviceEvent> | ||
2159 | 308 | bool InvokeCallbacks(EventCallbackSet& callbacks, XEvent& xiev) | ||
2160 | 309 | { | ||
2161 | 310 | XGenericEventCookie *cookie = &xiev.xcookie; | ||
2162 | 311 | |||
2163 | 312 | if (!XGetEventData(xiev.xany.display, cookie)) | ||
2164 | 313 | return false; | ||
2165 | 314 | |||
2166 | 315 | XEvent event; | ||
2167 | 316 | initialize_event<EVENT_TYPE>(&event, reinterpret_cast<NATIVE_TYPE*>(cookie->data)); | ||
2168 | 317 | invoking_callbacks_ = true; | ||
2169 | 318 | |||
2170 | 319 | for (auto it = callbacks.begin(); it != callbacks.end();) | ||
2171 | 320 | { | ||
2172 | 321 | if (it->empty()) | ||
2173 | 322 | { | ||
2174 | 323 | it = callbacks.erase(it); | ||
2175 | 324 | continue; | ||
2176 | 325 | } | ||
2177 | 326 | |||
2178 | 327 | (*it)(event); | ||
2179 | 328 | ++it; | ||
2180 | 329 | } | ||
2181 | 330 | |||
2182 | 331 | XFreeEventData(xiev.xany.display, cookie); | ||
2183 | 332 | invoking_callbacks_ = false; | ||
2184 | 333 | |||
2185 | 334 | // A callback might unregister itself on the event callback, causing the | ||
2186 | 335 | // above callbacks loop to crash, so in this case we save the event in the | ||
2187 | 336 | // removal queue and eventually we unregistered these callbacks. | ||
2188 | 337 | bool update_event_monitor = false; | ||
2189 | 338 | for (auto it = removal_queue_.begin(); it != removal_queue_.end(); it = removal_queue_.erase(it)) | ||
2190 | 339 | { | ||
2191 | 340 | auto const& cb = *it; | ||
2192 | 341 | pointer_callbacks_.erase(cb); | ||
2193 | 342 | key_callbacks_.erase(cb); | ||
2194 | 343 | barrier_callbacks_.erase(cb); | ||
2195 | 344 | update_event_monitor = true; | ||
2196 | 345 | } | ||
2197 | 346 | |||
2198 | 347 | if (callbacks.empty() || update_event_monitor) | ||
2199 | 348 | { | ||
2200 | 349 | idle_removal_.reset(new glib::Idle([this] { | ||
2201 | 350 | UpdateEventMonitor(); | ||
2202 | 351 | return false; | ||
2203 | 352 | })); | ||
2204 | 353 | |||
2205 | 354 | return false; | ||
2206 | 355 | } | ||
2207 | 356 | |||
2208 | 357 | return true; | ||
2209 | 358 | } | ||
2210 | 359 | |||
2211 | 360 | int xi_opcode_; | ||
2212 | 361 | bool event_filter_set_; | ||
2213 | 362 | bool invoking_callbacks_; | ||
2214 | 363 | glib::Source::UniquePtr idle_removal_; | ||
2215 | 364 | EventCallbackSet pointer_callbacks_; | ||
2216 | 365 | EventCallbackSet key_callbacks_; | ||
2217 | 366 | EventCallbackSet barrier_callbacks_; | ||
2218 | 367 | EventCallbackSet removal_queue_; | ||
2219 | 368 | }; | ||
2220 | 369 | |||
2221 | 370 | Monitor::Monitor() | ||
2222 | 371 | { | ||
2223 | 372 | if (instance_) | ||
2224 | 373 | { | ||
2225 | 374 | LOG_WARN(logger) << "More than one input::Monitor created."; | ||
2226 | 375 | return; | ||
2227 | 376 | } | ||
2228 | 377 | |||
2229 | 378 | instance_ = this; | ||
2230 | 379 | impl_.reset(new Impl()); | ||
2231 | 380 | } | ||
2232 | 381 | |||
2233 | 382 | Monitor::~Monitor() | ||
2234 | 383 | { | ||
2235 | 384 | if (this == instance_) | ||
2236 | 385 | instance_ = nullptr; | ||
2237 | 386 | } | ||
2238 | 387 | |||
2239 | 388 | Monitor& Monitor::Get() | ||
2240 | 389 | { | ||
2241 | 390 | if (!instance_) | ||
2242 | 391 | { | ||
2243 | 392 | LOG_ERROR(logger) << "No input::Monitor created yet."; | ||
2244 | 393 | } | ||
2245 | 394 | |||
2246 | 395 | return *instance_; | ||
2247 | 396 | } | ||
2248 | 397 | |||
2249 | 398 | bool Monitor::RegisterClient(Events events, EventCallback const& cb) | ||
2250 | 399 | { | ||
2251 | 400 | return impl_->RegisterClient(events, cb); | ||
2252 | 401 | } | ||
2253 | 402 | |||
2254 | 403 | bool Monitor::UnregisterClient(EventCallback const& cb) | ||
2255 | 404 | { | ||
2256 | 405 | return impl_->UnregisterClient(cb); | ||
2257 | 406 | } | ||
2258 | 407 | |||
2259 | 408 | Events Monitor::RegisteredEvents(EventCallback const& cb) const | ||
2260 | 409 | { | ||
2261 | 410 | return impl_->RegisteredEvents(cb); | ||
2262 | 411 | } | ||
2263 | 412 | |||
2264 | 413 | } // input namespace | ||
2265 | 414 | } // unity namespace | ||
2266 | 0 | 415 | ||
2267 | === added file 'unity-shared/InputMonitor.h' | |||
2268 | --- unity-shared/InputMonitor.h 1970-01-01 00:00:00 +0000 | |||
2269 | +++ unity-shared/InputMonitor.h 2016-08-30 14:38:39 +0000 | |||
2270 | @@ -0,0 +1,67 @@ | |||
2271 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
2272 | 2 | /* | ||
2273 | 3 | * Copyright (C) 2014 Canonical Ltd | ||
2274 | 4 | * | ||
2275 | 5 | * This program is free software: you can redistribute it and/or modify | ||
2276 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
2277 | 7 | * published by the Free Software Foundation. | ||
2278 | 8 | * | ||
2279 | 9 | * This program is distributed in the hope that it will be useful, | ||
2280 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2281 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2282 | 12 | * GNU General Public License for more details. | ||
2283 | 13 | * | ||
2284 | 14 | * You should have received a copy of the GNU General Public License | ||
2285 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2286 | 16 | * | ||
2287 | 17 | * Authored by: Marco Trevisan <marco.trevisan@canonical.com> | ||
2288 | 18 | */ | ||
2289 | 19 | |||
2290 | 20 | #ifndef __UNITY_INPUT_MONITOR__ | ||
2291 | 21 | #define __UNITY_INPUT_MONITOR__ | ||
2292 | 22 | |||
2293 | 23 | #include <X11/Xlib.h> | ||
2294 | 24 | #include <sigc++/slot.h> | ||
2295 | 25 | #include <memory> | ||
2296 | 26 | |||
2297 | 27 | namespace unity | ||
2298 | 28 | { | ||
2299 | 29 | namespace input | ||
2300 | 30 | { | ||
2301 | 31 | enum class Events : unsigned | ||
2302 | 32 | { | ||
2303 | 33 | NONE = 0, | ||
2304 | 34 | POINTER = (1 << 0), | ||
2305 | 35 | KEYS = (1 << 1), | ||
2306 | 36 | BARRIER = (1 << 2), | ||
2307 | 37 | INPUT = POINTER | KEYS, | ||
2308 | 38 | ALL = POINTER | KEYS | BARRIER | ||
2309 | 39 | }; | ||
2310 | 40 | |||
2311 | 41 | class Monitor : public sigc::trackable | ||
2312 | 42 | { | ||
2313 | 43 | public: | ||
2314 | 44 | typedef sigc::slot<void, XEvent const&> EventCallback; | ||
2315 | 45 | |||
2316 | 46 | static Monitor& Get(); | ||
2317 | 47 | |||
2318 | 48 | Monitor(); | ||
2319 | 49 | virtual ~Monitor(); | ||
2320 | 50 | |||
2321 | 51 | bool RegisterClient(Events, EventCallback const&); | ||
2322 | 52 | bool UnregisterClient(EventCallback const&); | ||
2323 | 53 | |||
2324 | 54 | Events RegisteredEvents(EventCallback const&) const; | ||
2325 | 55 | |||
2326 | 56 | private: | ||
2327 | 57 | Monitor(Monitor const&) = delete; | ||
2328 | 58 | Monitor& operator=(Monitor const&) = delete; | ||
2329 | 59 | |||
2330 | 60 | struct Impl; | ||
2331 | 61 | std::unique_ptr<Impl> impl_; | ||
2332 | 62 | }; | ||
2333 | 63 | |||
2334 | 64 | } // input namespace | ||
2335 | 65 | } // unity namespace | ||
2336 | 66 | |||
2337 | 67 | #endif // __UNITY_INPUT_MONITOR__ | ||
2338 | 0 | 68 | ||
2339 | === modified file 'unity-shared/MenuManager.cpp' | |||
2340 | --- unity-shared/MenuManager.cpp 2015-10-02 14:02:05 +0000 | |||
2341 | +++ unity-shared/MenuManager.cpp 2016-08-30 14:38:39 +0000 | |||
2342 | @@ -21,11 +21,17 @@ | |||
2343 | 21 | #include <gtk/gtk.h> | 21 | #include <gtk/gtk.h> |
2344 | 22 | #include <NuxCore/Logger.h> | 22 | #include <NuxCore/Logger.h> |
2345 | 23 | #include <UnityCore/GLibSignal.h> | 23 | #include <UnityCore/GLibSignal.h> |
2346 | 24 | #include <UnityCore/GLibSource.h> | ||
2347 | 24 | #include <UnityCore/GLibWrapper.h> | 25 | #include <UnityCore/GLibWrapper.h> |
2348 | 25 | #include <UnityCore/DBusIndicators.h> | 26 | #include <UnityCore/DBusIndicators.h> |
2349 | 26 | #include <unordered_map> | 27 | #include <unordered_map> |
2350 | 27 | 28 | ||
2351 | 28 | #include "MenuManager.h" | 29 | #include "MenuManager.h" |
2352 | 30 | #include "InputMonitor.h" | ||
2353 | 31 | #include "RawPixel.h" | ||
2354 | 32 | #include "SigcSlotHash.h" | ||
2355 | 33 | #include "UnitySettings.h" | ||
2356 | 34 | #include "UScreen.h" | ||
2357 | 29 | #include "WindowManager.h" | 35 | #include "WindowManager.h" |
2358 | 30 | 36 | ||
2359 | 31 | namespace unity | 37 | namespace unity |
2360 | @@ -40,6 +46,10 @@ | |||
2361 | 40 | const std::string LIM_KEY = "integrated-menus"; | 46 | const std::string LIM_KEY = "integrated-menus"; |
2362 | 41 | const std::string SHOW_MENUS_NOW_DELAY = "show-menus-now-delay"; | 47 | const std::string SHOW_MENUS_NOW_DELAY = "show-menus-now-delay"; |
2363 | 42 | const std::string ALWAYS_SHOW_MENUS_KEY = "always-show-menus"; | 48 | const std::string ALWAYS_SHOW_MENUS_KEY = "always-show-menus"; |
2364 | 49 | |||
2365 | 50 | const RawPixel TRIANGLE_THRESHOLD = 5_em; | ||
2366 | 51 | const double SCRUB_VELOCITY_THRESHOLD = 0.05; | ||
2367 | 52 | const unsigned MENU_OPEN_MOUSE_WAIT = 150; | ||
2368 | 43 | } | 53 | } |
2369 | 44 | 54 | ||
2370 | 45 | using namespace indicator; | 55 | using namespace indicator; |
2371 | @@ -51,6 +61,7 @@ | |||
2372 | 51 | , indicators_(indicators) | 61 | , indicators_(indicators) |
2373 | 52 | , key_grabber_(grabber) | 62 | , key_grabber_(grabber) |
2374 | 53 | , show_now_window_(0) | 63 | , show_now_window_(0) |
2375 | 64 | , last_pointer_time_(0) | ||
2376 | 54 | , settings_(g_settings_new(SETTINGS_NAME.c_str())) | 65 | , settings_(g_settings_new(SETTINGS_NAME.c_str())) |
2377 | 55 | { | 66 | { |
2378 | 56 | for (auto const& indicator : indicators_->GetIndicators()) | 67 | for (auto const& indicator : indicators_->GetIndicators()) |
2379 | @@ -182,9 +193,15 @@ | |||
2380 | 182 | parent_->key_activate_entry.emit(entry_id); | 193 | parent_->key_activate_entry.emit(entry_id); |
2381 | 183 | } | 194 | } |
2382 | 184 | 195 | ||
2384 | 185 | void EntryActivated(std::string const&, std::string const&, nux::Rect const& geo) | 196 | void EntryActivated(std::string const& menubar, std::string const&, nux::Rect const& geo) |
2385 | 186 | { | 197 | { |
2386 | 187 | parent_->menu_open = !geo.IsNull(); | 198 | parent_->menu_open = !geo.IsNull(); |
2387 | 199 | |||
2388 | 200 | if (active_menubar_ != menubar) | ||
2389 | 201 | { | ||
2390 | 202 | active_menubar_ = menubar; | ||
2391 | 203 | UpdateActiveTracker(); | ||
2392 | 204 | } | ||
2393 | 188 | } | 205 | } |
2394 | 189 | 206 | ||
2395 | 190 | void SetShowNowForWindow(Window xid, bool show) | 207 | void SetShowNowForWindow(Window xid, bool show) |
2396 | @@ -231,15 +248,148 @@ | |||
2397 | 231 | gtk_icon_theme_set_search_path(gtk_icon_theme_get_default(), gicon_paths.data(), gicon_paths.size()); | 248 | gtk_icon_theme_set_search_path(gtk_icon_theme_get_default(), gicon_paths.data(), gicon_paths.size()); |
2398 | 232 | } | 249 | } |
2399 | 233 | 250 | ||
2400 | 251 | bool PointInTriangle(nux::Point const& p, nux::Point const& t0, nux::Point const& t1, nux::Point const& t2) | ||
2401 | 252 | { | ||
2402 | 253 | int s = t0.y * t2.x - t0.x * t2.y + (t2.y - t0.y) * p.x + (t0.x - t2.x) * p.y; | ||
2403 | 254 | int t = t0.x * t1.y - t0.y * t1.x + (t0.y - t1.y) * p.x + (t1.x - t0.x) * p.y; | ||
2404 | 255 | |||
2405 | 256 | if ((s < 0) != (t < 0)) | ||
2406 | 257 | return false; | ||
2407 | 258 | |||
2408 | 259 | int A = -t1.y * t2.x + t0.y * (t2.x - t1.x) + t0.x * (t1.y - t2.y) + t1.x * t2.y; | ||
2409 | 260 | if (A < 0) | ||
2410 | 261 | { | ||
2411 | 262 | s = -s; | ||
2412 | 263 | t = -t; | ||
2413 | 264 | A = -A; | ||
2414 | 265 | } | ||
2415 | 266 | |||
2416 | 267 | return s > 0 && t > 0 && (s + t) < A; | ||
2417 | 268 | } | ||
2418 | 269 | |||
2419 | 270 | double GetMouseVelocity(nux::Point const& p0, nux::Point const& p1, Time time_delta) | ||
2420 | 271 | { | ||
2421 | 272 | int dx, dy; | ||
2422 | 273 | double speed; | ||
2423 | 274 | |||
2424 | 275 | if (time_delta == 0) | ||
2425 | 276 | return 1; | ||
2426 | 277 | |||
2427 | 278 | dx = p0.x - p1.x; | ||
2428 | 279 | dy = p0.y - p1.y; | ||
2429 | 280 | |||
2430 | 281 | speed = sqrt(dx * dx + dy * dy) / time_delta; | ||
2431 | 282 | |||
2432 | 283 | return speed; | ||
2433 | 284 | } | ||
2434 | 285 | |||
2435 | 286 | void OnActiveEntryEvent(XEvent const& e) | ||
2436 | 287 | { | ||
2437 | 288 | if (e.type != MotionNotify) | ||
2438 | 289 | return; | ||
2439 | 290 | |||
2440 | 291 | auto const& active_entry = indicators_->GetActiveEntry(); | ||
2441 | 292 | |||
2442 | 293 | if (!active_entry) | ||
2443 | 294 | return; | ||
2444 | 295 | |||
2445 | 296 | nux::Point mouse(e.xmotion.x_root, e.xmotion.y_root); | ||
2446 | 297 | auto monitor = UScreen::GetDefault()->GetMonitorAtPosition(mouse.x, mouse.y); | ||
2447 | 298 | double scale = Settings::Instance().em(monitor)->DPIScale(); | ||
2448 | 299 | double speed = GetMouseVelocity(mouse, tracked_pointer_pos_, e.xmotion.time - last_pointer_time_); | ||
2449 | 300 | auto menu_geo = active_entry->geometry(); | ||
2450 | 301 | |||
2451 | 302 | tracked_pointer_pos_ = mouse; | ||
2452 | 303 | last_pointer_time_ = e.xmotion.time; | ||
2453 | 304 | |||
2454 | 305 | if (speed > SCRUB_VELOCITY_THRESHOLD && | ||
2455 | 306 | PointInTriangle(mouse, {mouse.x, std::max(mouse.y - TRIANGLE_THRESHOLD.CP(scale), 0)}, | ||
2456 | 307 | menu_geo.GetPosition(), {menu_geo.x + menu_geo.width, menu_geo.y})) | ||
2457 | 308 | { | ||
2458 | 309 | pointer_movement_timeout_ = std::make_shared<glib::Timeout>(MENU_OPEN_MOUSE_WAIT, [this, mouse, speed] { | ||
2459 | 310 | if (active_tracker_) | ||
2460 | 311 | active_tracker_(mouse.x, mouse.y, speed); | ||
2461 | 312 | |||
2462 | 313 | return false; | ||
2463 | 314 | }); | ||
2464 | 315 | |||
2465 | 316 | return; | ||
2466 | 317 | } | ||
2467 | 318 | |||
2468 | 319 | if (active_tracker_) | ||
2469 | 320 | { | ||
2470 | 321 | pointer_movement_timeout_.reset(); | ||
2471 | 322 | active_tracker_(mouse.x, mouse.y, speed); | ||
2472 | 323 | } | ||
2473 | 324 | } | ||
2474 | 325 | |||
2475 | 326 | bool RegisterTracker(std::string const& menubar, PositionTracker const& cb) | ||
2476 | 327 | { | ||
2477 | 328 | auto it = position_trackers_.find(menubar); | ||
2478 | 329 | |||
2479 | 330 | if (it != end(position_trackers_)) | ||
2480 | 331 | return false; | ||
2481 | 332 | |||
2482 | 333 | position_trackers_.insert({menubar, cb}); | ||
2483 | 334 | |||
2484 | 335 | if (active_menubar_ == menubar) | ||
2485 | 336 | UpdateActiveTracker(); | ||
2486 | 337 | |||
2487 | 338 | return true; | ||
2488 | 339 | } | ||
2489 | 340 | |||
2490 | 341 | bool UnregisterTracker(std::string const& menubar, PositionTracker const& cb) | ||
2491 | 342 | { | ||
2492 | 343 | auto it = position_trackers_.find(menubar); | ||
2493 | 344 | |||
2494 | 345 | if (it == end(position_trackers_)) | ||
2495 | 346 | return false; | ||
2496 | 347 | |||
2497 | 348 | if (!cb || (cb && it->second == cb)) | ||
2498 | 349 | { | ||
2499 | 350 | position_trackers_.erase(it); | ||
2500 | 351 | UpdateActiveTracker(); | ||
2501 | 352 | return true; | ||
2502 | 353 | } | ||
2503 | 354 | |||
2504 | 355 | return false; | ||
2505 | 356 | } | ||
2506 | 357 | |||
2507 | 358 | void UpdateActiveTracker() | ||
2508 | 359 | { | ||
2509 | 360 | auto it = position_trackers_.find(active_menubar_); | ||
2510 | 361 | active_tracker_ = (it != end(position_trackers_)) ? it->second : PositionTracker(); | ||
2511 | 362 | pointer_movement_timeout_.reset(); | ||
2512 | 363 | |||
2513 | 364 | if (active_tracker_) | ||
2514 | 365 | { | ||
2515 | 366 | if (input::Monitor::Get().RegisterClient(input::Events::POINTER, sigc::mem_fun(this, &Impl::OnActiveEntryEvent))) | ||
2516 | 367 | last_pointer_time_ = 0; | ||
2517 | 368 | } | ||
2518 | 369 | else | ||
2519 | 370 | { | ||
2520 | 371 | input::Monitor::Get().UnregisterClient(sigc::mem_fun(this, &Impl::OnActiveEntryEvent)); | ||
2521 | 372 | |||
2522 | 373 | if (it != end(position_trackers_)) | ||
2523 | 374 | position_trackers_.erase(it); | ||
2524 | 375 | } | ||
2525 | 376 | } | ||
2526 | 377 | |||
2527 | 234 | Manager* parent_; | 378 | Manager* parent_; |
2528 | 235 | Indicators::Ptr indicators_; | 379 | Indicators::Ptr indicators_; |
2529 | 236 | AppmenuIndicator::Ptr appmenu_; | 380 | AppmenuIndicator::Ptr appmenu_; |
2530 | 237 | key::Grabber::Ptr key_grabber_; | 381 | key::Grabber::Ptr key_grabber_; |
2531 | 238 | Window show_now_window_; | 382 | Window show_now_window_; |
2532 | 383 | std::string active_menubar_; | ||
2533 | 384 | PositionTracker active_tracker_; | ||
2534 | 385 | nux::Point tracked_pointer_pos_; | ||
2535 | 386 | Time last_pointer_time_; | ||
2536 | 387 | glib::Source::Ptr pointer_movement_timeout_; | ||
2537 | 239 | connection::Manager appmenu_connections_; | 388 | connection::Manager appmenu_connections_; |
2538 | 240 | connection::Wrapper active_win_conn_; | 389 | connection::Wrapper active_win_conn_; |
2539 | 241 | glib::Object<GSettings> settings_; | 390 | glib::Object<GSettings> settings_; |
2540 | 242 | glib::SignalManager signals_; | 391 | glib::SignalManager signals_; |
2541 | 392 | std::unordered_map<std::string, PositionTracker> position_trackers_; | ||
2542 | 243 | std::unordered_map<indicator::Entry::Ptr, uint32_t> entry_actions_; | 393 | std::unordered_map<indicator::Entry::Ptr, uint32_t> entry_actions_; |
2543 | 244 | }; | 394 | }; |
2544 | 245 | 395 | ||
2545 | @@ -278,5 +428,16 @@ | |||
2546 | 278 | return impl_->key_grabber_; | 428 | return impl_->key_grabber_; |
2547 | 279 | } | 429 | } |
2548 | 280 | 430 | ||
2549 | 431 | bool Manager::RegisterTracker(std::string const& menubar, PositionTracker const& cb) | ||
2550 | 432 | { | ||
2551 | 433 | return impl_->RegisterTracker(menubar, cb); | ||
2552 | 434 | } | ||
2553 | 435 | |||
2554 | 436 | bool Manager::UnregisterTracker(std::string const& menubar, PositionTracker const& cb) | ||
2555 | 437 | { | ||
2556 | 438 | return impl_->UnregisterTracker(menubar, cb); | ||
2557 | 439 | } | ||
2558 | 440 | |||
2559 | 441 | |||
2560 | 281 | } // menu namespace | 442 | } // menu namespace |
2561 | 282 | } // unity namespace | 443 | } // unity namespace |
2562 | 283 | 444 | ||
2563 | === modified file 'unity-shared/MenuManager.h' | |||
2564 | --- unity-shared/MenuManager.h 2015-06-05 14:28:27 +0000 | |||
2565 | +++ unity-shared/MenuManager.h 2016-08-30 14:38:39 +0000 | |||
2566 | @@ -67,6 +67,10 @@ | |||
2567 | 67 | 67 | ||
2568 | 68 | key::Grabber::Ptr const& KeyGrabber() const; | 68 | key::Grabber::Ptr const& KeyGrabber() const; |
2569 | 69 | 69 | ||
2570 | 70 | typedef sigc::slot<void, int /*x*/, int /*y*/, double /*speed*/> PositionTracker; | ||
2571 | 71 | bool RegisterTracker(std::string const& menubar, PositionTracker const&); | ||
2572 | 72 | bool UnregisterTracker(std::string const& menubar, PositionTracker const& = PositionTracker()); | ||
2573 | 73 | |||
2574 | 70 | sigc::signal<void> appmenu_added; | 74 | sigc::signal<void> appmenu_added; |
2575 | 71 | sigc::signal<void> appmenu_removed; | 75 | sigc::signal<void> appmenu_removed; |
2576 | 72 | sigc::signal<bool>::accumulated<any_true> open_first; | 76 | sigc::signal<bool>::accumulated<any_true> open_first; |
2577 | 73 | 77 | ||
2578 | === added file 'unity-shared/SigcSlotHash.h' | |||
2579 | --- unity-shared/SigcSlotHash.h 1970-01-01 00:00:00 +0000 | |||
2580 | +++ unity-shared/SigcSlotHash.h 2016-08-30 14:38:39 +0000 | |||
2581 | @@ -0,0 +1,70 @@ | |||
2582 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
2583 | 2 | /* | ||
2584 | 3 | * Copyright (C) 2016 Canonical Ltd | ||
2585 | 4 | * | ||
2586 | 5 | * This program is free software: you can redistribute it and/or modify | ||
2587 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
2588 | 7 | * published by the Free Software Foundation. | ||
2589 | 8 | * | ||
2590 | 9 | * This program is distributed in the hope that it will be useful, | ||
2591 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2592 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2593 | 12 | * GNU General Public License for more details. | ||
2594 | 13 | * | ||
2595 | 14 | * You should have received a copy of the GNU General Public License | ||
2596 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2597 | 16 | * | ||
2598 | 17 | * Authored by: Marco Trevisan <marco.trevisan@canonical.com> | ||
2599 | 18 | */ | ||
2600 | 19 | |||
2601 | 20 | #ifndef __UNITY_SIGC_SLOT_HASHER__ | ||
2602 | 21 | #define __UNITY_SIGC_SLOT_HASHER__ | ||
2603 | 22 | |||
2604 | 23 | #include <sigc++/slot.h> | ||
2605 | 24 | |||
2606 | 25 | namespace sigc | ||
2607 | 26 | { | ||
2608 | 27 | inline bool operator==(slot_base const& lhs, slot_base const& rhs) | ||
2609 | 28 | { | ||
2610 | 29 | if (!lhs.rep_ || !rhs.rep_) | ||
2611 | 30 | return (lhs.rep_ == rhs.rep_); | ||
2612 | 31 | |||
2613 | 32 | return (lhs.rep_->call_ == rhs.rep_->call_); | ||
2614 | 33 | } | ||
2615 | 34 | |||
2616 | 35 | inline bool operator!=(slot_base const& lhs, slot_base const& rhs) | ||
2617 | 36 | { | ||
2618 | 37 | return !(lhs == rhs); | ||
2619 | 38 | } | ||
2620 | 39 | } // sigc namespace | ||
2621 | 40 | |||
2622 | 41 | namespace std | ||
2623 | 42 | { | ||
2624 | 43 | |||
2625 | 44 | template<> | ||
2626 | 45 | struct hash<sigc::slot_base> | ||
2627 | 46 | { | ||
2628 | 47 | size_t operator()(sigc::slot_base const& cb) const | ||
2629 | 48 | { | ||
2630 | 49 | if (cb.rep_) | ||
2631 | 50 | return hash<size_t>()(reinterpret_cast<size_t>(cb.rep_->call_)); | ||
2632 | 51 | |||
2633 | 52 | return hash<size_t>()(reinterpret_cast<size_t>(cb.rep_)); | ||
2634 | 53 | } | ||
2635 | 54 | }; | ||
2636 | 55 | |||
2637 | 56 | #if __GNUC__ < 6 | ||
2638 | 57 | template<class T> | ||
2639 | 58 | struct hash | ||
2640 | 59 | { | ||
2641 | 60 | size_t operator()(T const& cb) const | ||
2642 | 61 | { | ||
2643 | 62 | static_assert(std::is_base_of<sigc::slot_base, T>::value, "Type is not derived from sigc::slot_base"); | ||
2644 | 63 | return hash<sigc::slot_base>()(cb); | ||
2645 | 64 | } | ||
2646 | 65 | }; | ||
2647 | 66 | #endif | ||
2648 | 67 | |||
2649 | 68 | } // std namespace | ||
2650 | 69 | |||
2651 | 70 | #endif // __UNITY_SIGC_SLOT_HASHER__ | ||
2652 | 0 | 71 | ||
2653 | === modified file 'unity-shared/StandaloneWindowManager.cpp' | |||
2654 | --- unity-shared/StandaloneWindowManager.cpp 2015-11-20 11:33:38 +0000 | |||
2655 | +++ unity-shared/StandaloneWindowManager.cpp 2016-08-30 14:38:39 +0000 | |||
2656 | @@ -624,6 +624,9 @@ | |||
2657 | 624 | return std::string(); | 624 | return std::string(); |
2658 | 625 | } | 625 | } |
2659 | 626 | 626 | ||
2660 | 627 | void StandaloneWindowManager::SetCardinalProperty(Window, Atom, std::vector<long> const&) | ||
2661 | 628 | {} | ||
2662 | 629 | |||
2663 | 627 | std::vector<long> StandaloneWindowManager::GetCardinalProperty(Window, Atom) const | 630 | std::vector<long> StandaloneWindowManager::GetCardinalProperty(Window, Atom) const |
2664 | 628 | { | 631 | { |
2665 | 629 | return std::vector<long>(); | 632 | return std::vector<long>(); |
2666 | 630 | 633 | ||
2667 | === modified file 'unity-shared/StandaloneWindowManager.h' | |||
2668 | --- unity-shared/StandaloneWindowManager.h 2016-03-18 18:58:26 +0000 | |||
2669 | +++ unity-shared/StandaloneWindowManager.h 2016-08-30 14:38:39 +0000 | |||
2670 | @@ -165,6 +165,7 @@ | |||
2671 | 165 | virtual std::string GetWindowName(Window window_id) const; | 165 | virtual std::string GetWindowName(Window window_id) const; |
2672 | 166 | virtual bool IsOnscreenKeyboard(Window window_id) const; | 166 | virtual bool IsOnscreenKeyboard(Window window_id) const; |
2673 | 167 | virtual std::string GetStringProperty(Window window_id, Atom) const; | 167 | virtual std::string GetStringProperty(Window window_id, Atom) const; |
2674 | 168 | virtual void SetCardinalProperty(Window window_id, Atom, std::vector<long> const&); | ||
2675 | 168 | virtual std::vector<long> GetCardinalProperty(Window window_id, Atom) const; | 169 | virtual std::vector<long> GetCardinalProperty(Window window_id, Atom) const; |
2676 | 169 | 170 | ||
2677 | 170 | // Mock functions | 171 | // Mock functions |
2678 | 171 | 172 | ||
2679 | === added file 'unity-shared/SystemdWrapper.cpp' | |||
2680 | --- unity-shared/SystemdWrapper.cpp 1970-01-01 00:00:00 +0000 | |||
2681 | +++ unity-shared/SystemdWrapper.cpp 2016-08-30 14:38:39 +0000 | |||
2682 | @@ -0,0 +1,103 @@ | |||
2683 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 3 -*- | ||
2684 | 2 | /* | ||
2685 | 3 | * Copyright © 2016 Canonical Ltd | ||
2686 | 4 | * | ||
2687 | 5 | * This program is free software: you can redistribute it and/or modify | ||
2688 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
2689 | 7 | * published by the Free Software Foundation. | ||
2690 | 8 | * | ||
2691 | 9 | * This program is distributed in the hope that it will be useful, | ||
2692 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2693 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2694 | 12 | * GNU General Public License for more details. | ||
2695 | 13 | * | ||
2696 | 14 | * You should have received a copy of the GNU General Public License | ||
2697 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2698 | 16 | * | ||
2699 | 17 | * Authored by: Ted Gould <ted@canonical.com> | ||
2700 | 18 | */ | ||
2701 | 19 | |||
2702 | 20 | #include "SystemdWrapper.h" | ||
2703 | 21 | |||
2704 | 22 | #include <UnityCore/GLibDBusProxy.h> | ||
2705 | 23 | |||
2706 | 24 | namespace unity | ||
2707 | 25 | { | ||
2708 | 26 | |||
2709 | 27 | // | ||
2710 | 28 | // Start private implementation | ||
2711 | 29 | // | ||
2712 | 30 | |||
2713 | 31 | class SystemdWrapper::Impl | ||
2714 | 32 | { | ||
2715 | 33 | public: | ||
2716 | 34 | Impl(bool test); | ||
2717 | 35 | |||
2718 | 36 | void Start(std::string const& name); | ||
2719 | 37 | void Stop(std::string const& name); | ||
2720 | 38 | bool IsConnected(); | ||
2721 | 39 | |||
2722 | 40 | private: | ||
2723 | 41 | glib::DBusProxy::Ptr systemd_proxy_; | ||
2724 | 42 | }; | ||
2725 | 43 | |||
2726 | 44 | SystemdWrapper::Impl::Impl(bool test) | ||
2727 | 45 | { | ||
2728 | 46 | std::string busname = "org.freedesktop.systemd1"; | ||
2729 | 47 | if (test) { | ||
2730 | 48 | busname = "com.canonical.Unity.Test.Systemd"; | ||
2731 | 49 | } | ||
2732 | 50 | |||
2733 | 51 | systemd_proxy_ = std::make_shared<unity::glib::DBusProxy>(busname, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager"); | ||
2734 | 52 | } | ||
2735 | 53 | |||
2736 | 54 | void SystemdWrapper::Impl::Start(std::string const& name) | ||
2737 | 55 | { | ||
2738 | 56 | if (IsConnected()) { | ||
2739 | 57 | systemd_proxy_->Call("StartUnit", g_variant_new("(ss)", name.c_str(), "replace")); | ||
2740 | 58 | } | ||
2741 | 59 | } | ||
2742 | 60 | |||
2743 | 61 | void SystemdWrapper::Impl::Stop(std::string const& name) | ||
2744 | 62 | { | ||
2745 | 63 | if (IsConnected()) { | ||
2746 | 64 | systemd_proxy_->Call("StopUnit", g_variant_new("(ss)", name.c_str(), "replace")); | ||
2747 | 65 | } | ||
2748 | 66 | } | ||
2749 | 67 | |||
2750 | 68 | bool SystemdWrapper::Impl::IsConnected() | ||
2751 | 69 | { | ||
2752 | 70 | return systemd_proxy_->IsConnected(); | ||
2753 | 71 | } | ||
2754 | 72 | |||
2755 | 73 | // | ||
2756 | 74 | // End private implementation | ||
2757 | 75 | // | ||
2758 | 76 | |||
2759 | 77 | SystemdWrapper::SystemdWrapper() | ||
2760 | 78 | : pimpl_(new Impl(false)) | ||
2761 | 79 | {} | ||
2762 | 80 | |||
2763 | 81 | SystemdWrapper::SystemdWrapper(SystemdWrapper::TestMode const& tm) | ||
2764 | 82 | : pimpl_(new Impl(true)) | ||
2765 | 83 | {} | ||
2766 | 84 | |||
2767 | 85 | SystemdWrapper::~SystemdWrapper() | ||
2768 | 86 | {} | ||
2769 | 87 | |||
2770 | 88 | void SystemdWrapper::Start(std::string const& name) | ||
2771 | 89 | { | ||
2772 | 90 | pimpl_->Start(name); | ||
2773 | 91 | } | ||
2774 | 92 | |||
2775 | 93 | void SystemdWrapper::Stop(std::string const& name) | ||
2776 | 94 | { | ||
2777 | 95 | pimpl_->Stop(name); | ||
2778 | 96 | } | ||
2779 | 97 | |||
2780 | 98 | bool SystemdWrapper::IsConnected() | ||
2781 | 99 | { | ||
2782 | 100 | return pimpl_->IsConnected(); | ||
2783 | 101 | } | ||
2784 | 102 | |||
2785 | 103 | } | ||
2786 | 0 | 104 | ||
2787 | === added file 'unity-shared/SystemdWrapper.h' | |||
2788 | --- unity-shared/SystemdWrapper.h 1970-01-01 00:00:00 +0000 | |||
2789 | +++ unity-shared/SystemdWrapper.h 2016-08-30 14:38:39 +0000 | |||
2790 | @@ -0,0 +1,55 @@ | |||
2791 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
2792 | 2 | /* | ||
2793 | 3 | * Copyright © 2016 Canonical Ltd | ||
2794 | 4 | * | ||
2795 | 5 | * This program is free software: you can redistribute it and/or modify | ||
2796 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
2797 | 7 | * published by the Free Software Foundation. | ||
2798 | 8 | * | ||
2799 | 9 | * This program is distributed in the hope that it will be useful, | ||
2800 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2801 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2802 | 12 | * GNU General Public License for more details. | ||
2803 | 13 | * | ||
2804 | 14 | * You should have received a copy of the GNU General Public License | ||
2805 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2806 | 16 | * | ||
2807 | 17 | * Authored by: Ted Gould <ted@canonical.com> | ||
2808 | 18 | */ | ||
2809 | 19 | |||
2810 | 20 | #ifndef UNITY_SYSTEMD_WRAPPER | ||
2811 | 21 | #define UNITY_SYSTEMD_WRAPPER | ||
2812 | 22 | |||
2813 | 23 | #include <memory> | ||
2814 | 24 | |||
2815 | 25 | namespace unity | ||
2816 | 26 | { | ||
2817 | 27 | |||
2818 | 28 | class SystemdWrapper | ||
2819 | 29 | { | ||
2820 | 30 | public: | ||
2821 | 31 | typedef std::shared_ptr<SystemdWrapper> Ptr; | ||
2822 | 32 | |||
2823 | 33 | SystemdWrapper(); | ||
2824 | 34 | ~SystemdWrapper(); | ||
2825 | 35 | |||
2826 | 36 | void Start(std::string const& name); | ||
2827 | 37 | void Stop(std::string const& name); | ||
2828 | 38 | bool IsConnected(); | ||
2829 | 39 | |||
2830 | 40 | protected: | ||
2831 | 41 | struct TestMode {}; | ||
2832 | 42 | SystemdWrapper(TestMode const&); | ||
2833 | 43 | |||
2834 | 44 | private: | ||
2835 | 45 | // Noncopyable | ||
2836 | 46 | SystemdWrapper(SystemdWrapper const&) = delete; | ||
2837 | 47 | SystemdWrapper& operator=(SystemdWrapper const&) = delete; | ||
2838 | 48 | |||
2839 | 49 | class Impl; | ||
2840 | 50 | std::unique_ptr<Impl> pimpl_; | ||
2841 | 51 | }; | ||
2842 | 52 | |||
2843 | 53 | } | ||
2844 | 54 | |||
2845 | 55 | #endif | ||
2846 | 0 | 56 | ||
2847 | === modified file 'unity-shared/WindowManager.h' | |||
2848 | --- unity-shared/WindowManager.h 2016-03-18 18:58:26 +0000 | |||
2849 | +++ unity-shared/WindowManager.h 2016-08-30 14:38:39 +0000 | |||
2850 | @@ -170,6 +170,7 @@ | |||
2851 | 170 | virtual bool IsOnscreenKeyboard(Window window_id) const = 0; | 170 | virtual bool IsOnscreenKeyboard(Window window_id) const = 0; |
2852 | 171 | 171 | ||
2853 | 172 | virtual std::string GetStringProperty(Window, Atom) const = 0; | 172 | virtual std::string GetStringProperty(Window, Atom) const = 0; |
2854 | 173 | virtual void SetCardinalProperty(Window, Atom, std::vector<long> const&) = 0; | ||
2855 | 173 | virtual std::vector<long> GetCardinalProperty(Window, Atom) const = 0; | 174 | virtual std::vector<long> GetCardinalProperty(Window, Atom) const = 0; |
2856 | 174 | 175 | ||
2857 | 175 | virtual Cursor GetCachedCursor(unsigned int cursor_name) const = 0; | 176 | virtual Cursor GetCachedCursor(unsigned int cursor_name) const = 0; |
2858 | 176 | 177 | ||
2859 | === modified file 'unity-shared/XWindowManager.cpp' | |||
2860 | --- unity-shared/XWindowManager.cpp 2015-01-21 15:28:59 +0000 | |||
2861 | +++ unity-shared/XWindowManager.cpp 2016-08-30 14:38:39 +0000 | |||
2862 | @@ -123,6 +123,12 @@ | |||
2863 | 123 | return std::string(val, n_items); | 123 | return std::string(val, n_items); |
2864 | 124 | } | 124 | } |
2865 | 125 | 125 | ||
2866 | 126 | void XWindowManager::SetCardinalProperty(Window window_id, Atom atom, std::vector<long> const& values) | ||
2867 | 127 | { | ||
2868 | 128 | XChangeProperty(screen->dpy(), window_id, atom, XA_CARDINAL, 32, PropModeReplace, | ||
2869 | 129 | (unsigned char *) values.data(), values.size()); | ||
2870 | 130 | } | ||
2871 | 131 | |||
2872 | 126 | std::vector<long> XWindowManager::GetCardinalProperty(Window window_id, Atom atom) const | 132 | std::vector<long> XWindowManager::GetCardinalProperty(Window window_id, Atom atom) const |
2873 | 127 | { | 133 | { |
2874 | 128 | Atom type; | 134 | Atom type; |
2875 | 129 | 135 | ||
2876 | === modified file 'unity-shared/XWindowManager.h' | |||
2877 | --- unity-shared/XWindowManager.h 2015-01-21 15:28:59 +0000 | |||
2878 | +++ unity-shared/XWindowManager.h 2016-08-30 14:38:39 +0000 | |||
2879 | @@ -36,6 +36,7 @@ | |||
2880 | 36 | std::string GetWindowName(Window window_id) const; | 36 | std::string GetWindowName(Window window_id) const; |
2881 | 37 | bool IsOnscreenKeyboard(Window window_id) const; | 37 | bool IsOnscreenKeyboard(Window window_id) const; |
2882 | 38 | std::string GetStringProperty(Window window_id, Atom atom) const; | 38 | std::string GetStringProperty(Window window_id, Atom atom) const; |
2883 | 39 | void SetCardinalProperty(Window, Atom, std::vector<long> const&); | ||
2884 | 39 | std::vector<long> GetCardinalProperty(Window, Atom) const; | 40 | std::vector<long> GetCardinalProperty(Window, Atom) const; |
2885 | 40 | }; | 41 | }; |
2886 | 41 | 42 | ||
2887 | 42 | 43 | ||
2888 | === modified file 'unity7.conf.in' | |||
2889 | --- unity7.conf.in 2016-07-21 13:01:59 +0000 | |||
2890 | +++ unity7.conf.in 2016-08-30 14:38:39 +0000 | |||
2891 | @@ -4,27 +4,7 @@ | |||
2892 | 4 | start on xsession SESSION=ubuntu and started unity-settings-daemon | 4 | start on xsession SESSION=ubuntu and started unity-settings-daemon |
2893 | 5 | stop on desktop-end | 5 | stop on desktop-end |
2894 | 6 | 6 | ||
2916 | 7 | pre-start script | 7 | pre-start exec @CMAKE_INSTALL_LIBDIR@/unity/unity-compiz-profile-select |
2896 | 8 | # If gnome-session is going to start compiz, | ||
2897 | 9 | # we don't want to be the ones doing it. | ||
2898 | 10 | |||
2899 | 11 | if grep -q compiz /usr/share/gnome-session/sessions/ubuntu.session ; then | ||
2900 | 12 | echo "GNOME Session is starting Compiz" | ||
2901 | 13 | stop ; exit 0 | ||
2902 | 14 | fi | ||
2903 | 15 | |||
2904 | 16 | compiz_profile="ubuntu" | ||
2905 | 17 | |||
2906 | 18 | if ! /usr/lib/nux/unity_support_test -p; then | ||
2907 | 19 | compiz_profile="ubuntu-lowgfx" | ||
2908 | 20 | fi | ||
2909 | 21 | |||
2910 | 22 | echo "Using compiz profile '$compiz_profile'" | ||
2911 | 23 | initctl set-env -g COMPIZ_CONFIG_PROFILE="$compiz_profile" | ||
2912 | 24 | export COMPIZ_CONFIG_PROFILE="$compiz_profile" | ||
2913 | 25 | |||
2914 | 26 | ${CMAKE_INSTALL_FULL_LIBDIR}/unity/unity-active-plugins-safety-check | ||
2915 | 27 | end script | ||
2917 | 28 | 8 | ||
2918 | 29 | respawn | 9 | respawn |
2919 | 30 | exec compiz | 10 | exec compiz |
2920 | 31 | 11 | ||
2921 | === added file 'unity7.override' | |||
2922 | --- unity7.override 1970-01-01 00:00:00 +0000 | |||
2923 | +++ unity7.override 2016-08-30 14:38:39 +0000 | |||
2924 | @@ -0,0 +1,1 @@ | |||
2925 | 1 | manual | ||
2926 | 0 | 2 | ||
2927 | === added file 'unity7.service.in' | |||
2928 | --- unity7.service.in 1970-01-01 00:00:00 +0000 | |||
2929 | +++ unity7.service.in 2016-08-30 14:38:39 +0000 | |||
2930 | @@ -0,0 +1,11 @@ | |||
2931 | 1 | [Unit] | ||
2932 | 2 | Description=Unity Shell v7 | ||
2933 | 3 | Requires=unity-settings-daemon.service unity-panel-service.service bamfdaemon.service | ||
2934 | 4 | Wants=unity-gtk-module.service | ||
2935 | 5 | After=unity-settings-daemon.service | ||
2936 | 6 | PartOf=graphical-session.target | ||
2937 | 7 | |||
2938 | 8 | [Service] | ||
2939 | 9 | ExecStart=/usr/bin/compiz | ||
2940 | 10 | ExecStart.Pre=@CMAKE_INSTALL_LIBDIR@/unity/unity-compiz-profile-select | ||
2941 | 11 | Restart=on-failure |