Merge lp:~3v1n0/unity/panel-gradient-scaling into lp:unity

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
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

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
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2016-07-21 13:01:59 +0000
+++ CMakeLists.txt 2016-08-30 14:38:39 +0000
@@ -429,5 +429,15 @@
429#429#
430# Upstart430# Upstart
431#431#
432configure_file(unity7.conf.in ${CMAKE_CURRENT_BINARY_DIR}/unity7.conf)432
433configure_file(unity7.conf.in ${CMAKE_CURRENT_BINARY_DIR}/unity7.conf @ONLY)
433install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity7.conf DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/sessions)434install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity7.conf DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/sessions)
435
436#
437# Systemd
438#
439
440configure_file(unity7.service.in ${CMAKE_CURRENT_BINARY_DIR}/unity7.service @ONLY)
441pkg_get_variable(SYSTEMD_USER_DIR systemd systemduserunitdir)
442install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity7.service DESTINATION ${SYSTEMD_USER_DIR})
443install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/unity7.override DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/systemd-session/upstart)
434444
=== modified file 'debian/control'
--- debian/control 2016-07-25 18:20:16 +0000
+++ debian/control 2016-08-30 14:38:39 +0000
@@ -53,6 +53,7 @@
53 python3 (>= 3.4),53 python3 (>= 3.4),
54 python-setuptools,54 python-setuptools,
55 quilt,55 quilt,
56 systemd,
56 xserver-xorg-video-dummy,57 xserver-xorg-video-dummy,
57 xsltproc,58 xsltproc,
58Standards-Version: 3.9.559Standards-Version: 3.9.5
@@ -81,12 +82,31 @@
81 libxfixes3 (>= 1:5.0.1-1),82 libxfixes3 (>= 1:5.0.1-1),
82 libxi6 (>= 2:1.7.1.901),83 libxi6 (>= 2:1.7.1.901),
83 unity-scope-home,84 unity-scope-home,
84Provides: indicator-renderer
85Recommends: unity-control-center,85Recommends: unity-control-center,
86 ${unity-default-masterscopes}86 ${unity-default-masterscopes}
87 nautilus,87 nautilus,
88 gnome-disk-utility,88 gnome-disk-utility,
89 indicator-appmenu (>= 15.02.0),89 hud,
90 session-shortcuts,
91Breaks: unity-lens-applications (<< 5.12.0-0ubuntu2),
92 unity-lens-files (<< 5.10.0-0ubuntu2),
93 unity-lens-music (<< 6.0.0),
94 unity-lens-video (<< 0.3.6-0ubuntu2),
95Description: Interface designed for efficiency of space and interaction.
96 Unity is a desktop experience that sings. Designed by Canonical and the Ayatana
97 community, Unity is all about the combination of familiarity and the future. We
98 bring together visual design, analysis of user experience testing, modern
99 graphics technologies and a deep understanding of the free software landscape
100 to produce what we hope will be the lightest, most elegant and most delightful
101 way to use your PC.
102
103Package: unity-services
104Architecture: any
105Depends: ${shlibs:Depends},
106 ${misc:Depends},
107 indicator-common,
108Provides: indicator-renderer
109Recommends: indicator-appmenu (>= 15.02.0),
90 indicator-application,110 indicator-application,
91 indicator-sound,111 indicator-sound,
92 indicator-bluetooth,112 indicator-bluetooth,
@@ -96,24 +116,6 @@
96 indicator-printers,116 indicator-printers,
97 indicator-power,117 indicator-power,
98 indicator-session,118 indicator-session,
99 hud,
100 session-shortcuts,
101Breaks: unity-lens-applications (<< 5.12.0-0ubuntu2),
102 unity-lens-files (<< 5.10.0-0ubuntu2),
103 unity-lens-music (<< 6.0.0),
104 unity-lens-video (<< 0.3.6-0ubuntu2),
105Description: Interface designed for efficiency of space and interaction.
106 Unity is a desktop experience that sings. Designed by Canonical and the Ayatana
107 community, Unity is all about the combination of familiarity and the future. We
108 bring together visual design, analysis of user experience testing, modern
109 graphics technologies and a deep understanding of the free software landscape
110 to produce what we hope will be the lightest, most elegant and most delightful
111 way to use your PC.
112
113Package: unity-services
114Architecture: any
115Depends: ${shlibs:Depends},
116 ${misc:Depends},
117Description: Services for the Unity interface119Description: Services for the Unity interface
118 Unity is a desktop experience that sings. Designed by Canonical and the Ayatana120 Unity is a desktop experience that sings. Designed by Canonical and the Ayatana
119 community, Unity is all about the combination of familiarity and the future. We121 community, Unity is all about the combination of familiarity and the future. We
120122
=== modified file 'debian/libunity-core-6.0-9.install'
--- debian/libunity-core-6.0-9.install 2016-07-26 16:45:34 +0000
+++ debian/libunity-core-6.0-9.install 2016-08-30 14:38:39 +0000
@@ -2,8 +2,9 @@
2usr/lib/*/unity/*.py2usr/lib/*/unity/*.py
3usr/share/ccsm3usr/share/ccsm
4usr/share/gnome-control-center/4usr/share/gnome-control-center/
5usr/share/unity5usr/share/unity/icons
6usr/share/upstart/sessions/unity7.conf6usr/share/unity/themes
7debian/unity-crashdb.conf etc/apport/crashdb.conf.d/7debian/unity-crashdb.conf etc/apport/crashdb.conf.d/
8debian/source_unity.py usr/share/apport/package-hooks8debian/source_unity.py usr/share/apport/package-hooks
9tools/convert-files/* usr/lib/compiz/migration/9tools/convert-files/* usr/lib/compiz/migration/
10usr/share/upstart/sessions/unity7.conf
1011
=== modified file 'debian/unity-services.install'
--- debian/unity-services.install 2016-07-26 13:58:14 +0000
+++ debian/unity-services.install 2016-08-30 14:38:39 +0000
@@ -1,3 +1,6 @@
1usr/lib/*/unity/*service1usr/lib/*/unity/*service
2usr/share/upstart/sessions/unity-panel-service*.conf2usr/share/upstart/sessions/unity-panel*
3usr/share/upstart/systemd-session/upstart/unity-panel*
4usr/lib/systemd/user/unity-panel*
5usr/lib/systemd/user/unity-screen-locked.target
3usr/share/man/*/unity-panel-service.16usr/share/man/*/unity-panel-service.1
47
=== added file 'debian/unity-services.links'
--- debian/unity-services.links 1970-01-01 00:00:00 +0000
+++ debian/unity-services.links 2016-08-30 14:38:39 +0000
@@ -0,0 +1,13 @@
1/usr/lib/systemd/user/indicator-application.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-application.service
2/usr/lib/systemd/user/indicator-bluetooth.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-bluetooth.service
3/usr/lib/systemd/user/indicator-datetime.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-datetime.service
4/usr/lib/systemd/user/indicator-keyboard.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-keyboard.service
5/usr/lib/systemd/user/indicator-messages.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-messages.service
6/usr/lib/systemd/user/indicator-power.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-power.service
7/usr/lib/systemd/user/indicator-session.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-session.service
8/usr/lib/systemd/user/indicator-sound.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-sound.service
9/usr/lib/systemd/user/indicator-datetime.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-datetime.service
10/usr/lib/systemd/user/indicator-keyboard.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-keyboard.service
11/usr/lib/systemd/user/indicator-power.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-power.service
12/usr/lib/systemd/user/indicator-session.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-session.service
13/usr/lib/systemd/user/indicator-sound.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-sound.service
014
=== modified file 'debian/unity.install'
--- debian/unity.install 2016-07-26 16:45:34 +0000
+++ debian/unity.install 2016-08-30 14:38:39 +0000
@@ -2,6 +2,9 @@
2usr/bin2usr/bin
3usr/lib/*/compiz/libunity*.so3usr/lib/*/compiz/libunity*.so
4usr/lib/*/unity/unity-active-plugins-safety-check4usr/lib/*/unity/unity-active-plugins-safety-check
5usr/lib/*/unity/unity-compiz-profile-select
5usr/share/man/*/unity.16usr/share/man/*/unity.1
6usr/share/compiz7usr/share/compiz
7usr/share/locale8usr/share/locale
9usr/lib/systemd/user/unity7.service
10usr/share/upstart/systemd-session/upstart/unity7.override
811
=== modified file 'decorations/DecoratedWindow.cpp'
--- decorations/DecoratedWindow.cpp 2016-08-06 16:24:45 +0000
+++ decorations/DecoratedWindow.cpp 2016-08-30 14:38:39 +0000
@@ -37,7 +37,6 @@
37{37{
38namespace38namespace
39{39{
40const std::string MENUS_PANEL_NAME = "WindowLIM";
41const int SHADOW_BLUR_MARGIN_FACTOR = 2;40const int SHADOW_BLUR_MARGIN_FACTOR = 2;
42}41}
4342
@@ -55,7 +54,6 @@
55 , deco_elements_(cu::DecorationElement::NONE)54 , deco_elements_(cu::DecorationElement::NONE)
56 , last_mwm_decor_(win_->mwmDecor())55 , last_mwm_decor_(win_->mwmDecor())
57 , last_actions_(win_->actions())56 , last_actions_(win_->actions())
58 , panel_id_(MENUS_PANEL_NAME + std::to_string(win_->id()))
59 , cv_(Settings::Instance().em())57 , cv_(Settings::Instance().em())
60{58{
61 active.changed.connect([this] (bool active) {59 active.changed.connect([this] (bool active) {
@@ -932,18 +930,13 @@
932 sliding_layout->mouse_owner = grab_edge_->mouse_owner();930 sliding_layout->mouse_owner = grab_edge_->mouse_owner();
933}931}
934932
935inline std::string const& Window::Impl::GetMenusPanelID() const
936{
937 return panel_id_;
938}
939
940void Window::Impl::UnsetAppMenu()933void Window::Impl::UnsetAppMenu()
941{934{
942 if (!menus_)935 if (!menus_)
943 return;936 return;
944937
945 auto const& indicators = manager_->impl_->menu_manager_->Indicators();938 auto const& indicators = manager_->impl_->menu_manager_->Indicators();
946 indicators->SyncGeometries(GetMenusPanelID(), indicator::EntryLocationMap());939 indicators->SyncGeometries(menus_->MenubarId(), indicator::EntryLocationMap());
947 sliding_layout_->SetInputItem(nullptr);940 sliding_layout_->SetInputItem(nullptr);
948 grab_mouse_changed_->disconnect();941 grab_mouse_changed_->disconnect();
949}942}
@@ -956,7 +949,7 @@
956 auto const& indicators = manager_->impl_->menu_manager_->Indicators();949 auto const& indicators = manager_->impl_->menu_manager_->Indicators();
957 indicator::EntryLocationMap map;950 indicator::EntryLocationMap map;
958 menus_->ChildrenGeometries(map);951 menus_->ChildrenGeometries(map);
959 indicators->SyncGeometries(GetMenusPanelID(), map);952 indicators->SyncGeometries(menus_->MenubarId(), map);
960}953}
961954
962bool Window::Impl::ActivateMenu(std::string const& entry_id)955bool Window::Impl::ActivateMenu(std::string const& entry_id)
963956
=== modified file 'decorations/DecorationsMenuLayout.cpp'
--- decorations/DecorationsMenuLayout.cpp 2015-02-03 10:04:17 +0000
+++ decorations/DecorationsMenuLayout.cpp 2016-08-30 14:38:39 +0000
@@ -25,6 +25,10 @@
25{25{
26namespace decoration26namespace decoration
27{27{
28namespace
29{
30const std::string MENUS_PANEL_NAME = "WindowLIM";
31}
2832
29using namespace indicator;33using namespace indicator;
3034
@@ -33,8 +37,8 @@
33 , show_now(false)37 , show_now(false)
34 , menu_manager_(menu)38 , menu_manager_(menu)
35 , win_(win)39 , win_(win)
36 , last_pointer_(-1, -1)
37 , dropdown_(std::make_shared<MenuDropdown>(menu_manager_->Indicators(), win))40 , dropdown_(std::make_shared<MenuDropdown>(menu_manager_->Indicators(), win))
41 , menubar_id_(MENUS_PANEL_NAME + std::to_string(win_->id()))
38{42{
39 visible = false;43 visible = false;
40}44}
@@ -91,6 +95,11 @@
91 Relayout();95 Relayout();
92}96}
9397
98std::string const& MenuLayout::MenubarId() const
99{
100 return menubar_id_;
101}
102
94bool MenuLayout::ActivateMenu(std::string const& entry_id)103bool MenuLayout::ActivateMenu(std::string const& entry_id)
95{104{
96 MenuEntry::Ptr target;105 MenuEntry::Ptr target;
@@ -117,16 +126,29 @@
117 if (!activated)126 if (!activated)
118 activated = dropdown_->ActivateChild(target);127 activated = dropdown_->ActivateChild(target);
119128
120 if (activated)
121 {
122 // Since this generally happens on keyboard activation we need to avoid that
123 // the mouse position would interfere with this
124 last_pointer_.set(pointerX, pointerY);
125 }
126
127 return activated;129 return activated;
128}130}
129131
132bool MenuLayout::ActivateMenu(CompPoint const& pos)
133{
134 if (!Geometry().contains(pos))
135 return false;
136
137 for (auto const& item : items_)
138 {
139 if (!item->visible() || !item->sensitive())
140 continue;
141
142 if (item->Geometry().contains(pos))
143 {
144 std::static_pointer_cast<MenuEntry>(item)->ShowMenu(1);
145 return true;
146 }
147 }
148
149 return false;
150}
151
130void MenuLayout::OnEntryMouseOwnershipChanged(bool owner)152void MenuLayout::OnEntryMouseOwnershipChanged(bool owner)
131{153{
132 mouse_owner = owner;154 mouse_owner = owner;
@@ -154,39 +176,15 @@
154{176{
155 active = actived;177 active = actived;
156178
157 if (active && !pointer_tracker_ && items_.size() > 1)179 if (active && items_.size() > 1)
158 {180 {
159 pointer_tracker_.reset(new glib::Timeout(16));181 menu_manager_->RegisterTracker(menubar_id_, (sigc::track_obj([this] (int x, int y, double speed) {
160 pointer_tracker_->Run([this] {182 ActivateMenu(CompPoint(x, y));
161 Window win;183 }, *this)));
162 int i, x, y;
163 unsigned int ui;
164
165 XQueryPointer(screen->dpy(), screen->root(), &win, &win, &x, &y, &i, &i, &ui);
166
167 if (last_pointer_.x() != x || last_pointer_.y() != y)
168 {
169 last_pointer_.set(x, y);
170
171 for (auto const& item : items_)
172 {
173 if (!item->visible() || !item->sensitive())
174 continue;
175
176 if (item->Geometry().contains(last_pointer_))
177 {
178 std::static_pointer_cast<MenuEntry>(item)->ShowMenu(1);
179 break;
180 }
181 }
182 }
183
184 return true;
185 });
186 }184 }
187 else if (!active)185 else if (!active)
188 {186 {
189 pointer_tracker_.reset();187 menu_manager_->UnregisterTracker(menubar_id_);
190 }188 }
191}189}
192190
193191
=== modified file 'decorations/DecorationsMenuLayout.h'
--- decorations/DecorationsMenuLayout.h 2014-02-13 03:01:30 +0000
+++ decorations/DecorationsMenuLayout.h 2016-08-30 14:38:39 +0000
@@ -42,7 +42,9 @@
4242
43 void Setup();43 void Setup();
44 bool ActivateMenu(std::string const& entry_id);44 bool ActivateMenu(std::string const& entry_id);
45 bool ActivateMenu(CompPoint const&);
45 void ChildrenGeometries(indicator::EntryLocationMap&) const;46 void ChildrenGeometries(indicator::EntryLocationMap&) const;
47 std::string const& MenubarId() const;
4648
47protected:49protected:
48 void DoRelayout() override;50 void DoRelayout() override;
@@ -55,10 +57,9 @@
5557
56 menu::Manager::Ptr menu_manager_;58 menu::Manager::Ptr menu_manager_;
57 CompWindow* win_;59 CompWindow* win_;
58 CompPoint last_pointer_;
59 glib::Source::UniquePtr pointer_tracker_;
60 glib::Source::UniquePtr show_now_timeout_;60 glib::Source::UniquePtr show_now_timeout_;
61 std::shared_ptr<MenuDropdown> dropdown_;61 std::shared_ptr<MenuDropdown> dropdown_;
62 std::string menubar_id_;
62};63};
6364
64} // decoration namespace65} // decoration namespace
6566
=== modified file 'decorations/DecorationsPriv.h'
--- decorations/DecorationsPriv.h 2016-08-06 16:24:45 +0000
+++ decorations/DecorationsPriv.h 2016-08-30 14:38:39 +0000
@@ -162,7 +162,6 @@
162 connection::Wrapper dpi_changed_;162 connection::Wrapper dpi_changed_;
163 connection::Wrapper grab_mouse_changed_;163 connection::Wrapper grab_mouse_changed_;
164 std::string last_title_;164 std::string last_title_;
165 std::string panel_id_;
166 std::vector<cu::SimpleTextureQuad> bg_textures_;165 std::vector<cu::SimpleTextureQuad> bg_textures_;
167 cu::PixmapTexture::Ptr shaped_shadow_pixmap_;166 cu::PixmapTexture::Ptr shaped_shadow_pixmap_;
168 std::shared_ptr<ForceQuitDialog> force_quit_;167 std::shared_ptr<ForceQuitDialog> force_quit_;
169168
=== modified file 'launcher/EdgeBarrierController.cpp'
--- launcher/EdgeBarrierController.cpp 2015-12-23 09:29:24 +0000
+++ launcher/EdgeBarrierController.cpp 2016-08-30 14:38:39 +0000
@@ -25,6 +25,7 @@
25#include <NuxCore/Logger.h>25#include <NuxCore/Logger.h>
26#include "unity-shared/UnitySettings.h"26#include "unity-shared/UnitySettings.h"
27#include "unity-shared/UScreen.h"27#include "unity-shared/UScreen.h"
28#include "unity-shared/InputMonitor.h"
28#include "UnityCore/GLibSource.h"29#include "UnityCore/GLibSource.h"
2930
30namespace unity31namespace unity
@@ -36,50 +37,12 @@
36{37{
37 int const Y_BREAK_BUFFER = 20;38 int const Y_BREAK_BUFFER = 20;
38 int const X_BREAK_BUFFER = 20;39 int const X_BREAK_BUFFER = 20;
39 int const MAJOR = 2;
40 int const MINOR = 3;
41}40}
4241
43DECLARE_LOGGER(logger, "unity.edge_barrier_controller");42DECLARE_LOGGER(logger, "unity.edge_barrier_controller");
4443
45int GetXI2OpCode()
46{
47 Display *dpy = nux::GetGraphicsDisplay()->GetX11Display();
48
49 int opcode, event_base, error_base;
50 if (!XQueryExtension(dpy, "XFIXES",
51 &opcode,
52 &event_base,
53 &error_base))
54 {
55 LOG_ERROR(logger) << "Missing XFixes";
56 return -1;
57 }
58
59 if (!XQueryExtension (dpy, "XInputExtension",
60 &opcode,
61 &event_base,
62 &error_base))
63 {
64 LOG_ERROR(logger) << "Missing XInput";
65 return -1;
66 }
67
68 int maj = MAJOR;
69 int min = MINOR;
70
71 if (XIQueryVersion(dpy, &maj, &min) == BadRequest)
72 {
73 LOG_ERROR(logger) << "Need XInput version 2.3";
74 return -1;
75 }
76
77 return opcode;
78}
79
80EdgeBarrierController::Impl::Impl(EdgeBarrierController *parent)44EdgeBarrierController::Impl::Impl(EdgeBarrierController *parent)
81 : xi2_opcode_(-1)45 : edge_overcome_pressure_(0)
82 , edge_overcome_pressure_(0)
83 , parent_(parent)46 , parent_(parent)
84{47{
85 UScreen *uscreen = UScreen::GetDefault();48 UScreen *uscreen = UScreen::GetDefault();
@@ -119,8 +82,6 @@
119 options->option_changed.connect(sigc::mem_fun(this, &EdgeBarrierController::Impl::OnOptionsChanged));82 options->option_changed.connect(sigc::mem_fun(this, &EdgeBarrierController::Impl::OnOptionsChanged));
120 SetupBarriers(UScreen::GetDefault()->GetMonitors());83 SetupBarriers(UScreen::GetDefault()->GetMonitors());
121 });84 });
122
123 xi2_opcode_ = GetXI2OpCode();
124}85}
12586
126EdgeBarrierController::Impl::~Impl()87EdgeBarrierController::Impl::~Impl()
@@ -202,36 +163,30 @@
202 }163 }
203}164}
204165
205void SetupXI2Events()
206{
207 Display *dpy = nux::GetGraphicsDisplay()->GetX11Display();
208
209 unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
210 XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits };
211
212 XISetMask(mask.mask, XI_BarrierHit);
213 XISetMask(mask.mask, XI_BarrierLeave);
214 XISelectEvents (dpy, DefaultRootWindow(dpy), &mask, 1);
215}
216
217void EdgeBarrierController::Impl::SetupBarriers(std::vector<nux::Geometry> const& layout)166void EdgeBarrierController::Impl::SetupBarriers(std::vector<nux::Geometry> const& layout)
218{167{
219 if (parent_->force_disable())168 if (parent_->force_disable())
220 return;169 return;
221170
171 size_t monitors_size = layout.size();
172 auto launcher_position = Settings::Instance().launcher_position();
222 bool edge_resist = parent_->sticky_edges();173 bool edge_resist = parent_->sticky_edges();
223 auto launcher_position = Settings::Instance().launcher_position();174 bool needs_barrier = edge_resist && monitors_size > 1;
224175 bool needs_vertical_barrier = needs_barrier;
225 for (unsigned i = 0; i < layout.size(); i++)176
177 if (parent_->options()->hide_mode() != launcher::LauncherHideMode::LAUNCHER_HIDE_NEVER)
178 needs_vertical_barrier = true;
179
180 for (unsigned i = 0; i < layout.size(); ++i)
226 {181 {
227 auto vertical_barrier = vertical_barriers_[i];182 auto const& vertical_barrier = vertical_barriers_[i];
228 auto horizontal_barrier = horizontal_barriers_[i];183 auto const& horizontal_barrier = horizontal_barriers_[i];
229 auto monitor = layout[i];184 auto const& monitor = layout[i];
230185
231 vertical_barrier->DestroyBarrier();186 vertical_barrier->DestroyBarrier();
232 horizontal_barrier->DestroyBarrier();187 horizontal_barrier->DestroyBarrier();
233188
234 if (edge_resist)189 if (needs_barrier)
235 {190 {
236 horizontal_barrier->x1 = monitor.x;191 horizontal_barrier->x1 = monitor.x;
237 horizontal_barrier->x2 = monitor.x + monitor.width;192 horizontal_barrier->x2 = monitor.x + monitor.width;
@@ -246,7 +201,7 @@
246 horizontal_barrier->ConstructBarrier();201 horizontal_barrier->ConstructBarrier();
247 }202 }
248203
249 if (!edge_resist && parent_->options()->hide_mode() == launcher::LauncherHideMode::LAUNCHER_HIDE_NEVER)204 if (!needs_vertical_barrier)
250 continue;205 continue;
251206
252 if (launcher_position == LauncherPosition::LEFT)207 if (launcher_position == LauncherPosition::LEFT)
@@ -273,8 +228,10 @@
273 vertical_barrier->ConstructBarrier();228 vertical_barrier->ConstructBarrier();
274 }229 }
275230
276 SetupXI2Events();231 if (needs_barrier || needs_vertical_barrier)
277 AddEventFilter();232 input::Monitor::Get().RegisterClient(input::Events::BARRIER, sigc::mem_fun(this, &Impl::HandleEvent));
233 else
234 input::Monitor::Get().UnregisterClient(sigc::mem_fun(this, &Impl::HandleEvent));
278235
279 float decay_responsiveness_mult = ((parent_->options()->edge_responsiveness() - 1) * .3f) + 1;236 float decay_responsiveness_mult = ((parent_->options()->edge_responsiveness() - 1) * .3f) + 1;
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;
@@ -283,65 +240,25 @@
283 edge_overcome_pressure_ = parent_->options()->edge_overcome_pressure() * overcome_responsiveness_mult;240 edge_overcome_pressure_ = parent_->options()->edge_overcome_pressure() * overcome_responsiveness_mult;
284}241}
285242
286void EdgeBarrierController::Impl::AddEventFilter()243void EdgeBarrierController::Impl::HandleEvent(XEvent const& xevent)
287{244{
288 // Remove an old one, if it exists245 if (xevent.xcookie.evtype != XI_BarrierHit)
289 nux::GetGraphicsDisplay()->RemoveEventFilter(this);246 return;
290247
291 nux::GraphicsDisplay::EventFilterArg event_filter;248 auto* barrier_event = reinterpret_cast<XIBarrierEvent*>(xevent.xcookie.data);
292 event_filter.filter = &HandleEventCB;249 PointerBarrierWrapper::Ptr const& wrapper = FindBarrierEventOwner(barrier_event);
293 event_filter.data = this;250
294251 if (wrapper)
295 nux::GetGraphicsDisplay()->AddEventFilter(event_filter);252 wrapper->HandleBarrierEvent(barrier_event);
296}
297
298bool EdgeBarrierController::Impl::HandleEvent(XEvent xevent)
299{
300 Display *dpy = nux::GetGraphicsDisplay()->GetX11Display();
301 XGenericEventCookie *cookie = &xevent.xcookie;
302 bool ret = false;
303
304 switch (cookie->evtype)
305 {
306 case (XI_BarrierHit):
307 {
308 if (XGetEventData(dpy, cookie))
309 {
310 XIBarrierEvent* barrier_event = (XIBarrierEvent*)cookie->data;
311 PointerBarrierWrapper::Ptr wrapper = FindBarrierEventOwner(barrier_event);
312
313 if (wrapper)
314 ret = wrapper->HandleBarrierEvent(barrier_event);
315 }
316
317 XFreeEventData(dpy, cookie);
318 break;
319 }
320 default:
321 break;
322 }
323
324 return ret;
325}
326
327bool EdgeBarrierController::Impl::HandleEventCB(XEvent xevent, void* data)
328{
329 auto edge_barrier_controller = static_cast<EdgeBarrierController::Impl*>(data);
330 int const xi2_opcode = edge_barrier_controller->xi2_opcode_;
331
332 if (xevent.type != GenericEvent || xevent.xcookie.extension != xi2_opcode)
333 return false;
334
335 return edge_barrier_controller->HandleEvent(xevent);
336}253}
337254
338PointerBarrierWrapper::Ptr EdgeBarrierController::Impl::FindBarrierEventOwner(XIBarrierEvent* barrier_event)255PointerBarrierWrapper::Ptr EdgeBarrierController::Impl::FindBarrierEventOwner(XIBarrierEvent* barrier_event)
339{256{
340 for (auto barrier : vertical_barriers_)257 for (auto const& barrier : vertical_barriers_)
341 if (barrier->OwnsBarrierEvent(barrier_event->barrier))258 if (barrier->OwnsBarrierEvent(barrier_event->barrier))
342 return barrier;259 return barrier;
343260
344 for (auto barrier : horizontal_barriers_)261 for (auto const& barrier : horizontal_barriers_)
345 if (barrier->OwnsBarrierEvent(barrier_event->barrier))262 if (barrier->OwnsBarrierEvent(barrier_event->barrier))
346 return barrier;263 return barrier;
347264
348265
=== modified file 'launcher/EdgeBarrierControllerPrivate.h'
--- launcher/EdgeBarrierControllerPrivate.h 2015-12-23 09:29:24 +0000
+++ launcher/EdgeBarrierControllerPrivate.h 2016-08-30 14:38:39 +0000
@@ -53,12 +53,8 @@
53 bool EventIsInsideYBreakZone(BarrierEvent::Ptr const& event);53 bool EventIsInsideYBreakZone(BarrierEvent::Ptr const& event);
54 bool EventIsInsideXBreakZone(BarrierEvent::Ptr const& event);54 bool EventIsInsideXBreakZone(BarrierEvent::Ptr const& event);
5555
56 void AddEventFilter();
57
58 PointerBarrierWrapper::Ptr FindBarrierEventOwner(XIBarrierEvent* barrier_event);56 PointerBarrierWrapper::Ptr FindBarrierEventOwner(XIBarrierEvent* barrier_event);
5957 void HandleEvent(XEvent const&);
60 static bool HandleEventCB(XEvent event, void* data);
61 bool HandleEvent(XEvent event);
6258
63 std::vector<PointerBarrierWrapper::Ptr> vertical_barriers_;59 std::vector<PointerBarrierWrapper::Ptr> vertical_barriers_;
64 std::vector<PointerBarrierWrapper::Ptr> horizontal_barriers_;60 std::vector<PointerBarrierWrapper::Ptr> horizontal_barriers_;
@@ -68,7 +64,6 @@
6864
69 Decaymulator decaymulator_;65 Decaymulator decaymulator_;
70 glib::Source::UniquePtr release_timeout_;66 glib::Source::UniquePtr release_timeout_;
71 int xi2_opcode_;
72 float edge_overcome_pressure_;67 float edge_overcome_pressure_;
73 EdgeBarrierController* parent_;68 EdgeBarrierController* parent_;
74};69};
7570
=== modified file 'lockscreen/KylinLockScreenShield.cpp'
--- lockscreen/KylinLockScreenShield.cpp 2015-12-07 03:09:28 +0000
+++ lockscreen/KylinLockScreenShield.cpp 2016-08-30 14:38:39 +0000
@@ -37,7 +37,7 @@
37 Accelerators::Ptr const& accelerators,37 Accelerators::Ptr const& accelerators,
38 nux::ObjectPtr<AbstractUserPromptView> const& prompt_view,38 nux::ObjectPtr<AbstractUserPromptView> const& prompt_view,
39 int monitor_num, bool is_primary)39 int monitor_num, bool is_primary)
40 : BaseShield(session_manager, nullptr, accelerators, prompt_view, monitor_num, is_primary)40 : BaseShield(session_manager, accelerators, prompt_view, monitor_num, is_primary)
41{41{
42 is_primary ? ShowPrimaryView() : ShowSecondaryView();42 is_primary ? ShowPrimaryView() : ShowSecondaryView();
43 EnableInputWindow(true);43 EnableInputWindow(true);
4444
=== modified file 'lockscreen/LockScreenBaseShield.cpp'
--- lockscreen/LockScreenBaseShield.cpp 2015-12-03 14:13:10 +0000
+++ lockscreen/LockScreenBaseShield.cpp 2016-08-30 14:38:39 +0000
@@ -38,7 +38,6 @@
38}38}
3939
40BaseShield::BaseShield(session::Manager::Ptr const& session,40BaseShield::BaseShield(session::Manager::Ptr const& session,
41 indicator::Indicators::Ptr const& indicators,
42 Accelerators::Ptr const& accelerators,41 Accelerators::Ptr const& accelerators,
43 nux::ObjectPtr<AbstractUserPromptView> const& prompt_view,42 nux::ObjectPtr<AbstractUserPromptView> const& prompt_view,
44 int monitor_num, bool is_primary)43 int monitor_num, bool is_primary)
@@ -47,7 +46,6 @@
47 , monitor(monitor_num)46 , monitor(monitor_num)
48 , scale(1.0)47 , scale(1.0)
49 , session_manager_(session)48 , session_manager_(session)
50 , indicators_(indicators)
51 , accelerators_(accelerators)49 , accelerators_(accelerators)
52 , prompt_view_(prompt_view)50 , prompt_view_(prompt_view)
53 , bg_settings_(std::make_shared<BackgroundSettings>())51 , bg_settings_(std::make_shared<BackgroundSettings>())
5452
=== modified file 'lockscreen/LockScreenBaseShield.h'
--- lockscreen/LockScreenBaseShield.h 2016-03-31 09:51:33 +0000
+++ lockscreen/LockScreenBaseShield.h 2016-08-30 14:38:39 +0000
@@ -21,8 +21,8 @@
21#define UNITY_LOCKSCREEN_BASE_SHIELD_H21#define UNITY_LOCKSCREEN_BASE_SHIELD_H
2222
23#include <NuxCore/Property.h>23#include <NuxCore/Property.h>
24#include "UnityCore/ConnectionManager.h"
24#include "UnityCore/SessionManager.h"25#include "UnityCore/SessionManager.h"
25#include "UnityCore/Indicators.h"
26#include "UnityCore/GLibSource.h"26#include "UnityCore/GLibSource.h"
27#include "unity-shared/MockableBaseWindow.h"27#include "unity-shared/MockableBaseWindow.h"
2828
@@ -39,8 +39,8 @@
39class BaseShield : public MockableBaseWindow39class BaseShield : public MockableBaseWindow
40{40{
41public:41public:
42 BaseShield(session::Manager::Ptr const&, indicator::Indicators::Ptr const&,42 BaseShield(session::Manager::Ptr const&, Accelerators::Ptr const&,
43 Accelerators::Ptr const&, nux::ObjectPtr<AbstractUserPromptView> const&,43 nux::ObjectPtr<AbstractUserPromptView> const&,
44 int monitor_num, bool is_primary);44 int monitor_num, bool is_primary);
4545
46 nux::Property<bool> primary;46 nux::Property<bool> primary;
@@ -69,7 +69,6 @@
69 void UpdateScale();69 void UpdateScale();
7070
71 session::Manager::Ptr session_manager_;71 session::Manager::Ptr session_manager_;
72 indicator::Indicators::Ptr indicators_;
73 Accelerators::Ptr accelerators_;72 Accelerators::Ptr accelerators_;
74 nux::ObjectPtr<AbstractUserPromptView> prompt_view_;73 nux::ObjectPtr<AbstractUserPromptView> prompt_view_;
75 std::shared_ptr<BackgroundSettings> bg_settings_;74 std::shared_ptr<BackgroundSettings> bg_settings_;
7675
=== modified file 'lockscreen/LockScreenController.cpp'
--- lockscreen/LockScreenController.cpp 2016-07-04 12:45:06 +0000
+++ lockscreen/LockScreenController.cpp 2016-08-30 14:38:39 +0000
@@ -56,6 +56,7 @@
56Controller::Controller(DBusManager::Ptr const& dbus_manager,56Controller::Controller(DBusManager::Ptr const& dbus_manager,
57 session::Manager::Ptr const& session_manager,57 session::Manager::Ptr const& session_manager,
58 key::Grabber::Ptr const& key_grabber,58 key::Grabber::Ptr const& key_grabber,
59 SystemdWrapper::Ptr const& systemd_wrapper,
59 UpstartWrapper::Ptr const& upstart_wrapper,60 UpstartWrapper::Ptr const& upstart_wrapper,
60 ShieldFactoryInterface::Ptr const& shield_factory,61 ShieldFactoryInterface::Ptr const& shield_factory,
61 bool test_mode)62 bool test_mode)
@@ -63,6 +64,7 @@
63 , dbus_manager_(dbus_manager)64 , dbus_manager_(dbus_manager)
64 , session_manager_(session_manager)65 , session_manager_(session_manager)
65 , key_grabber_(key_grabber)66 , key_grabber_(key_grabber)
67 , systemd_wrapper_(systemd_wrapper)
66 , upstart_wrapper_(upstart_wrapper)68 , upstart_wrapper_(upstart_wrapper)
67 , shield_factory_(shield_factory)69 , shield_factory_(shield_factory)
68 , suspend_inhibitor_manager_(std::make_shared<SuspendInhibitorManager>())70 , suspend_inhibitor_manager_(std::make_shared<SuspendInhibitorManager>())
@@ -129,8 +131,9 @@
129 shields_.clear();131 shields_.clear();
130132
131 upstart_wrapper_->Emit("desktop-unlock");133 upstart_wrapper_->Emit("desktop-unlock");
134 systemd_wrapper_->Stop("unity-screen-locked.target");
132 accelerator_controller_.reset();135 accelerator_controller_.reset();
133 indicators_.reset();136 menu_manager_.reset();
134 }137 }
135 else if (!prompt_activation_)138 else if (!prompt_activation_)
136 {139 {
@@ -252,7 +255,7 @@
252255
253 if (i >= shields_size)256 if (i >= shields_size)
254 {257 {
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);
256 is_new = true;259 is_new = true;
257 }260 }
258261
@@ -462,8 +465,9 @@
462465
463void Controller::LockScreen()466void Controller::LockScreen()
464{467{
465 indicators_ = std::make_shared<indicator::LockScreenDBusIndicators>();468 menu_manager_ = std::make_shared<menu::Manager>(std::make_shared<indicator::LockScreenDBusIndicators>(), key_grabber_);
466 upstart_wrapper_->Emit("desktop-lock");469 upstart_wrapper_->Emit("desktop-lock");
470 systemd_wrapper_->Stop("unity-screen-locked.target");
467471
468 accelerator_controller_ = std::make_shared<AcceleratorController>(key_grabber_);472 accelerator_controller_ = std::make_shared<AcceleratorController>(key_grabber_);
469 auto activate_key = WindowManager::Default().activate_indicators_key();473 auto activate_key = WindowManager::Default().activate_indicators_key();
470474
=== modified file 'lockscreen/LockScreenController.h'
--- lockscreen/LockScreenController.h 2016-06-21 01:28:26 +0000
+++ lockscreen/LockScreenController.h 2016-08-30 14:38:39 +0000
@@ -30,7 +30,7 @@
30#include "SuspendInhibitorManager.h"30#include "SuspendInhibitorManager.h"
31#include "ScreenSaverDBusManager.h"31#include "ScreenSaverDBusManager.h"
32#include "unity-shared/BackgroundEffectHelper.h"32#include "unity-shared/BackgroundEffectHelper.h"
33#include "unity-shared/KeyGrabber.h"33#include "unity-shared/SystemdWrapper.h"
34#include "unity-shared/UpstartWrapper.h"34#include "unity-shared/UpstartWrapper.h"
3535
36namespace unity36namespace unity
@@ -46,6 +46,7 @@
46 typedef std::shared_ptr<Controller> Ptr;46 typedef std::shared_ptr<Controller> Ptr;
4747
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&,
49 SystemdWrapper::Ptr const& systemd_wrapper = std::make_shared<SystemdWrapper>(),
49 UpstartWrapper::Ptr const& upstart_wrapper = std::make_shared<UpstartWrapper>(),50 UpstartWrapper::Ptr const& upstart_wrapper = std::make_shared<UpstartWrapper>(),
50 ShieldFactoryInterface::Ptr const& shield_factory = std::make_shared<ShieldFactory>(),51 ShieldFactoryInterface::Ptr const& shield_factory = std::make_shared<ShieldFactory>(),
51 bool test_mode = false);52 bool test_mode = false);
@@ -85,9 +86,10 @@
8586
86 DBusManager::Ptr dbus_manager_;87 DBusManager::Ptr dbus_manager_;
87 session::Manager::Ptr session_manager_;88 session::Manager::Ptr session_manager_;
89 menu::Manager::Ptr menu_manager_;
88 key::Grabber::Ptr key_grabber_;90 key::Grabber::Ptr key_grabber_;
89 indicator::Indicators::Ptr indicators_;
90 AcceleratorController::Ptr accelerator_controller_;91 AcceleratorController::Ptr accelerator_controller_;
92 SystemdWrapper::Ptr systemd_wrapper_;
91 UpstartWrapper::Ptr upstart_wrapper_;93 UpstartWrapper::Ptr upstart_wrapper_;
92 ShieldFactoryInterface::Ptr shield_factory_;94 ShieldFactoryInterface::Ptr shield_factory_;
93 SuspendInhibitorManager::Ptr suspend_inhibitor_manager_;95 SuspendInhibitorManager::Ptr suspend_inhibitor_manager_;
9496
=== modified file 'lockscreen/LockScreenPanel.cpp'
--- lockscreen/LockScreenPanel.cpp 2015-11-05 14:55:54 +0000
+++ lockscreen/LockScreenPanel.cpp 2016-08-30 14:38:39 +0000
@@ -24,7 +24,7 @@
2424
25#include "LockScreenSettings.h"25#include "LockScreenSettings.h"
26#include "panel/PanelIndicatorsView.h"26#include "panel/PanelIndicatorsView.h"
27#include "unity-shared/CairoTexture.h"27#include "unity-shared/InputMonitor.h"
28#include "unity-shared/StaticCairoText.h"28#include "unity-shared/StaticCairoText.h"
29#include "unity-shared/PanelStyle.h"29#include "unity-shared/PanelStyle.h"
30#include "unity-shared/RawPixel.h"30#include "unity-shared/RawPixel.h"
@@ -38,24 +38,24 @@
38namespace38namespace
39{39{
40const RawPixel PADDING = 5_em;40const RawPixel PADDING = 5_em;
41const nux::Color BG_COLOR(0.1, 0.1, 0.1, 0.4);
41}42}
4243
43using namespace indicator;44using namespace indicator;
44using namespace panel;45using namespace panel;
4546
46Panel::Panel(int monitor_, Indicators::Ptr const& indicators, session::Manager::Ptr const& session_manager)47Panel::Panel(int monitor_, menu::Manager::Ptr const& menu_manager, session::Manager::Ptr const& session_manager)
47 : nux::View(NUX_TRACKER_LOCATION)48 : nux::View(NUX_TRACKER_LOCATION)
48 , active(false)49 , active(false)
49 , monitor(monitor_)50 , monitor(monitor_)
50 , indicators_(indicators)51 , menu_manager_(menu_manager)
51 , needs_geo_sync_(true)52 , needs_geo_sync_(true)
52{53{
53 double scale = unity::Settings::Instance().em(monitor)->DPIScale();54 double scale = unity::Settings::Instance().em(monitor)->DPIScale();
54 auto* layout = new nux::HLayout();55 auto* layout = new nux::HLayout();
55 layout->SetLeftAndRightPadding(PADDING.CP(scale), 0);56 layout->SetLeftAndRightPadding(PADDING.CP(scale), 0);
56 SetLayout(layout);57 SetLayout(layout);
5758 UpdateSize();
58 BuildTexture();
5959
60 // Add setting60 // Add setting
61 auto *hostname = new StaticCairoText(session_manager->HostName());61 auto *hostname = new StaticCairoText(session_manager->HostName());
@@ -72,34 +72,33 @@
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));
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);
7474
75 for (auto const& indicator : indicators_->GetIndicators())75 auto indicators = menu_manager_->Indicators();
76 menu_manager_->RegisterTracker(GetPanelName(), (sigc::track_obj([this] (int x, int y, double speed) {
77 indicators_view_->ActivateEntryAt(x, y);
78 }, *this)));
79
80 for (auto const& indicator : indicators->GetIndicators())
76 AddIndicator(indicator);81 AddIndicator(indicator);
7782
78 indicators_->on_object_added.connect(sigc::mem_fun(this, &Panel::AddIndicator));83 indicators->on_object_added.connect(sigc::mem_fun(this, &Panel::AddIndicator));
79 indicators_->on_object_removed.connect(sigc::mem_fun(this, &Panel::RemoveIndicator));84 indicators->on_object_removed.connect(sigc::mem_fun(this, &Panel::RemoveIndicator));
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));
81 indicators_->on_entry_activated.connect(sigc::mem_fun(this, &Panel::OnEntryActivated));86 indicators->on_entry_activated.connect(sigc::mem_fun(this, &Panel::OnEntryActivated));
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));
8388
84 monitor.changed.connect([this, hostname] (int monitor) {89 monitor.changed.connect([this, hostname] (int monitor) {
85 double scale = unity::Settings::Instance().em(monitor)->DPIScale();90 double scale = unity::Settings::Instance().em(monitor)->DPIScale();
86 hostname->SetScale(scale);91 hostname->SetScale(scale);
87 static_cast<nux::HLayout*>(GetLayout())->SetLeftAndRightPadding(PADDING.CP(scale), 0);92 static_cast<nux::HLayout*>(GetLayout())->SetLeftAndRightPadding(PADDING.CP(scale), 0);
88 indicators_view_->SetMonitor(monitor);93 indicators_view_->SetMonitor(monitor);
89 BuildTexture();94 UpdateSize();
90 QueueRelayout();95 QueueRelayout();
91 });96 });
92}97}
9398
94void Panel::BuildTexture()99void Panel::UpdateSize()
95{100{
96 int height = panel::Style::Instance().PanelHeight(monitor);101 int height = panel::Style::Instance().PanelHeight(monitor);
97 nux::CairoGraphics context(CAIRO_FORMAT_ARGB32, 1, height);
98 auto* cr = context.GetInternalContext();
99 cairo_set_source_rgb(cr, 0.1, 0.1, 0.1);
100 cairo_paint_with_alpha(cr, 0.4);
101 bg_texture_ = texture_ptr_from_cairo_graphics(context);
102
103 view_layout_->SetMinimumHeight(height);102 view_layout_->SetMinimumHeight(height);
104 view_layout_->SetMaximumHeight(height);103 view_layout_->SetMaximumHeight(height);
105}104}
@@ -165,12 +164,7 @@
165 if (!GetInputEventSensitivity())164 if (!GetInputEventSensitivity())
166 return;165 return;
167166
168 if (!active)167 active = true;
169 {
170 // This is ugly... But Nux fault!
171 WindowManager::Default().UnGrabMousePointer(CurrentTime, button, x, y);
172 active = true;
173 }
174}168}
175169
176void Panel::OnEntryActivateRequest(std::string const& entry_id)170void Panel::OnEntryActivateRequest(std::string const& entry_id)
@@ -184,36 +178,16 @@
184 if (!GetInputEventSensitivity() || (!panel.empty() && panel != GetPanelName()))178 if (!GetInputEventSensitivity() || (!panel.empty() && panel != GetPanelName()))
185 return;179 return;
186180
187 bool active = !entry_id.empty();181 bool valid_entry = !entry_id.empty();
188182
189 if (active && !WindowManager::Default().IsScreenGrabbed())183 if (valid_entry && !WindowManager::Default().IsScreenGrabbed())
190 {184 {
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.
192 nux::GetWindowCompositor().GrabKeyboardAdd(static_cast<nux::BaseWindow*>(GetTopLevelViewWindow()));186 nux::GetWindowCompositor().GrabKeyboardAdd(static_cast<nux::BaseWindow*>(GetTopLevelViewWindow()));
193 }187 }
194188
195 if (active && !track_menu_pointer_timeout_)189 if (!valid_entry)
196 {190 active = valid_entry;
197 track_menu_pointer_timeout_.reset(new glib::Timeout(16));
198 track_menu_pointer_timeout_->Run([this] {
199 nux::Point const& mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord();
200 if (tracked_pointer_pos_ != mouse)
201 {
202 if (GetAbsoluteGeometry().IsPointInside(mouse.x, mouse.y))
203 indicators_view_->ActivateEntryAt(mouse.x, mouse.y);
204
205 tracked_pointer_pos_ = mouse;
206 }
207
208 return true;
209 });
210 }
211 else if (!active)
212 {
213 track_menu_pointer_timeout_.reset();
214 tracked_pointer_pos_ = {-1, -1};
215 this->active = false;
216 }
217}191}
218192
219void Panel::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)193void Panel::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)
@@ -227,12 +201,7 @@
227 graphics_engine.PushClippingRectangle(geo);201 graphics_engine.PushClippingRectangle(geo);
228 nux::GetPainter().PaintBackground(graphics_engine, geo);202 nux::GetPainter().PaintBackground(graphics_engine, geo);
229203
230 nux::TexCoordXForm texxform;204 graphics_engine.QRP_Color(geo.x, geo.y, geo.width, geo.height, BG_COLOR);
231 texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_CLAMP);
232 graphics_engine.QRP_1Tex(geo.x, geo.y, geo.width, geo.height,
233 bg_texture_->GetDeviceTexture(), texxform,
234 nux::color::White);
235
236 view_layout_->ProcessDraw(graphics_engine, force_draw);205 view_layout_->ProcessDraw(graphics_engine, force_draw);
237206
238 graphics_engine.PopClippingRectangle();207 graphics_engine.PopClippingRectangle();
@@ -242,7 +211,7 @@
242 {211 {
243 EntryLocationMap locations;212 EntryLocationMap locations;
244 indicators_view_->GetGeometryForSync(locations);213 indicators_view_->GetGeometryForSync(locations);
245 indicators_->SyncGeometries(GetPanelName(), locations);214 menu_manager_->Indicators()->SyncGeometries(GetPanelName(), locations);
246 needs_geo_sync_ = false;215 needs_geo_sync_ = false;
247 }216 }
248}217}
249218
=== modified file 'lockscreen/LockScreenPanel.h'
--- lockscreen/LockScreenPanel.h 2016-03-31 09:51:33 +0000
+++ lockscreen/LockScreenPanel.h 2016-08-30 14:38:39 +0000
@@ -22,9 +22,9 @@
2222
23#include <Nux/Nux.h>23#include <Nux/Nux.h>
24#include <Nux/View.h>24#include <Nux/View.h>
25#include "UnityCore/Indicators.h"
26#include "UnityCore/GLibSource.h"25#include "UnityCore/GLibSource.h"
27#include "UnityCore/SessionManager.h"26#include "UnityCore/SessionManager.h"
27#include "unity-shared/MenuManager.h"
2828
29namespace unity29namespace unity
30{30{
@@ -39,7 +39,7 @@
39class Panel : public nux::View39class Panel : public nux::View
40{40{
41public:41public:
42 Panel(int monitor, indicator::Indicators::Ptr const&, session::Manager::Ptr const&);42 Panel(int monitor, menu::Manager::Ptr const&, session::Manager::Ptr const&);
4343
44 nux::Property<bool> active;44 nux::Property<bool> active;
45 nux::Property<int> monitor;45 nux::Property<int> monitor;
@@ -55,20 +55,16 @@
55 void AddIndicator(indicator::Indicator::Ptr const&);55 void AddIndicator(indicator::Indicator::Ptr const&);
56 void RemoveIndicator(indicator::Indicator::Ptr const&);56 void RemoveIndicator(indicator::Indicator::Ptr const&);
57 void OnIndicatorViewUpdated();57 void OnIndicatorViewUpdated();
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&);
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);
60 void OnEntryActivateRequest(std::string const& entry_id);60 void OnEntryActivateRequest(std::string const& entry_id);
6161
62 void BuildTexture();62 void UpdateSize();
63 std::string GetPanelName() const;63 std::string GetPanelName() const;
6464
65 indicator::Indicators::Ptr indicators_;65 menu::Manager::Ptr menu_manager_;
66 panel::PanelIndicatorsView* indicators_view_;66 panel::PanelIndicatorsView* indicators_view_;
67 nux::ObjectPtr<nux::BaseTexture> bg_texture_;
68
69 bool needs_geo_sync_;67 bool needs_geo_sync_;
70 nux::Point tracked_pointer_pos_;
71 glib::Source::UniquePtr track_menu_pointer_timeout_;
72};68};
7369
74} // lockscreen namespace70} // lockscreen namespace
7571
=== modified file 'lockscreen/LockScreenShield.cpp'
--- lockscreen/LockScreenShield.cpp 2015-12-03 14:13:10 +0000
+++ lockscreen/LockScreenShield.cpp 2016-08-30 14:38:39 +0000
@@ -32,11 +32,12 @@
32{32{
3333
34Shield::Shield(session::Manager::Ptr const& session_manager,34Shield::Shield(session::Manager::Ptr const& session_manager,
35 indicator::Indicators::Ptr const& indicators,35 menu::Manager::Ptr const& menu_manager,
36 Accelerators::Ptr const& accelerators,36 Accelerators::Ptr const& accelerators,
37 nux::ObjectPtr<AbstractUserPromptView> const& prompt_view,37 nux::ObjectPtr<AbstractUserPromptView> const& prompt_view,
38 int monitor_num, bool is_primary)38 int monitor_num, bool is_primary)
39 : BaseShield(session_manager, indicators, accelerators, prompt_view, monitor_num, is_primary)39 : BaseShield(session_manager, accelerators, prompt_view, monitor_num, is_primary)
40 , menu_manager_(menu_manager)
40 , panel_view_(nullptr)41 , panel_view_(nullptr)
41{42{
42 is_primary ? ShowPrimaryView() : ShowSecondaryView();43 is_primary ? ShowPrimaryView() : ShowSecondaryView();
@@ -91,11 +92,11 @@
9192
92Panel* Shield::CreatePanel()93Panel* Shield::CreatePanel()
93{94{
94 if (!indicators_ || !session_manager_)95 if (!menu_manager_ || !session_manager_)
95 return nullptr;96 return nullptr;
9697
97 panel_view_ = new Panel(monitor, indicators_, session_manager_);98 panel_view_ = new Panel(monitor, menu_manager_, session_manager_);
98 panel_active_conn_ = panel_view_->active.changed.connect([this] (bool active) {99 panel_view_->active.changed.connect(sigc::track_obj([this] (bool active) {
99 if (primary())100 if (primary())
100 {101 {
101 if (active)102 if (active)
@@ -109,7 +110,7 @@
109 GrabScreen(false);110 GrabScreen(false);
110 }111 }
111 }112 }
112 });113 }, *this));
113114
114 return panel_view_;115 return panel_view_;
115}116}
116117
=== modified file 'lockscreen/LockScreenShield.h'
--- lockscreen/LockScreenShield.h 2015-12-03 14:13:10 +0000
+++ lockscreen/LockScreenShield.h 2016-08-30 14:38:39 +0000
@@ -20,8 +20,9 @@
20#ifndef UNITY_LOCKSCREEN_SHIELD_H20#ifndef UNITY_LOCKSCREEN_SHIELD_H
21#define UNITY_LOCKSCREEN_SHIELD_H21#define UNITY_LOCKSCREEN_SHIELD_H
2222
23#include <UnityCore/ConnectionManager.h>
24#include "LockScreenBaseShield.h"23#include "LockScreenBaseShield.h"
24#include "unity-shared/MenuManager.h"
25
2526
26namespace unity27namespace unity
27{28{
@@ -35,7 +36,7 @@
35{36{
36public:37public:
37 Shield(session::Manager::Ptr const&,38 Shield(session::Manager::Ptr const&,
38 indicator::Indicators::Ptr const&,39 menu::Manager::Ptr const&,
39 Accelerators::Ptr const&,40 Accelerators::Ptr const&,
40 nux::ObjectPtr<AbstractUserPromptView> const&,41 nux::ObjectPtr<AbstractUserPromptView> const&,
41 int monitor, bool is_primary);42 int monitor, bool is_primary);
@@ -50,7 +51,7 @@
50 void ShowPrimaryView() override;51 void ShowPrimaryView() override;
51 Panel* CreatePanel();52 Panel* CreatePanel();
5253
53 connection::Wrapper panel_active_conn_;54 menu::Manager::Ptr menu_manager_;
54 Panel* panel_view_;55 Panel* panel_view_;
55};56};
5657
5758
=== modified file 'lockscreen/LockScreenShieldFactory.cpp'
--- lockscreen/LockScreenShieldFactory.cpp 2015-12-04 08:17:46 +0000
+++ lockscreen/LockScreenShieldFactory.cpp 2016-08-30 14:38:39 +0000
@@ -28,7 +28,7 @@
28{28{
2929
30nux::ObjectPtr<BaseShield> ShieldFactory::CreateShield(session::Manager::Ptr const& session_manager,30nux::ObjectPtr<BaseShield> ShieldFactory::CreateShield(session::Manager::Ptr const& session_manager,
31 indicator::Indicators::Ptr const& indicators,31 menu::Manager::Ptr const& menu_manager,
32 Accelerators::Ptr const& accelerators,32 Accelerators::Ptr const& accelerators,
33 nux::ObjectPtr<AbstractUserPromptView> const& prompt_view,33 nux::ObjectPtr<AbstractUserPromptView> const& prompt_view,
34 int monitor, bool is_primary)34 int monitor, bool is_primary)
@@ -38,7 +38,7 @@
38 if (Settings::Instance().desktop_type() == DesktopType::UBUNTUKYLIN)38 if (Settings::Instance().desktop_type() == DesktopType::UBUNTUKYLIN)
39 shield = new KylinShield(session_manager, accelerators, prompt_view, monitor, is_primary);39 shield = new KylinShield(session_manager, accelerators, prompt_view, monitor, is_primary);
40 else40 else
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);
4242
43 return shield;43 return shield;
44}44}
4545
=== modified file 'lockscreen/LockScreenShieldFactory.h'
--- lockscreen/LockScreenShieldFactory.h 2016-03-31 09:51:33 +0000
+++ lockscreen/LockScreenShieldFactory.h 2016-08-30 14:38:39 +0000
@@ -22,7 +22,7 @@
2222
23#include <NuxCore/NuxCore.h>23#include <NuxCore/NuxCore.h>
24#include "UnityCore/SessionManager.h"24#include "UnityCore/SessionManager.h"
25#include "UnityCore/Indicators.h"25#include "unity-shared/MenuManager.h"
26#include "LockScreenAccelerators.h"26#include "LockScreenAccelerators.h"
2727
28namespace unity28namespace unity
@@ -41,7 +41,7 @@
41 virtual ~ShieldFactoryInterface() = default;41 virtual ~ShieldFactoryInterface() = default;
4242
43 virtual nux::ObjectPtr<BaseShield> CreateShield(session::Manager::Ptr const&,43 virtual nux::ObjectPtr<BaseShield> CreateShield(session::Manager::Ptr const&,
44 indicator::Indicators::Ptr const&,44 menu::Manager::Ptr const&,
45 Accelerators::Ptr const&,45 Accelerators::Ptr const&,
46 nux::ObjectPtr<AbstractUserPromptView> const&,46 nux::ObjectPtr<AbstractUserPromptView> const&,
47 int monitor, bool is_primary) = 0;47 int monitor, bool is_primary) = 0;
@@ -50,7 +50,7 @@
50struct ShieldFactory : ShieldFactoryInterface50struct ShieldFactory : ShieldFactoryInterface
51{51{
52 nux::ObjectPtr<BaseShield> CreateShield(session::Manager::Ptr const&,52 nux::ObjectPtr<BaseShield> CreateShield(session::Manager::Ptr const&,
53 indicator::Indicators::Ptr const&,53 menu::Manager::Ptr const&,
54 Accelerators::Ptr const&,54 Accelerators::Ptr const&,
55 nux::ObjectPtr<AbstractUserPromptView> const&,55 nux::ObjectPtr<AbstractUserPromptView> const&,
56 int monitor, bool is_primary) override;56 int monitor, bool is_primary) override;
5757
=== modified file 'panel/PanelIndicatorEntryView.cpp'
--- panel/PanelIndicatorEntryView.cpp 2016-02-17 13:14:37 +0000
+++ panel/PanelIndicatorEntryView.cpp 2016-08-30 14:38:39 +0000
@@ -33,6 +33,8 @@
33#include "unity-shared/RawPixel.h"33#include "unity-shared/RawPixel.h"
34#include "unity-shared/WindowManager.h"34#include "unity-shared/WindowManager.h"
35#include "unity-shared/ThemeSettings.h"35#include "unity-shared/ThemeSettings.h"
36#include "unity-shared/UBusWrapper.h"
37#include "unity-shared/UBusMessages.h"
36#include "unity-shared/UnitySettings.h"38#include "unity-shared/UnitySettings.h"
3739
38namespace unity40namespace unity
@@ -117,6 +119,9 @@
117 }119 }
118 else120 else
119 {121 {
122 if (overlay_showing_)
123 UBusManager::SendMessage(UBUS_OVERLAY_CLOSE_REQUEST);
124
120 WindowManager& wm = WindowManager::Default();125 WindowManager& wm = WindowManager::Default();
121126
122 if (wm.IsExpoActive())127 if (wm.IsExpoActive())
@@ -140,6 +145,11 @@
140 wm.TerminateScale();145 wm.TerminateScale();
141 }146 }
142147
148 // This is ugly... But Nux fault!
149 auto const& abs_geo = GetAbsoluteGeometry();
150 guint64 timestamp = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp;
151 WindowManager::Default().UnGrabMousePointer(timestamp, button, abs_geo.x, abs_geo.y);
152
143 Activate(button);153 Activate(button);
144 }154 }
145 }155 }
146156
=== modified file 'panel/PanelMenuView.cpp'
--- panel/PanelMenuView.cpp 2015-12-16 15:12:05 +0000
+++ panel/PanelMenuView.cpp 2016-08-30 14:38:39 +0000
@@ -102,7 +102,6 @@
102 , ignore_menu_visibility_(false)102 , ignore_menu_visibility_(false)
103 , integrated_menus_(menu_manager_->integrated_menus())103 , integrated_menus_(menu_manager_->integrated_menus())
104 , always_show_menus_(menu_manager_->always_show_menus())104 , always_show_menus_(menu_manager_->always_show_menus())
105 , ignore_leave_events_(false)
106 , desktop_name_(get_current_desktop())105 , desktop_name_(get_current_desktop())
107{106{
108 if (ApplicationWindowPtr const& win = ApplicationManager::Default().GetActiveWindow())107 if (ApplicationWindowPtr const& win = ApplicationManager::Default().GetActiveWindow())
@@ -1814,14 +1813,9 @@
1814 }1813 }
1815}1814}
18161815
1817void PanelMenuView::IgnoreLeaveEvents(bool ignore)
1818{
1819 ignore_leave_events_ = ignore;
1820}
1821
1822void PanelMenuView::OnPanelViewMouseLeave(int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state)1816void PanelMenuView::OnPanelViewMouseLeave(int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state)
1823{1817{
1824 if (always_show_menus_ || ignore_leave_events_)1818 if (always_show_menus_)
1825 return;1819 return;
18261820
1827 if (is_inside_)1821 if (is_inside_)
18281822
=== modified file 'panel/PanelMenuView.h'
--- panel/PanelMenuView.h 2015-11-05 14:54:13 +0000
+++ panel/PanelMenuView.h 2016-08-30 14:38:39 +0000
@@ -56,7 +56,6 @@
56 bool HasKeyActivableMenus() const;56 bool HasKeyActivableMenus() const;
5757
58 void NotifyAllMenusClosed();58 void NotifyAllMenusClosed();
59 void IgnoreLeaveEvents(bool);
6059
61 virtual void AddIndicator(indicator::Indicator::Ptr const& indicator);60 virtual void AddIndicator(indicator::Indicator::Ptr const& indicator);
6261
@@ -192,7 +191,6 @@
192 bool ignore_menu_visibility_;191 bool ignore_menu_visibility_;
193 bool integrated_menus_;192 bool integrated_menus_;
194 bool always_show_menus_;193 bool always_show_menus_;
195 bool ignore_leave_events_;
196194
197 nux::Geometry monitor_geo_;195 nux::Geometry monitor_geo_;
198 const std::string desktop_name_;196 const std::string desktop_name_;
199197
=== modified file 'panel/PanelView.cpp'
--- panel/PanelView.cpp 2016-08-12 13:57:19 +0000
+++ panel/PanelView.cpp 2016-08-30 14:38:39 +0000
@@ -42,7 +42,8 @@
42namespace42namespace
43{43{
44const RawPixel TRIANGLE_THRESHOLD = 5_em;44const RawPixel TRIANGLE_THRESHOLD = 5_em;
45const int refine_gradient_midpoint = 959;45const double SCRUB_VELOCITY_THRESHOLD = 0.05;
46const RawPixel REFINE_GRADIENT_MIDPOINT = 959;
46}47}
4748
4849
@@ -113,10 +114,9 @@
113114
114 remote_->on_object_added.connect(sigc::mem_fun(this, &PanelView::OnObjectAdded));115 remote_->on_object_added.connect(sigc::mem_fun(this, &PanelView::OnObjectAdded));
115 remote_->on_object_removed.connect(sigc::mem_fun(this, &PanelView::OnObjectRemoved));116 remote_->on_object_removed.connect(sigc::mem_fun(this, &PanelView::OnObjectRemoved));
116 remote_->on_entry_activated.connect(sigc::mem_fun(this, &PanelView::OnEntryActivated));
117 remote_->on_entry_show_menu.connect(sigc::mem_fun(this, &PanelView::OnEntryShowMenu));
118 menus->key_activate_entry.connect(sigc::mem_fun(this, &PanelView::ActivateEntry));117 menus->key_activate_entry.connect(sigc::mem_fun(this, &PanelView::ActivateEntry));
119 menus->open_first.connect(sigc::mem_fun(this, &PanelView::ActivateFirstSensitive));118 menus->open_first.connect(sigc::mem_fun(this, &PanelView::ActivateFirstSensitive));
119 menus->RegisterTracker(GetPanelName(), sigc::mem_fun(this, &PanelView::OnMenuPointerMoved));
120120
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));
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));
@@ -374,7 +374,7 @@
374 GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);374 GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
375 nux::TexCoordXForm refine_texxform;375 nux::TexCoordXForm refine_texxform;
376376
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_)));
378378
379 if (Settings::Instance().launcher_position() == LauncherPosition::LEFT)379 if (Settings::Instance().launcher_position() == LauncherPosition::LEFT)
380 refine_x_pos += unity::Settings::Instance().LauncherSize(monitor_);380 refine_x_pos += unity::Settings::Instance().LauncherSize(monitor_);
@@ -473,7 +473,7 @@
473473
474 nux::Geometry refine_geo = geo;474 nux::Geometry refine_geo = geo;
475475
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_)));
477 if (Settings::Instance().launcher_position() == LauncherPosition::LEFT)477 if (Settings::Instance().launcher_position() == LauncherPosition::LEFT)
478 refine_x_pos += unity::Settings::Instance().LauncherSize(monitor_);478 refine_x_pos += unity::Settings::Instance().LauncherSize(monitor_);
479479
@@ -627,7 +627,7 @@
627 QueueDraw();627 QueueDraw();
628}628}
629629
630void PanelView::OnMenuPointerMoved(int x, int y)630void PanelView::OnMenuPointerMoved(int x, int y, double speed)
631{631{
632 nux::Geometry const& geo = GetAbsoluteGeometry();632 nux::Geometry const& geo = GetAbsoluteGeometry();
633633
@@ -648,116 +648,6 @@
648 }648 }
649}649}
650650
651static bool PointInTriangle(nux::Point const& p, nux::Point const& t0, nux::Point const& t1, nux::Point const& t2)
652{
653 int s = t0.y * t2.x - t0.x * t2.y + (t2.y - t0.y) * p.x + (t0.x - t2.x) * p.y;
654 int t = t0.x * t1.y - t0.y * t1.x + (t0.y - t1.y) * p.x + (t1.x - t0.x) * p.y;
655
656 if ((s < 0) != (t < 0))
657 return false;
658
659 int A = -t1.y * t2.x + t0.y * (t2.x - t1.x) + t0.x * (t1.y - t2.y) + t1.x * t2.y;
660 if (A < 0)
661 {
662 s = -s;
663 t = -t;
664 A = -A;
665 }
666
667 return s > 0 && t > 0 && (s + t) < A;
668}
669
670static double GetMouseVelocity(nux::Point const& p0, nux::Point const& p1, util::Timer &timer)
671{
672 int dx, dy;
673 double speed;
674 auto millis = timer.ElapsedMicroSeconds();
675
676 if (millis == 0)
677 return 1;
678
679 dx = p0.x - p1.x;
680 dy = p0.y - p1.y;
681
682 speed = sqrt(dx * dx + dy * dy) / millis * 1000;
683
684 return speed;
685}
686
687bool PanelView::TrackMenuPointer()
688{
689 nux::Point const& mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord();
690 double speed = GetMouseVelocity(mouse, tracked_pointer_pos_, mouse_tracker_timer_);
691
692 mouse_tracker_timer_.Reset();
693 tracked_pointer_pos_ = mouse;
694
695 double scale = Settings::Instance().em(monitor_)->DPIScale();
696 if (speed > 0 && PointInTriangle(mouse,
697 nux::Point(triangle_top_corner_.x, std::max(triangle_top_corner_.y - TRIANGLE_THRESHOLD.CP(scale), 0)),
698 nux::Point(menu_geo_.x, menu_geo_.y),
699 nux::Point(menu_geo_.x + menu_geo_.width, menu_geo_.y)))
700 {
701 return true;
702 }
703
704 if (mouse != triangle_top_corner_)
705 {
706 triangle_top_corner_ = mouse;
707 OnMenuPointerMoved(mouse.x, mouse.y);
708 }
709
710 return true;
711}
712
713void PanelView::OnEntryActivated(std::string const& panel, std::string const& entry_id, nux::Rect const& menu_geo)
714{
715 if (!panel.empty() && panel != GetPanelName())
716 return;
717
718 menu_geo_ = menu_geo;
719
720 bool active = !entry_id.empty();
721 if (active && !track_menu_pointer_timeout_)
722 {
723 //
724 // Track menus being scrubbed at 60Hz (about every 16 millisec)
725 // It might sound ugly, but it's far nicer (and more responsive) than the
726 // code it replaces which used to capture motion events in another process
727 // (unity-panel-service) and send them to us over dbus.
728 // NOTE: The reason why we have to use a timer instead of tracking motion
729 // events is because the motion events will never be delivered to this
730 // process. All the motion events will go to unity-panel-service while
731 // scrubbing because the active panel menu has (needs) the pointer grab.
732 //
733 mouse_tracker_timer_.Reset();
734 triangle_top_corner_ = nux::GetGraphicsDisplay()->GetMouseScreenCoord();
735 track_menu_pointer_timeout_.reset(new glib::Timeout(16));
736 track_menu_pointer_timeout_->Run(sigc::mem_fun(this, &PanelView::TrackMenuPointer));
737 }
738 else if (!active)
739 {
740 track_menu_pointer_timeout_.reset();
741 menu_view_->NotifyAllMenusClosed();
742 tracked_pointer_pos_ = {-1, -1};
743 }
744
745 if (overlay_is_open_)
746 ubus_manager_.SendMessage(UBUS_OVERLAY_CLOSE_REQUEST);
747}
748
749void PanelView::OnEntryShowMenu(std::string const& entry_id, unsigned xid,
750 int x, int y, unsigned button)
751{
752 if (!track_menu_pointer_timeout_)
753 {
754 // This is ugly... But Nux fault!
755 menu_view_->IgnoreLeaveEvents(true);
756 WindowManager::Default().UnGrabMousePointer(CurrentTime, button, x, y);
757 menu_view_->IgnoreLeaveEvents(false);
758 }
759}
760
761bool PanelView::ActivateFirstSensitive()651bool PanelView::ActivateFirstSensitive()
762{652{
763 if (!IsActive())653 if (!IsActive())
@@ -768,7 +658,6 @@
768 {658 {
769 // Since this only happens on keyboard events, we need to prevent that the659 // Since this only happens on keyboard events, we need to prevent that the
770 // pointer tracker would select another entry.660 // pointer tracker would select another entry.
771 tracked_pointer_pos_ = nux::GetGraphicsDisplay()->GetMouseScreenCoord();
772 return true;661 return true;
773 }662 }
774663
@@ -785,7 +674,6 @@
785 {674 {
786 // Since this only happens on keyboard events, we need to prevent that the675 // Since this only happens on keyboard events, we need to prevent that the
787 // pointer tracker would select another entry.676 // pointer tracker would select another entry.
788 tracked_pointer_pos_ = nux::GetGraphicsDisplay()->GetMouseScreenCoord();
789 return true;677 return true;
790 }678 }
791679
792680
=== modified file 'panel/PanelView.h'
--- panel/PanelView.h 2016-03-30 18:18:07 +0000
+++ panel/PanelView.h 2016-08-30 14:38:39 +0000
@@ -35,7 +35,6 @@
35#include "unity-shared/Introspectable.h"35#include "unity-shared/Introspectable.h"
36#include "unity-shared/MenuManager.h"36#include "unity-shared/MenuManager.h"
37#include "unity-shared/MockableBaseWindow.h"37#include "unity-shared/MockableBaseWindow.h"
38#include "unity-shared/Timer.h"
39#include "PanelMenuView.h"38#include "PanelMenuView.h"
40#include "PanelTray.h"39#include "PanelTray.h"
41#include "PanelIndicatorsView.h"40#include "PanelIndicatorsView.h"
@@ -88,9 +87,6 @@
88 void OnObjectAdded(indicator::Indicator::Ptr const& proxy);87 void OnObjectAdded(indicator::Indicator::Ptr const& proxy);
89 void OnObjectRemoved(indicator::Indicator::Ptr const& proxy);88 void OnObjectRemoved(indicator::Indicator::Ptr const& proxy);
90 void OnIndicatorViewUpdated();89 void OnIndicatorViewUpdated();
91 void OnMenuPointerMoved(int x, int y);
92 void OnEntryActivated(std::string const& panel, std::string const& entry_id, nux::Rect const& geo);
93 void OnEntryShowMenu(std::string const& entry_id, unsigned xid, int x, int y, unsigned button);
9490
95private:91private:
96 std::string GetPanelName() const;92 std::string GetPanelName() const;
@@ -100,6 +96,8 @@
100 void OnSpreadInitiate();96 void OnSpreadInitiate();
101 void OnSpreadTerminate();97 void OnSpreadTerminate();
102 void OnLowGfxChanged();98 void OnLowGfxChanged();
99 void OnMenuPointerMoved(int x, int y, double speed);
100 void OnActiveEntryEvent(XEvent const&);
103 void EnableOverlayMode(bool);101 void EnableOverlayMode(bool);
104 void LoadTextures();102 void LoadTextures();
105103
@@ -109,7 +107,6 @@
109 bool IsTransparent();107 bool IsTransparent();
110 void UpdateBackground();108 void UpdateBackground();
111 void ForceUpdateBackground();109 void ForceUpdateBackground();
112 bool TrackMenuPointer();
113 void SyncGeometries();110 void SyncGeometries();
114 void AddPanelView(PanelIndicatorsView* child, unsigned int stretchFactor);111 void AddPanelView(PanelIndicatorsView* child, unsigned int stretchFactor);
115112
@@ -133,10 +130,6 @@
133 BaseTexturePtr bg_refine_single_column_tex_;130 BaseTexturePtr bg_refine_single_column_tex_;
134 std::unique_ptr<nux::AbstractPaintLayer> bg_refine_single_column_layer_;131 std::unique_ptr<nux::AbstractPaintLayer> bg_refine_single_column_layer_;
135132
136 std::string active_overlay_;
137 nux::Point tracked_pointer_pos_, triangle_top_corner_;
138 util::Timer mouse_tracker_timer_;
139
140 bool is_dirty_;133 bool is_dirty_;
141 bool opacity_maximized_toggle_;134 bool opacity_maximized_toggle_;
142 bool needs_geo_sync_;135 bool needs_geo_sync_;
@@ -144,15 +137,13 @@
144 float opacity_;137 float opacity_;
145 int monitor_;138 int monitor_;
146 int stored_dash_width_;139 int stored_dash_width_;
147140 std::string active_overlay_;
148 nux::Geometry menu_geo_;
149141
150 connection::Manager on_indicator_updated_connections_;142 connection::Manager on_indicator_updated_connections_;
151 connection::Manager maximized_opacity_toggle_connections_;143 connection::Manager maximized_opacity_toggle_connections_;
152 BackgroundEffectHelper bg_effect_helper_;144 BackgroundEffectHelper bg_effect_helper_;
153 nux::ObjectPtr<nux::IOpenGLBaseTexture> bg_blur_texture_;145 nux::ObjectPtr<nux::IOpenGLBaseTexture> bg_blur_texture_;
154 UBusManager ubus_manager_;146 UBusManager ubus_manager_;
155 glib::Source::UniquePtr track_menu_pointer_timeout_;
156};147};
157148
158} // namespace panel149} // namespace panel
159150
=== modified file 'plugins/unityshell/src/unityshell.h'
--- plugins/unityshell/src/unityshell.h 2016-08-12 11:21:48 +0000
+++ plugins/unityshell/src/unityshell.h 2016-08-30 14:38:39 +0000
@@ -56,6 +56,7 @@
56#include "DashStyle.h"56#include "DashStyle.h"
57#include "EdgeBarrierController.h"57#include "EdgeBarrierController.h"
58#include "FavoriteStoreGSettings.h"58#include "FavoriteStoreGSettings.h"
59#include "InputMonitor.h"
59#include "ShortcutController.h"60#include "ShortcutController.h"
60#include "LauncherController.h"61#include "LauncherController.h"
61#include "LockScreenController.h"62#include "LockScreenController.h"
@@ -317,6 +318,7 @@
317 internal::FavoriteStoreGSettings favorite_store_;318 internal::FavoriteStoreGSettings favorite_store_;
318 ThumbnailGenerator thumbnail_generator_;319 ThumbnailGenerator thumbnail_generator_;
319 lockscreen::Settings lockscreen_settings_;320 lockscreen::Settings lockscreen_settings_;
321 input::Monitor input_monitor_;
320322
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 */
322 std::unique_ptr<nux::WindowThread> wt;324 std::unique_ptr<nux::WindowThread> wt;
323325
=== modified file 'services/CMakeLists.txt'
--- services/CMakeLists.txt 2016-02-09 01:26:22 +0000
+++ services/CMakeLists.txt 2016-08-30 14:38:39 +0000
@@ -58,3 +58,34 @@
5858
59configure_file(unity-panel-service-lockscreen.conf.in ${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.conf)59configure_file(unity-panel-service-lockscreen.conf.in ${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.conf)
60install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.conf DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/sessions)60install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.conf DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/sessions)
61
62##
63## Systemd Unit Files
64##
65
66# where to install
67# Uncomment when we drop Vivid
68# pkg_get_variable(SYSTEMD_USER_DIR systemd systemduserunitdir)
69set (SYSTEMD_USER_DIR "/usr/lib/systemd/user")
70message (STATUS "${SYSTEMD_USER_DIR} is the systemd user unit file install dir")
71
72configure_file (unity-panel-service.service.in "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service.service")
73configure_file (unity-panel-service-lockscreen.service.in "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.service")
74
75install( FILES
76 "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service.service"
77 "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.service"
78 "${CMAKE_CURRENT_SOURCE_DIR}/unity-screen-locked.target"
79 DESTINATION "${SYSTEMD_USER_DIR}")
80
81##
82## Upstart systemd override Job File
83##
84
85set (UPSTART_SYSTEMD_OVERRIDE_DIR "${CMAKE_INSTALL_FULL_DATADIR}/upstart/systemd-session/upstart")
86message (STATUS "${UPSTART_SYSTEMD_OVERRIDE_DIR} is the Upstart override Job File for systemd dir")
87
88install (FILES
89 unity-panel-service.override
90 unity-panel-service-lockscreen.override
91 DESTINATION "${UPSTART_SYSTEMD_OVERRIDE_DIR}")
6192
=== added file 'services/unity-panel-service-lockscreen.override'
--- services/unity-panel-service-lockscreen.override 1970-01-01 00:00:00 +0000
+++ services/unity-panel-service-lockscreen.override 2016-08-30 14:38:39 +0000
@@ -0,0 +1,1 @@
1manual
02
=== added file 'services/unity-panel-service-lockscreen.service.in'
--- services/unity-panel-service-lockscreen.service.in 1970-01-01 00:00:00 +0000
+++ services/unity-panel-service-lockscreen.service.in 2016-08-30 14:38:39 +0000
@@ -0,0 +1,7 @@
1[Unit]
2Description=Backing Service for the Unity Panel in Lockscreen mode
3PartOf=unity-screen-locked.target
4
5[Service]
6ExecStart=${CMAKE_INSTALL_FULL_LIBDIR}/unity/unity-panel-service --lockscreen-mode
7Restart=on-failure
08
=== added file 'services/unity-panel-service.override'
--- services/unity-panel-service.override 1970-01-01 00:00:00 +0000
+++ services/unity-panel-service.override 2016-08-30 14:38:39 +0000
@@ -0,0 +1,1 @@
1manual
02
=== added file 'services/unity-panel-service.service.in'
--- services/unity-panel-service.service.in 1970-01-01 00:00:00 +0000
+++ services/unity-panel-service.service.in 2016-08-30 14:38:39 +0000
@@ -0,0 +1,9 @@
1[Unit]
2Description=Backing Service for the Unity Panel
3After=unity7.service
4PartOf=graphical-session.target
5BindsTo=indicators-pre.target
6
7[Service]
8ExecStart=${CMAKE_INSTALL_FULL_LIBDIR}/unity/unity-panel-service
9Restart=on-failure
010
=== added file 'services/unity-screen-locked.target'
--- services/unity-screen-locked.target 1970-01-01 00:00:00 +0000
+++ services/unity-screen-locked.target 2016-08-30 14:38:39 +0000
@@ -0,0 +1,4 @@
1[Unit]
2Description=A target that, when running, represents the screen being locked
3Wants=ubuntu-panel-service-lock.service
4PartOf=graphical-session.target
05
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2015-12-17 22:32:37 +0000
+++ tests/CMakeLists.txt 2016-08-30 14:38:39 +0000
@@ -286,6 +286,7 @@
286 test_switcher_controller_class.cpp286 test_switcher_controller_class.cpp
287 test_switcher_model.cpp287 test_switcher_model.cpp
288 test_switcher_view.cpp288 test_switcher_view.cpp
289 test_systemd_wrapper.cpp
289 test_tabiterator.cpp290 test_tabiterator.cpp
290 test_texture_cache.cpp291 test_texture_cache.cpp
291 test_text_input.cpp292 test_text_input.cpp
292293
=== modified file 'tests/test_edge_barrier_controller.cpp'
--- tests/test_edge_barrier_controller.cpp 2015-01-15 15:02:24 +0000
+++ tests/test_edge_barrier_controller.cpp 2016-08-30 14:38:39 +0000
@@ -25,6 +25,7 @@
2525
26#include "EdgeBarrierController.h"26#include "EdgeBarrierController.h"
27#include "EdgeBarrierControllerPrivate.h"27#include "EdgeBarrierControllerPrivate.h"
28#include "InputMonitor.h"
2829
29using namespace unity;30using namespace unity;
30using namespace unity::ui;31using namespace unity::ui;
@@ -108,6 +109,7 @@
108109
109 TestBarrierSubscriber horizontal_subscribers_[monitors::MAX];110 TestBarrierSubscriber horizontal_subscribers_[monitors::MAX];
110 TestBarrierSubscriber vertical_subscribers_[monitors::MAX];111 TestBarrierSubscriber vertical_subscribers_[monitors::MAX];
112 input::Monitor im;
111 MockUScreen uscreen;113 MockUScreen uscreen;
112 EdgeBarrierController bc;114 EdgeBarrierController bc;
113};115};
114116
=== modified file 'tests/test_lockscreen_controller.cpp'
--- tests/test_lockscreen_controller.cpp 2016-06-21 14:40:26 +0000
+++ tests/test_lockscreen_controller.cpp 2016-08-30 14:38:39 +0000
@@ -55,7 +55,7 @@
55struct MockShield : BaseShield55struct MockShield : BaseShield
56{56{
57 MockShield()57 MockShield()
58 : BaseShield(nullptr, nullptr, nullptr, nux::ObjectPtr<AbstractUserPromptView>(), 0, false)58 : BaseShield(nullptr, nullptr, nux::ObjectPtr<AbstractUserPromptView>(), 0, false)
59 {}59 {}
6060
61 MOCK_CONST_METHOD0(IsIndicatorOpen, bool());61 MOCK_CONST_METHOD0(IsIndicatorOpen, bool());
@@ -67,7 +67,7 @@
67struct ShieldFactoryMock : ShieldFactoryInterface67struct ShieldFactoryMock : ShieldFactoryInterface
68{68{
69 nux::ObjectPtr<BaseShield> CreateShield(session::Manager::Ptr const&,69 nux::ObjectPtr<BaseShield> CreateShield(session::Manager::Ptr const&,
70 indicator::Indicators::Ptr const&,70 menu::Manager::Ptr const&,
71 Accelerators::Ptr const&,71 Accelerators::Ptr const&,
72 nux::ObjectPtr<AbstractUserPromptView> const&,72 nux::ObjectPtr<AbstractUserPromptView> const&,
73 int, bool) override73 int, bool) override
@@ -83,9 +83,10 @@
83 , session_manager(std::make_shared<NiceMock<session::MockManager>>())83 , session_manager(std::make_shared<NiceMock<session::MockManager>>())
84 , key_grabber(std::make_shared<key::MockGrabber::Nice>())84 , key_grabber(std::make_shared<key::MockGrabber::Nice>())
85 , dbus_manager(std::make_shared<DBusManager>(session_manager))85 , dbus_manager(std::make_shared<DBusManager>(session_manager))
86 , systemd_wrapper(std::make_shared<SystemdWrapper>())
86 , upstart_wrapper(std::make_shared<UpstartWrapper>())87 , upstart_wrapper(std::make_shared<UpstartWrapper>())
87 , shield_factory(std::make_shared<ShieldFactoryMock>())88 , shield_factory(std::make_shared<ShieldFactoryMock>())
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)
89 {}90 {}
9091
91 struct ControllerWrap : Controller92 struct ControllerWrap : Controller
@@ -93,9 +94,10 @@
93 ControllerWrap(DBusManager::Ptr const& dbus_manager,94 ControllerWrap(DBusManager::Ptr const& dbus_manager,
94 session::Manager::Ptr const& session_manager,95 session::Manager::Ptr const& session_manager,
95 key::Grabber::Ptr const& key_grabber,96 key::Grabber::Ptr const& key_grabber,
97 SystemdWrapper::Ptr const& systemd_wrapper,
96 UpstartWrapper::Ptr const& upstart_wrapper,98 UpstartWrapper::Ptr const& upstart_wrapper,
97 ShieldFactoryInterface::Ptr const& shield_factory)99 ShieldFactoryInterface::Ptr const& shield_factory)
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)
99 {}101 {}
100102
101 using Controller::shields_;103 using Controller::shields_;
@@ -112,6 +114,7 @@
112 session::MockManager::Ptr session_manager;114 session::MockManager::Ptr session_manager;
113 key::MockGrabber::Ptr key_grabber;115 key::MockGrabber::Ptr key_grabber;
114 DBusManager::Ptr dbus_manager;116 DBusManager::Ptr dbus_manager;
117 unity::SystemdWrapper::Ptr systemd_wrapper;
115 unity::UpstartWrapper::Ptr upstart_wrapper;118 unity::UpstartWrapper::Ptr upstart_wrapper;
116119
117 ShieldFactoryMock::Ptr shield_factory;120 ShieldFactoryMock::Ptr shield_factory;
118121
=== modified file 'tests/test_panel_controller.cpp'
--- tests/test_panel_controller.cpp 2014-03-21 04:40:12 +0000
+++ tests/test_panel_controller.cpp 2016-08-30 14:38:39 +0000
@@ -19,6 +19,7 @@
1919
20#include <gmock/gmock.h>20#include <gmock/gmock.h>
2121
22#include "InputMonitor.h"
22#include "PanelController.h"23#include "PanelController.h"
23#include "PanelStyle.h"24#include "PanelStyle.h"
24#include "PanelView.h"25#include "PanelView.h"
@@ -46,6 +47,7 @@
46 menu::MockManager::Ptr menus;47 menu::MockManager::Ptr menus;
47 ui::EdgeBarrierController::Ptr edge_barriers;48 ui::EdgeBarrierController::Ptr edge_barriers;
48 launcher::Options::Ptr options;49 launcher::Options::Ptr options;
50 input::Monitor im;
49};51};
5052
51TEST_F(TestPanelController, Construction)53TEST_F(TestPanelController, Construction)
5254
=== modified file 'tests/test_panel_view.cpp'
--- tests/test_panel_view.cpp 2014-12-12 22:33:24 +0000
+++ tests/test_panel_view.cpp 2016-08-30 14:38:39 +0000
@@ -25,6 +25,7 @@
25#include "unity-shared/PanelStyle.h"25#include "unity-shared/PanelStyle.h"
26#include "unity-shared/UBusMessages.h"26#include "unity-shared/UBusMessages.h"
27#include "unity-shared/UBusWrapper.h"27#include "unity-shared/UBusWrapper.h"
28 #include "InputMonitor.h"
2829
29#include "mock_menu_manager.h"30#include "mock_menu_manager.h"
30#include "test_standalone_wm.h"31#include "test_standalone_wm.h"
@@ -43,6 +44,7 @@
43 nux::ObjectPtr<MockableBaseWindow> window_;44 nux::ObjectPtr<MockableBaseWindow> window_;
44 nux::ObjectPtr<PanelView> panel_view_;45 nux::ObjectPtr<PanelView> panel_view_;
45 testwrapper::StandaloneWM WM;46 testwrapper::StandaloneWM WM;
47 input::Monitor im;
4648
47 TestPanelView()49 TestPanelView()
48 : window_(new MockableBaseWindow())50 : window_(new MockableBaseWindow())
4951
=== added file 'tests/test_systemd_wrapper.cpp'
--- tests/test_systemd_wrapper.cpp 1970-01-01 00:00:00 +0000
+++ tests/test_systemd_wrapper.cpp 2016-08-30 14:38:39 +0000
@@ -0,0 +1,111 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3* Copyright (c) 2016 Canonical Ltd
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License version 3 as
7* published by the Free Software Foundation.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with this program. If not, see <http://www.gnu.org/licenses/>.
16*
17* Authored by: Ted Gould <ted@canonical.com>
18*/
19
20#include <gtest/gtest.h>
21using namespace testing;
22
23#include "unity-shared/SystemdWrapper.h"
24
25#include <UnityCore/GLibDBusServer.h>
26#include <UnityCore/Variant.h>
27
28#include "test_utils.h"
29
30namespace
31{
32
33const std::string SYSTEMD =
34R"(<node>
35 <interface name="org.freedesktop.systemd1.Manager">
36 <method name="StartUnit">
37 <arg name="name" type="s" direction="in" />
38 <arg name="mode" type="s" direction="in" />
39 <arg name="job" type="o" direction="out" />
40 </method>
41 <method name="StopUnit">
42 <arg name="name" type="s" direction="in" />
43 <arg name="mode" type="s" direction="in" />
44 <arg name="job" type="o" direction="out" />
45 </method>
46 </interface>
47</node>)";
48
49struct MockSystemdWrapper : unity::SystemdWrapper {
50 MockSystemdWrapper()
51 : SystemdWrapper(SystemdWrapper::TestMode())
52 {}
53};
54
55struct TestSystemdWrapper : public Test
56{
57 TestSystemdWrapper()
58 {
59 systemd_server_ = std::make_shared<unity::glib::DBusServer>("com.canonical.Unity.Test.Systemd");
60 systemd_server_->AddObjects(SYSTEMD, "/org/freedesktop/systemd1");
61
62 Utils::WaitUntilMSec([this] { return systemd_server_->IsConnected(); });
63 Utils::WaitUntilMSec([this] { return systemd_wrapper_.IsConnected(); });
64 }
65
66 unity::glib::DBusServer::Ptr systemd_server_;
67 MockSystemdWrapper systemd_wrapper_;
68};
69
70
71TEST_F(TestSystemdWrapper, Start)
72{
73 bool start_sent = false;
74
75 systemd_server_->GetObjects().front()->SetMethodsCallsHandler([&] (std::string const& method, GVariant* par) -> GVariant* {
76 if (method == "StartUnit")
77 {
78 start_sent = true;
79
80 std::string event_name = glib::Variant(g_variant_get_child_value(par, 0)).GetString();
81 EXPECT_EQ("unity-screen-locked", event_name);
82 }
83
84 return nullptr;
85 });
86
87 systemd_wrapper_.Start("unity-screen-locked");
88 Utils::WaitUntil(start_sent);
89}
90
91TEST_F(TestSystemdWrapper, Stop)
92{
93 bool stop_sent = false;
94
95 systemd_server_->GetObjects().front()->SetMethodsCallsHandler([&] (std::string const& method, GVariant* par) -> GVariant* {
96 if (method == "StopUnit")
97 {
98 stop_sent = true;
99
100 std::string event_name = glib::Variant(g_variant_get_child_value(par, 0)).GetString();
101 EXPECT_EQ("unity-screen-locked", event_name);
102 }
103
104 return nullptr;
105 });
106
107 systemd_wrapper_.Stop("unity-screen-locked");
108 Utils::WaitUntil(stop_sent);
109}
110
111}
0112
=== modified file 'tools/CMakeLists.txt'
--- tools/CMakeLists.txt 2016-07-18 17:26:01 +0000
+++ tools/CMakeLists.txt 2016-08-30 14:38:39 +0000
@@ -28,3 +28,6 @@
28add_executable(unity-active-plugins-safety-check unity_active_plugins_safety_check.cpp)28add_executable(unity-active-plugins-safety-check unity_active_plugins_safety_check.cpp)
29target_link_libraries(unity-active-plugins-safety-check ${LIBS})29target_link_libraries(unity-active-plugins-safety-check ${LIBS})
30install(TARGETS unity-active-plugins-safety-check DESTINATION ${CMAKE_INSTALL_LIBDIR}/unity/)30install(TARGETS unity-active-plugins-safety-check DESTINATION ${CMAKE_INSTALL_LIBDIR}/unity/)
31
32configure_file (${CMAKE_CURRENT_SOURCE_DIR}/unity-compiz-profile-select.in ${CMAKE_CURRENT_BINARY_DIR}/unity-compiz-profile-select @ONLY)
33install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity-compiz-profile-select DESTINATION ${CMAKE_INSTALL_LIBDIR}/unity/)
3134
=== added file 'tools/unity-compiz-profile-select.in'
--- tools/unity-compiz-profile-select.in 1970-01-01 00:00:00 +0000
+++ tools/unity-compiz-profile-select.in 2016-08-30 14:38:39 +0000
@@ -0,0 +1,25 @@
1#!/bin/bash
2
3set -e
4
5# If gnome-session is going to start compiz,
6# we don't want to be the ones doing it.
7
8if grep -q compiz /usr/share/gnome-session/sessions/ubuntu.session ; then
9 echo "GNOME Session is starting Compiz"
10 stop ; exit 0
11fi
12
13compiz_profile="ubuntu"
14
15if ! /usr/lib/nux/unity_support_test -p; then
16 compiz_profile="ubuntu-lowgfx"
17fi
18
19echo "Using compiz profile '$compiz_profile'"
20
21initctl set-env -g COMPIZ_CONFIG_PROFILE="$compiz_profile"
22systemctl set-environment --user COMPIZ_CONFIG_PROFILE="$compiz_profile"
23
24export COMPIZ_CONFIG_PROFILE="$compiz_profile"
25exec @CMAKE_INSTALL_LIBDIR@/unity/unity-active-plugins-safety-check
026
=== modified file 'unity-shared/CMakeLists.txt'
--- unity-shared/CMakeLists.txt 2016-08-12 11:21:48 +0000
+++ unity-shared/CMakeLists.txt 2016-08-30 14:38:39 +0000
@@ -60,6 +60,7 @@
60 SpreadFilter.cpp60 SpreadFilter.cpp
61 SpreadWidgets.cpp61 SpreadWidgets.cpp
62 StaticCairoText.cpp62 StaticCairoText.cpp
63 SystemdWrapper.cpp
63 TextureCache.cpp64 TextureCache.cpp
64 TextInput.cpp65 TextInput.cpp
65 TextureThumbnailProvider.cpp66 TextureThumbnailProvider.cpp
@@ -82,6 +83,7 @@
82 set (UNITY_SHARED_SOURCES83 set (UNITY_SHARED_SOURCES
83 XKeyboardUtil.cpp84 XKeyboardUtil.cpp
84 XWindowManager.cpp85 XWindowManager.cpp
86 InputMonitor.cpp
85 ${UNITY_SHARED_SOURCES}87 ${UNITY_SHARED_SOURCES}
86 )88 )
87else()89else()
8890
=== added file 'unity-shared/InputMonitor.cpp'
--- unity-shared/InputMonitor.cpp 1970-01-01 00:00:00 +0000
+++ unity-shared/InputMonitor.cpp 2016-08-30 14:38:39 +0000
@@ -0,0 +1,414 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright (C) 2014 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
18 */
19
20#include "InputMonitor.h"
21#include "SigcSlotHash.h"
22
23#include <Nux/Nux.h>
24#include <NuxCore/Logger.h>
25#include <X11/extensions/XInput2.h>
26#include <UnityCore/GLibSource.h>
27#include <unordered_set>
28#include <gdk/gdkx.h>
29#include <glib.h>
30
31namespace unity
32{
33namespace input
34{
35namespace
36{
37DECLARE_LOGGER(logger, "unity.input.monitor");
38
39Monitor* instance_ = nullptr;
40
41const unsigned XINPUT_MAJOR_VERSION = 2;
42const unsigned XINPUT_MINOR_VERSION = 3;
43
44bool operator&(Events l, Events r)
45{
46 typedef std::underlying_type<Events>::type ut;
47 return static_cast<ut>(static_cast<ut>(l) & static_cast<ut>(r));
48}
49
50Events& operator|=(Events& l, Events r)
51{
52 typedef std::underlying_type<Events>::type ut;
53 return l = static_cast<Events>(static_cast<ut>(l) | static_cast<ut>(r));
54}
55
56template <typename EVENT>
57void initialize_event_common(EVENT* ev, XIDeviceEvent* xiev)
58{
59 ev->serial = xiev->serial;
60 ev->send_event = xiev->send_event;
61 ev->display = xiev->display;
62 ev->window = xiev->event;
63 ev->root = xiev->root;
64 ev->subwindow = xiev->child;
65 ev->time = xiev->time;
66 ev->x = std::round(xiev->event_x);
67 ev->y = std::round(xiev->event_y);
68 ev->x_root = std::round(xiev->root_x);
69 ev->y_root = std::round(xiev->root_y);
70 ev->state = xiev->mods.effective;
71 ev->same_screen = True;
72}
73
74template <typename EVENT_TYPE, typename NATIVE_TYPE>
75void initialize_event(XEvent* ev, NATIVE_TYPE* xiev);
76
77template <>
78void initialize_event<XButtonEvent>(XEvent* ev, XIDeviceEvent* xiev)
79{
80 XButtonEvent* bev = &ev->xbutton;
81 ev->type = (xiev->evtype == XI_ButtonPress) ? ButtonPress : ButtonRelease;
82 initialize_event_common(bev, xiev);
83 bev->button = xiev->detail;
84}
85
86template <>
87void initialize_event<XKeyEvent>(XEvent* ev, XIDeviceEvent* xiev)
88{
89 XKeyEvent* kev = &ev->xkey;
90 ev->type = (xiev->evtype == XI_KeyPress) ? KeyPress : KeyRelease;
91 initialize_event_common(kev, xiev);
92 kev->keycode = xiev->detail;
93}
94
95template <>
96void initialize_event<XMotionEvent>(XEvent* ev, XIDeviceEvent* xiev)
97{
98 XMotionEvent* mev = &ev->xmotion;
99 ev->type = MotionNotify;
100 initialize_event_common(mev, xiev);
101 mev->is_hint = NotifyNormal;
102
103 for (int i = 0; i < xiev->buttons.mask_len * 8; ++i)
104 {
105 if (XIMaskIsSet(xiev->buttons.mask, i))
106 {
107 mev->is_hint = NotifyHint;
108 break;
109 }
110 }
111}
112
113template <>
114void initialize_event<XGenericEventCookie>(XEvent* ev, XIBarrierEvent* xiev)
115{
116 XGenericEventCookie* cev = &ev->xcookie;
117 cev->type = GenericEvent;
118 cev->serial = xiev->serial;
119 cev->send_event = xiev->send_event;
120 cev->display = xiev->display;
121 cev->evtype = xiev->evtype;
122 cev->data = xiev;
123}
124}
125
126struct Monitor::Impl
127{
128#if __GNUC__ < 6
129 using EventCallbackSet = std::unordered_set<EventCallback>;
130#else
131 using EventCallbackSet = std::unordered_set<EventCallback, std::hash<sigc::slot_base>>;
132#endif
133
134 Impl()
135 : xi_opcode_(0)
136 , event_filter_set_(false)
137 , invoking_callbacks_(false)
138 {
139 Display *dpy = gdk_x11_get_default_xdisplay();
140 int event_base, error_base;
141
142 if (XQueryExtension(dpy, "XInputExtension", &xi_opcode_, &event_base, &error_base))
143 {
144 int maj = XINPUT_MAJOR_VERSION;
145 int min = XINPUT_MINOR_VERSION;
146
147 if (XIQueryVersion(dpy, &maj, &min) == BadRequest)
148 {
149 LOG_ERROR(logger) << "Need XInput version "<< maj << "." << min << ", "
150 << "impossible, to setup an InputMonitor";
151 }
152 }
153 else
154 {
155 LOG_ERROR(logger) << "Missing XInput, impossible to setup an InputMonitor";
156 }
157 }
158
159 ~Impl()
160 {
161 if (event_filter_set_)
162 {
163 pointer_callbacks_.clear();
164 key_callbacks_.clear();
165 barrier_callbacks_.clear();
166 UpdateEventMonitor();
167 }
168 }
169
170 bool RegisterClient(Events type, EventCallback const& cb)
171 {
172 bool added = false;
173
174 if (type & Events::POINTER)
175 added = pointer_callbacks_.insert(cb).second || added;
176
177 if (type & Events::KEYS)
178 added = key_callbacks_.insert(cb).second || added;
179
180 if (type & Events::BARRIER)
181 added = barrier_callbacks_.insert(cb).second || added;
182
183 if (added)
184 UpdateEventMonitor();
185
186 return added;
187 }
188
189 bool UnregisterClient(EventCallback const& cb)
190 {
191 if (invoking_callbacks_)
192 {
193 // Delay the event removal if we're currently invoking a callback
194 // not to break the callbacks loop
195 removal_queue_.insert(cb);
196 return false;
197 }
198
199 bool removed = false;
200 removed = pointer_callbacks_.erase(cb) > 0 || removed;
201 removed = key_callbacks_.erase(cb) > 0 || removed;
202 removed = barrier_callbacks_.erase(cb) > 0 || removed;
203
204 if (removed)
205 UpdateEventMonitor();
206
207 return removed;
208 }
209
210 Events RegisteredEvents(EventCallback const& cb) const
211 {
212 Events events = Events::NONE;
213
214 if (pointer_callbacks_.find(cb) != end(pointer_callbacks_))
215 events |= Events::POINTER;
216
217 if (key_callbacks_.find(cb) != end(key_callbacks_))
218 events |= Events::KEYS;
219
220 if (barrier_callbacks_.find(cb) != end(barrier_callbacks_))
221 events |= Events::BARRIER;
222
223 return events;
224 }
225
226 void UpdateEventMonitor()
227 {
228 auto* dpy = nux::GetGraphicsDisplay()->GetX11Display();
229 Window root = DefaultRootWindow(dpy);
230
231 unsigned char master_dev_bits[XIMaskLen(XI_LASTEVENT)] = { 0 };
232 XIEventMask master_dev = { XIAllMasterDevices, sizeof(master_dev_bits), master_dev_bits };
233
234 if (!barrier_callbacks_.empty())
235 {
236 XISetMask(master_dev.mask, XI_BarrierHit);
237 XISetMask(master_dev.mask, XI_BarrierLeave);
238 }
239
240 unsigned char all_devs_bits[XIMaskLen(XI_LASTEVENT)] = { 0 };
241 XIEventMask all_devs = { XIAllDevices, sizeof(all_devs_bits), all_devs_bits };
242
243 if (!pointer_callbacks_.empty())
244 {
245 XISetMask(all_devs.mask, XI_Motion);
246 XISetMask(all_devs.mask, XI_ButtonPress);
247 XISetMask(all_devs.mask, XI_ButtonRelease);
248 }
249
250 if (!key_callbacks_.empty())
251 {
252 XISetMask(all_devs.mask, XI_KeyPress);
253 XISetMask(all_devs.mask, XI_KeyRelease);
254 }
255
256 XIEventMask selected[] = {master_dev, all_devs};
257 XISelectEvents(dpy, root, selected, G_N_ELEMENTS(selected));
258 XSync(dpy, False);
259
260 if (!pointer_callbacks_.empty() || !key_callbacks_.empty() || !barrier_callbacks_.empty())
261 {
262 if (!event_filter_set_)
263 {
264 nux::GetGraphicsDisplay()->AddEventFilter({[] (XEvent event, void* data) {
265 return static_cast<Impl*>(data)->HandleEvent(event);
266 }, this});
267
268 event_filter_set_ = true;
269 }
270 }
271 else if (event_filter_set_)
272 {
273 nux::GetGraphicsDisplay()->RemoveEventFilter(this);
274 event_filter_set_ = false;
275 }
276 }
277
278 bool HandleEvent(XEvent& event)
279 {
280 bool handled = false;
281
282 if (event.type != GenericEvent || event.xcookie.extension != xi_opcode_)
283 return handled;
284
285 switch (event.xcookie.evtype)
286 {
287 case XI_ButtonPress:
288 case XI_ButtonRelease:
289 handled = InvokeCallbacks<XButtonEvent>(pointer_callbacks_, event);
290 break;
291 case XI_Motion:
292 handled = InvokeCallbacks<XMotionEvent>(pointer_callbacks_, event);
293 break;
294 case XI_KeyPress:
295 case XI_KeyRelease:
296 handled = InvokeCallbacks<XKeyEvent>(key_callbacks_, event);
297 break;
298 case XI_BarrierHit:
299 case XI_BarrierLeave:
300 handled = InvokeCallbacks<XGenericEventCookie, XIBarrierEvent>(barrier_callbacks_, event);
301 break;
302 }
303
304 return handled;
305 }
306
307 template <typename EVENT_TYPE, typename NATIVE_TYPE = XIDeviceEvent>
308 bool InvokeCallbacks(EventCallbackSet& callbacks, XEvent& xiev)
309 {
310 XGenericEventCookie *cookie = &xiev.xcookie;
311
312 if (!XGetEventData(xiev.xany.display, cookie))
313 return false;
314
315 XEvent event;
316 initialize_event<EVENT_TYPE>(&event, reinterpret_cast<NATIVE_TYPE*>(cookie->data));
317 invoking_callbacks_ = true;
318
319 for (auto it = callbacks.begin(); it != callbacks.end();)
320 {
321 if (it->empty())
322 {
323 it = callbacks.erase(it);
324 continue;
325 }
326
327 (*it)(event);
328 ++it;
329 }
330
331 XFreeEventData(xiev.xany.display, cookie);
332 invoking_callbacks_ = false;
333
334 // A callback might unregister itself on the event callback, causing the
335 // above callbacks loop to crash, so in this case we save the event in the
336 // removal queue and eventually we unregistered these callbacks.
337 bool update_event_monitor = false;
338 for (auto it = removal_queue_.begin(); it != removal_queue_.end(); it = removal_queue_.erase(it))
339 {
340 auto const& cb = *it;
341 pointer_callbacks_.erase(cb);
342 key_callbacks_.erase(cb);
343 barrier_callbacks_.erase(cb);
344 update_event_monitor = true;
345 }
346
347 if (callbacks.empty() || update_event_monitor)
348 {
349 idle_removal_.reset(new glib::Idle([this] {
350 UpdateEventMonitor();
351 return false;
352 }));
353
354 return false;
355 }
356
357 return true;
358 }
359
360 int xi_opcode_;
361 bool event_filter_set_;
362 bool invoking_callbacks_;
363 glib::Source::UniquePtr idle_removal_;
364 EventCallbackSet pointer_callbacks_;
365 EventCallbackSet key_callbacks_;
366 EventCallbackSet barrier_callbacks_;
367 EventCallbackSet removal_queue_;
368};
369
370Monitor::Monitor()
371{
372 if (instance_)
373 {
374 LOG_WARN(logger) << "More than one input::Monitor created.";
375 return;
376 }
377
378 instance_ = this;
379 impl_.reset(new Impl());
380}
381
382Monitor::~Monitor()
383{
384 if (this == instance_)
385 instance_ = nullptr;
386}
387
388Monitor& Monitor::Get()
389{
390 if (!instance_)
391 {
392 LOG_ERROR(logger) << "No input::Monitor created yet.";
393 }
394
395 return *instance_;
396}
397
398bool Monitor::RegisterClient(Events events, EventCallback const& cb)
399{
400 return impl_->RegisterClient(events, cb);
401}
402
403bool Monitor::UnregisterClient(EventCallback const& cb)
404{
405 return impl_->UnregisterClient(cb);
406}
407
408Events Monitor::RegisteredEvents(EventCallback const& cb) const
409{
410 return impl_->RegisteredEvents(cb);
411}
412
413} // input namespace
414} // unity namespace
0415
=== added file 'unity-shared/InputMonitor.h'
--- unity-shared/InputMonitor.h 1970-01-01 00:00:00 +0000
+++ unity-shared/InputMonitor.h 2016-08-30 14:38:39 +0000
@@ -0,0 +1,67 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright (C) 2014 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
18 */
19
20#ifndef __UNITY_INPUT_MONITOR__
21#define __UNITY_INPUT_MONITOR__
22
23#include <X11/Xlib.h>
24#include <sigc++/slot.h>
25#include <memory>
26
27namespace unity
28{
29namespace input
30{
31enum class Events : unsigned
32{
33 NONE = 0,
34 POINTER = (1 << 0),
35 KEYS = (1 << 1),
36 BARRIER = (1 << 2),
37 INPUT = POINTER | KEYS,
38 ALL = POINTER | KEYS | BARRIER
39};
40
41class Monitor : public sigc::trackable
42{
43public:
44 typedef sigc::slot<void, XEvent const&> EventCallback;
45
46 static Monitor& Get();
47
48 Monitor();
49 virtual ~Monitor();
50
51 bool RegisterClient(Events, EventCallback const&);
52 bool UnregisterClient(EventCallback const&);
53
54 Events RegisteredEvents(EventCallback const&) const;
55
56private:
57 Monitor(Monitor const&) = delete;
58 Monitor& operator=(Monitor const&) = delete;
59
60 struct Impl;
61 std::unique_ptr<Impl> impl_;
62};
63
64} // input namespace
65} // unity namespace
66
67#endif // __UNITY_INPUT_MONITOR__
068
=== modified file 'unity-shared/MenuManager.cpp'
--- unity-shared/MenuManager.cpp 2015-10-02 14:02:05 +0000
+++ unity-shared/MenuManager.cpp 2016-08-30 14:38:39 +0000
@@ -21,11 +21,17 @@
21#include <gtk/gtk.h>21#include <gtk/gtk.h>
22#include <NuxCore/Logger.h>22#include <NuxCore/Logger.h>
23#include <UnityCore/GLibSignal.h>23#include <UnityCore/GLibSignal.h>
24#include <UnityCore/GLibSource.h>
24#include <UnityCore/GLibWrapper.h>25#include <UnityCore/GLibWrapper.h>
25#include <UnityCore/DBusIndicators.h>26#include <UnityCore/DBusIndicators.h>
26#include <unordered_map>27#include <unordered_map>
2728
28#include "MenuManager.h"29#include "MenuManager.h"
30#include "InputMonitor.h"
31#include "RawPixel.h"
32#include "SigcSlotHash.h"
33#include "UnitySettings.h"
34#include "UScreen.h"
29#include "WindowManager.h"35#include "WindowManager.h"
3036
31namespace unity37namespace unity
@@ -40,6 +46,10 @@
40const std::string LIM_KEY = "integrated-menus";46const std::string LIM_KEY = "integrated-menus";
41const std::string SHOW_MENUS_NOW_DELAY = "show-menus-now-delay";47const std::string SHOW_MENUS_NOW_DELAY = "show-menus-now-delay";
42const std::string ALWAYS_SHOW_MENUS_KEY = "always-show-menus";48const std::string ALWAYS_SHOW_MENUS_KEY = "always-show-menus";
49
50const RawPixel TRIANGLE_THRESHOLD = 5_em;
51const double SCRUB_VELOCITY_THRESHOLD = 0.05;
52const unsigned MENU_OPEN_MOUSE_WAIT = 150;
43}53}
4454
45using namespace indicator;55using namespace indicator;
@@ -51,6 +61,7 @@
51 , indicators_(indicators)61 , indicators_(indicators)
52 , key_grabber_(grabber)62 , key_grabber_(grabber)
53 , show_now_window_(0)63 , show_now_window_(0)
64 , last_pointer_time_(0)
54 , settings_(g_settings_new(SETTINGS_NAME.c_str()))65 , settings_(g_settings_new(SETTINGS_NAME.c_str()))
55 {66 {
56 for (auto const& indicator : indicators_->GetIndicators())67 for (auto const& indicator : indicators_->GetIndicators())
@@ -182,9 +193,15 @@
182 parent_->key_activate_entry.emit(entry_id);193 parent_->key_activate_entry.emit(entry_id);
183 }194 }
184195
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)
186 {197 {
187 parent_->menu_open = !geo.IsNull();198 parent_->menu_open = !geo.IsNull();
199
200 if (active_menubar_ != menubar)
201 {
202 active_menubar_ = menubar;
203 UpdateActiveTracker();
204 }
188 }205 }
189206
190 void SetShowNowForWindow(Window xid, bool show)207 void SetShowNowForWindow(Window xid, bool show)
@@ -231,15 +248,148 @@
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());
232 }249 }
233250
251 bool PointInTriangle(nux::Point const& p, nux::Point const& t0, nux::Point const& t1, nux::Point const& t2)
252 {
253 int s = t0.y * t2.x - t0.x * t2.y + (t2.y - t0.y) * p.x + (t0.x - t2.x) * p.y;
254 int t = t0.x * t1.y - t0.y * t1.x + (t0.y - t1.y) * p.x + (t1.x - t0.x) * p.y;
255
256 if ((s < 0) != (t < 0))
257 return false;
258
259 int A = -t1.y * t2.x + t0.y * (t2.x - t1.x) + t0.x * (t1.y - t2.y) + t1.x * t2.y;
260 if (A < 0)
261 {
262 s = -s;
263 t = -t;
264 A = -A;
265 }
266
267 return s > 0 && t > 0 && (s + t) < A;
268 }
269
270 double GetMouseVelocity(nux::Point const& p0, nux::Point const& p1, Time time_delta)
271 {
272 int dx, dy;
273 double speed;
274
275 if (time_delta == 0)
276 return 1;
277
278 dx = p0.x - p1.x;
279 dy = p0.y - p1.y;
280
281 speed = sqrt(dx * dx + dy * dy) / time_delta;
282
283 return speed;
284 }
285
286 void OnActiveEntryEvent(XEvent const& e)
287 {
288 if (e.type != MotionNotify)
289 return;
290
291 auto const& active_entry = indicators_->GetActiveEntry();
292
293 if (!active_entry)
294 return;
295
296 nux::Point mouse(e.xmotion.x_root, e.xmotion.y_root);
297 auto monitor = UScreen::GetDefault()->GetMonitorAtPosition(mouse.x, mouse.y);
298 double scale = Settings::Instance().em(monitor)->DPIScale();
299 double speed = GetMouseVelocity(mouse, tracked_pointer_pos_, e.xmotion.time - last_pointer_time_);
300 auto menu_geo = active_entry->geometry();
301
302 tracked_pointer_pos_ = mouse;
303 last_pointer_time_ = e.xmotion.time;
304
305 if (speed > SCRUB_VELOCITY_THRESHOLD &&
306 PointInTriangle(mouse, {mouse.x, std::max(mouse.y - TRIANGLE_THRESHOLD.CP(scale), 0)},
307 menu_geo.GetPosition(), {menu_geo.x + menu_geo.width, menu_geo.y}))
308 {
309 pointer_movement_timeout_ = std::make_shared<glib::Timeout>(MENU_OPEN_MOUSE_WAIT, [this, mouse, speed] {
310 if (active_tracker_)
311 active_tracker_(mouse.x, mouse.y, speed);
312
313 return false;
314 });
315
316 return;
317 }
318
319 if (active_tracker_)
320 {
321 pointer_movement_timeout_.reset();
322 active_tracker_(mouse.x, mouse.y, speed);
323 }
324 }
325
326 bool RegisterTracker(std::string const& menubar, PositionTracker const& cb)
327 {
328 auto it = position_trackers_.find(menubar);
329
330 if (it != end(position_trackers_))
331 return false;
332
333 position_trackers_.insert({menubar, cb});
334
335 if (active_menubar_ == menubar)
336 UpdateActiveTracker();
337
338 return true;
339 }
340
341 bool UnregisterTracker(std::string const& menubar, PositionTracker const& cb)
342 {
343 auto it = position_trackers_.find(menubar);
344
345 if (it == end(position_trackers_))
346 return false;
347
348 if (!cb || (cb && it->second == cb))
349 {
350 position_trackers_.erase(it);
351 UpdateActiveTracker();
352 return true;
353 }
354
355 return false;
356 }
357
358 void UpdateActiveTracker()
359 {
360 auto it = position_trackers_.find(active_menubar_);
361 active_tracker_ = (it != end(position_trackers_)) ? it->second : PositionTracker();
362 pointer_movement_timeout_.reset();
363
364 if (active_tracker_)
365 {
366 if (input::Monitor::Get().RegisterClient(input::Events::POINTER, sigc::mem_fun(this, &Impl::OnActiveEntryEvent)))
367 last_pointer_time_ = 0;
368 }
369 else
370 {
371 input::Monitor::Get().UnregisterClient(sigc::mem_fun(this, &Impl::OnActiveEntryEvent));
372
373 if (it != end(position_trackers_))
374 position_trackers_.erase(it);
375 }
376 }
377
234 Manager* parent_;378 Manager* parent_;
235 Indicators::Ptr indicators_;379 Indicators::Ptr indicators_;
236 AppmenuIndicator::Ptr appmenu_;380 AppmenuIndicator::Ptr appmenu_;
237 key::Grabber::Ptr key_grabber_;381 key::Grabber::Ptr key_grabber_;
238 Window show_now_window_;382 Window show_now_window_;
383 std::string active_menubar_;
384 PositionTracker active_tracker_;
385 nux::Point tracked_pointer_pos_;
386 Time last_pointer_time_;
387 glib::Source::Ptr pointer_movement_timeout_;
239 connection::Manager appmenu_connections_;388 connection::Manager appmenu_connections_;
240 connection::Wrapper active_win_conn_;389 connection::Wrapper active_win_conn_;
241 glib::Object<GSettings> settings_;390 glib::Object<GSettings> settings_;
242 glib::SignalManager signals_;391 glib::SignalManager signals_;
392 std::unordered_map<std::string, PositionTracker> position_trackers_;
243 std::unordered_map<indicator::Entry::Ptr, uint32_t> entry_actions_;393 std::unordered_map<indicator::Entry::Ptr, uint32_t> entry_actions_;
244};394};
245395
@@ -278,5 +428,16 @@
278 return impl_->key_grabber_;428 return impl_->key_grabber_;
279}429}
280430
431bool Manager::RegisterTracker(std::string const& menubar, PositionTracker const& cb)
432{
433 return impl_->RegisterTracker(menubar, cb);
434}
435
436bool Manager::UnregisterTracker(std::string const& menubar, PositionTracker const& cb)
437{
438 return impl_->UnregisterTracker(menubar, cb);
439}
440
441
281} // menu namespace442} // menu namespace
282} // unity namespace443} // unity namespace
283444
=== modified file 'unity-shared/MenuManager.h'
--- unity-shared/MenuManager.h 2015-06-05 14:28:27 +0000
+++ unity-shared/MenuManager.h 2016-08-30 14:38:39 +0000
@@ -67,6 +67,10 @@
6767
68 key::Grabber::Ptr const& KeyGrabber() const;68 key::Grabber::Ptr const& KeyGrabber() const;
6969
70 typedef sigc::slot<void, int /*x*/, int /*y*/, double /*speed*/> PositionTracker;
71 bool RegisterTracker(std::string const& menubar, PositionTracker const&);
72 bool UnregisterTracker(std::string const& menubar, PositionTracker const& = PositionTracker());
73
70 sigc::signal<void> appmenu_added;74 sigc::signal<void> appmenu_added;
71 sigc::signal<void> appmenu_removed;75 sigc::signal<void> appmenu_removed;
72 sigc::signal<bool>::accumulated<any_true> open_first;76 sigc::signal<bool>::accumulated<any_true> open_first;
7377
=== added file 'unity-shared/SigcSlotHash.h'
--- unity-shared/SigcSlotHash.h 1970-01-01 00:00:00 +0000
+++ unity-shared/SigcSlotHash.h 2016-08-30 14:38:39 +0000
@@ -0,0 +1,70 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright (C) 2016 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
18 */
19
20#ifndef __UNITY_SIGC_SLOT_HASHER__
21#define __UNITY_SIGC_SLOT_HASHER__
22
23#include <sigc++/slot.h>
24
25namespace sigc
26{
27inline bool operator==(slot_base const& lhs, slot_base const& rhs)
28{
29 if (!lhs.rep_ || !rhs.rep_)
30 return (lhs.rep_ == rhs.rep_);
31
32 return (lhs.rep_->call_ == rhs.rep_->call_);
33}
34
35inline bool operator!=(slot_base const& lhs, slot_base const& rhs)
36{
37 return !(lhs == rhs);
38}
39} // sigc namespace
40
41namespace std
42{
43
44template<>
45struct hash<sigc::slot_base>
46{
47 size_t operator()(sigc::slot_base const& cb) const
48 {
49 if (cb.rep_)
50 return hash<size_t>()(reinterpret_cast<size_t>(cb.rep_->call_));
51
52 return hash<size_t>()(reinterpret_cast<size_t>(cb.rep_));
53 }
54};
55
56#if __GNUC__ < 6
57template<class T>
58struct hash
59{
60 size_t operator()(T const& cb) const
61 {
62 static_assert(std::is_base_of<sigc::slot_base, T>::value, "Type is not derived from sigc::slot_base");
63 return hash<sigc::slot_base>()(cb);
64 }
65};
66#endif
67
68} // std namespace
69
70#endif // __UNITY_SIGC_SLOT_HASHER__
071
=== modified file 'unity-shared/StandaloneWindowManager.cpp'
--- unity-shared/StandaloneWindowManager.cpp 2015-11-20 11:33:38 +0000
+++ unity-shared/StandaloneWindowManager.cpp 2016-08-30 14:38:39 +0000
@@ -624,6 +624,9 @@
624 return std::string();624 return std::string();
625}625}
626626
627void StandaloneWindowManager::SetCardinalProperty(Window, Atom, std::vector<long> const&)
628{}
629
627std::vector<long> StandaloneWindowManager::GetCardinalProperty(Window, Atom) const630std::vector<long> StandaloneWindowManager::GetCardinalProperty(Window, Atom) const
628{631{
629 return std::vector<long>();632 return std::vector<long>();
630633
=== modified file 'unity-shared/StandaloneWindowManager.h'
--- unity-shared/StandaloneWindowManager.h 2016-03-18 18:58:26 +0000
+++ unity-shared/StandaloneWindowManager.h 2016-08-30 14:38:39 +0000
@@ -165,6 +165,7 @@
165 virtual std::string GetWindowName(Window window_id) const;165 virtual std::string GetWindowName(Window window_id) const;
166 virtual bool IsOnscreenKeyboard(Window window_id) const;166 virtual bool IsOnscreenKeyboard(Window window_id) const;
167 virtual std::string GetStringProperty(Window window_id, Atom) const;167 virtual std::string GetStringProperty(Window window_id, Atom) const;
168 virtual void SetCardinalProperty(Window window_id, Atom, std::vector<long> const&);
168 virtual std::vector<long> GetCardinalProperty(Window window_id, Atom) const;169 virtual std::vector<long> GetCardinalProperty(Window window_id, Atom) const;
169170
170 // Mock functions171 // Mock functions
171172
=== added file 'unity-shared/SystemdWrapper.cpp'
--- unity-shared/SystemdWrapper.cpp 1970-01-01 00:00:00 +0000
+++ unity-shared/SystemdWrapper.cpp 2016-08-30 14:38:39 +0000
@@ -0,0 +1,103 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 3 -*-
2/*
3* Copyright © 2016 Canonical Ltd
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License version 3 as
7* published by the Free Software Foundation.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with this program. If not, see <http://www.gnu.org/licenses/>.
16*
17* Authored by: Ted Gould <ted@canonical.com>
18*/
19
20#include "SystemdWrapper.h"
21
22#include <UnityCore/GLibDBusProxy.h>
23
24namespace unity
25{
26
27//
28// Start private implementation
29//
30
31class SystemdWrapper::Impl
32{
33public:
34 Impl(bool test);
35
36 void Start(std::string const& name);
37 void Stop(std::string const& name);
38 bool IsConnected();
39
40private:
41 glib::DBusProxy::Ptr systemd_proxy_;
42};
43
44SystemdWrapper::Impl::Impl(bool test)
45{
46 std::string busname = "org.freedesktop.systemd1";
47 if (test) {
48 busname = "com.canonical.Unity.Test.Systemd";
49 }
50
51 systemd_proxy_ = std::make_shared<unity::glib::DBusProxy>(busname, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager");
52}
53
54void SystemdWrapper::Impl::Start(std::string const& name)
55{
56 if (IsConnected()) {
57 systemd_proxy_->Call("StartUnit", g_variant_new("(ss)", name.c_str(), "replace"));
58 }
59}
60
61void SystemdWrapper::Impl::Stop(std::string const& name)
62{
63 if (IsConnected()) {
64 systemd_proxy_->Call("StopUnit", g_variant_new("(ss)", name.c_str(), "replace"));
65 }
66}
67
68bool SystemdWrapper::Impl::IsConnected()
69{
70 return systemd_proxy_->IsConnected();
71}
72
73//
74// End private implementation
75//
76
77SystemdWrapper::SystemdWrapper()
78 : pimpl_(new Impl(false))
79{}
80
81SystemdWrapper::SystemdWrapper(SystemdWrapper::TestMode const& tm)
82 : pimpl_(new Impl(true))
83{}
84
85SystemdWrapper::~SystemdWrapper()
86{}
87
88void SystemdWrapper::Start(std::string const& name)
89{
90 pimpl_->Start(name);
91}
92
93void SystemdWrapper::Stop(std::string const& name)
94{
95 pimpl_->Stop(name);
96}
97
98bool SystemdWrapper::IsConnected()
99{
100 return pimpl_->IsConnected();
101}
102
103}
0104
=== added file 'unity-shared/SystemdWrapper.h'
--- unity-shared/SystemdWrapper.h 1970-01-01 00:00:00 +0000
+++ unity-shared/SystemdWrapper.h 2016-08-30 14:38:39 +0000
@@ -0,0 +1,55 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3* Copyright © 2016 Canonical Ltd
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License version 3 as
7* published by the Free Software Foundation.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with this program. If not, see <http://www.gnu.org/licenses/>.
16*
17* Authored by: Ted Gould <ted@canonical.com>
18*/
19
20#ifndef UNITY_SYSTEMD_WRAPPER
21#define UNITY_SYSTEMD_WRAPPER
22
23#include <memory>
24
25namespace unity
26{
27
28class SystemdWrapper
29{
30public:
31 typedef std::shared_ptr<SystemdWrapper> Ptr;
32
33 SystemdWrapper();
34 ~SystemdWrapper();
35
36 void Start(std::string const& name);
37 void Stop(std::string const& name);
38 bool IsConnected();
39
40protected:
41 struct TestMode {};
42 SystemdWrapper(TestMode const&);
43
44private:
45 // Noncopyable
46 SystemdWrapper(SystemdWrapper const&) = delete;
47 SystemdWrapper& operator=(SystemdWrapper const&) = delete;
48
49 class Impl;
50 std::unique_ptr<Impl> pimpl_;
51};
52
53}
54
55#endif
056
=== modified file 'unity-shared/WindowManager.h'
--- unity-shared/WindowManager.h 2016-03-18 18:58:26 +0000
+++ unity-shared/WindowManager.h 2016-08-30 14:38:39 +0000
@@ -170,6 +170,7 @@
170 virtual bool IsOnscreenKeyboard(Window window_id) const = 0;170 virtual bool IsOnscreenKeyboard(Window window_id) const = 0;
171171
172 virtual std::string GetStringProperty(Window, Atom) const = 0;172 virtual std::string GetStringProperty(Window, Atom) const = 0;
173 virtual void SetCardinalProperty(Window, Atom, std::vector<long> const&) = 0;
173 virtual std::vector<long> GetCardinalProperty(Window, Atom) const = 0;174 virtual std::vector<long> GetCardinalProperty(Window, Atom) const = 0;
174175
175 virtual Cursor GetCachedCursor(unsigned int cursor_name) const = 0;176 virtual Cursor GetCachedCursor(unsigned int cursor_name) const = 0;
176177
=== modified file 'unity-shared/XWindowManager.cpp'
--- unity-shared/XWindowManager.cpp 2015-01-21 15:28:59 +0000
+++ unity-shared/XWindowManager.cpp 2016-08-30 14:38:39 +0000
@@ -123,6 +123,12 @@
123 return std::string(val, n_items);123 return std::string(val, n_items);
124}124}
125125
126void XWindowManager::SetCardinalProperty(Window window_id, Atom atom, std::vector<long> const& values)
127{
128 XChangeProperty(screen->dpy(), window_id, atom, XA_CARDINAL, 32, PropModeReplace,
129 (unsigned char *) values.data(), values.size());
130}
131
126std::vector<long> XWindowManager::GetCardinalProperty(Window window_id, Atom atom) const132std::vector<long> XWindowManager::GetCardinalProperty(Window window_id, Atom atom) const
127{133{
128 Atom type;134 Atom type;
129135
=== modified file 'unity-shared/XWindowManager.h'
--- unity-shared/XWindowManager.h 2015-01-21 15:28:59 +0000
+++ unity-shared/XWindowManager.h 2016-08-30 14:38:39 +0000
@@ -36,6 +36,7 @@
36 std::string GetWindowName(Window window_id) const;36 std::string GetWindowName(Window window_id) const;
37 bool IsOnscreenKeyboard(Window window_id) const;37 bool IsOnscreenKeyboard(Window window_id) const;
38 std::string GetStringProperty(Window window_id, Atom atom) const;38 std::string GetStringProperty(Window window_id, Atom atom) const;
39 void SetCardinalProperty(Window, Atom, std::vector<long> const&);
39 std::vector<long> GetCardinalProperty(Window, Atom) const;40 std::vector<long> GetCardinalProperty(Window, Atom) const;
40};41};
4142
4243
=== modified file 'unity7.conf.in'
--- unity7.conf.in 2016-07-21 13:01:59 +0000
+++ unity7.conf.in 2016-08-30 14:38:39 +0000
@@ -4,27 +4,7 @@
4start on xsession SESSION=ubuntu and started unity-settings-daemon4start on xsession SESSION=ubuntu and started unity-settings-daemon
5stop on desktop-end5stop on desktop-end
66
7pre-start script7pre-start exec @CMAKE_INSTALL_LIBDIR@/unity/unity-compiz-profile-select
8 # If gnome-session is going to start compiz,
9 # we don't want to be the ones doing it.
10
11 if grep -q compiz /usr/share/gnome-session/sessions/ubuntu.session ; then
12 echo "GNOME Session is starting Compiz"
13 stop ; exit 0
14 fi
15
16 compiz_profile="ubuntu"
17
18 if ! /usr/lib/nux/unity_support_test -p; then
19 compiz_profile="ubuntu-lowgfx"
20 fi
21
22 echo "Using compiz profile '$compiz_profile'"
23 initctl set-env -g COMPIZ_CONFIG_PROFILE="$compiz_profile"
24 export COMPIZ_CONFIG_PROFILE="$compiz_profile"
25
26 ${CMAKE_INSTALL_FULL_LIBDIR}/unity/unity-active-plugins-safety-check
27end script
288
29respawn9respawn
30exec compiz10exec compiz
3111
=== added file 'unity7.override'
--- unity7.override 1970-01-01 00:00:00 +0000
+++ unity7.override 2016-08-30 14:38:39 +0000
@@ -0,0 +1,1 @@
1manual
02
=== added file 'unity7.service.in'
--- unity7.service.in 1970-01-01 00:00:00 +0000
+++ unity7.service.in 2016-08-30 14:38:39 +0000
@@ -0,0 +1,11 @@
1[Unit]
2Description=Unity Shell v7
3Requires=unity-settings-daemon.service unity-panel-service.service bamfdaemon.service
4Wants=unity-gtk-module.service
5After=unity-settings-daemon.service
6PartOf=graphical-session.target
7
8[Service]
9ExecStart=/usr/bin/compiz
10ExecStart.Pre=@CMAKE_INSTALL_LIBDIR@/unity/unity-compiz-profile-select
11Restart=on-failure