Merge lp:~nick-dedekind/unity/lp857422.dash-mouse-steal into lp:unity
- lp857422.dash-mouse-steal
- Merge into trunk
Proposed by
Nick Dedekind
Status: | Merged |
---|---|
Approved by: | Brandon Schaefer |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2715 |
Proposed branch: | lp:~nick-dedekind/unity/lp857422.dash-mouse-steal |
Merge into: | lp:unity |
Diff against target: |
948 lines (+329/-111) 17 files modified
dash/DashController.cpp (+30/-13) dash/DashController.h (+4/-5) dash/DashView.cpp (+5/-0) dash/DashView.h (+2/-0) hud/HudAbstractView.h (+3/-1) hud/HudController.cpp (+42/-11) hud/HudController.h (+7/-3) hud/HudView.cpp (+60/-65) hud/HudView.h (+4/-5) hud/StandaloneHud.cpp (+1/-4) plugins/unityshell/src/unityshell.cpp (+45/-3) plugins/unityshell/src/unityshell.h (+2/-0) tests/autopilot/unity/emulators/dash.py (+4/-0) tests/autopilot/unity/tests/test_dash.py (+33/-0) tests/autopilot/unity/tests/test_hud.py (+32/-0) tests/test_hud_controller.cpp (+2/-1) unity-shared/ResizingBaseWindow.h (+53/-0) |
To merge this branch: | bzr merge lp:~nick-dedekind/unity/lp857422.dash-mouse-steal |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Brandon Schaefer (community) | Approve | ||
Review via email: mp+124221@code.launchpad.net |
Commit message
Dash/Hud no longer steal mouse events outside their content area. Better draw handling of hud animation.
Description of the change
Resize input window relative to the size of the dash/hud. Now only encompasses the required content area.
Added some draw performance fixes for the hud. (only redraw when needed)
To post a comment you must log in.
Revision history for this message
Nick Dedekind (nick-dedekind) wrote : | # |
Revision history for this message
Omer Akram (om26er) wrote : | # |
Has conflicts?
Revision history for this message
Nick Dedekind (nick-dedekind) wrote : | # |
Fixed conflicts.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote : | # |
I checked with trunk and the launcher looks the same as trunk so we are good there :).
Other then that everything looks awesome :). The tests worked for me, and it works manually for me as well. The launcher works, the Window buttons works...
soo this branch looks good to me :)
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'dash/DashController.cpp' | |||
2 | --- dash/DashController.cpp 2012-09-17 10:00:38 +0000 | |||
3 | +++ dash/DashController.cpp 2012-09-18 17:41:27 +0000 | |||
4 | @@ -66,13 +66,13 @@ | |||
5 | 66 | , timeline_animator_(90) | 66 | , timeline_animator_(90) |
6 | 67 | , dbus_connect_cancellable_(g_cancellable_new()) | 67 | , dbus_connect_cancellable_(g_cancellable_new()) |
7 | 68 | { | 68 | { |
8 | 69 | SetupRelayoutCallbacks(); | ||
9 | 70 | RegisterUBusInterests(); | 69 | RegisterUBusInterests(); |
10 | 71 | 70 | ||
11 | 72 | ensure_timeout_.Run([&]() { EnsureDash(); return false; }); | 71 | ensure_timeout_.Run([&]() { EnsureDash(); return false; }); |
12 | 73 | timeline_animator_.animation_updated.connect(sigc::mem_fun(this, &Controller::OnViewShowHideFrame)); | 72 | timeline_animator_.animation_updated.connect(sigc::mem_fun(this, &Controller::OnViewShowHideFrame)); |
13 | 74 | 73 | ||
14 | 75 | SetupWindow(); | 74 | SetupWindow(); |
15 | 75 | UScreen::GetDefault()->changed.connect([&] (int, std::vector<nux::Geometry>&) { Relayout(true); }); | ||
16 | 76 | 76 | ||
17 | 77 | Settings::Instance().changed.connect([&]() | 77 | Settings::Instance().changed.connect([&]() |
18 | 78 | { | 78 | { |
19 | @@ -97,7 +97,12 @@ | |||
20 | 97 | 97 | ||
21 | 98 | void Controller::SetupWindow() | 98 | void Controller::SetupWindow() |
22 | 99 | { | 99 | { |
24 | 100 | window_ = new nux::BaseWindow(dash::window_title); | 100 | window_ = new ResizingBaseWindow(dash::window_title, [this](nux::Geometry const& geo) |
25 | 101 | { | ||
26 | 102 | if (view_) | ||
27 | 103 | return GetInputWindowGeometry(); | ||
28 | 104 | return geo; | ||
29 | 105 | }); | ||
30 | 101 | window_->SetBackgroundColor(nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); | 106 | window_->SetBackgroundColor(nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); |
31 | 102 | window_->SetConfigureNotifyCallback(&Controller::OnWindowConfigure, this); | 107 | window_->SetConfigureNotifyCallback(&Controller::OnWindowConfigure, this); |
32 | 103 | window_->ShowWindow(false); | 108 | window_->ShowWindow(false); |
33 | @@ -122,19 +127,13 @@ | |||
34 | 122 | layout->SetContentDistribution(nux::eStackLeft); | 127 | layout->SetContentDistribution(nux::eStackLeft); |
35 | 123 | layout->SetVerticalExternalMargin(0); | 128 | layout->SetVerticalExternalMargin(0); |
36 | 124 | layout->SetHorizontalExternalMargin(0); | 129 | layout->SetHorizontalExternalMargin(0); |
37 | 125 | |||
38 | 126 | window_->SetLayout(layout); | 130 | window_->SetLayout(layout); |
39 | 131 | |||
40 | 132 | window_->UpdateInputWindowGeometry(); | ||
41 | 133 | |||
42 | 127 | ubus_manager_.UnregisterInterest(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST); | 134 | ubus_manager_.UnregisterInterest(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST); |
43 | 128 | } | 135 | } |
44 | 129 | 136 | ||
45 | 130 | void Controller::SetupRelayoutCallbacks() | ||
46 | 131 | { | ||
47 | 132 | GdkScreen* screen = gdk_screen_get_default(); | ||
48 | 133 | auto relayout_cb = sigc::mem_fun(this, &Controller::Relayout); | ||
49 | 134 | sig_manager_.Add<void, GdkScreen*>(screen, "monitors-changed", relayout_cb); | ||
50 | 135 | sig_manager_.Add<void, GdkScreen*>(screen, "size-changed", relayout_cb); | ||
51 | 136 | } | ||
52 | 137 | |||
53 | 138 | void Controller::RegisterUBusInterests() | 137 | void Controller::RegisterUBusInterests() |
54 | 139 | { | 138 | { |
55 | 140 | ubus_manager_.RegisterInterest(UBUS_DASH_EXTERNAL_ACTIVATION, | 139 | ubus_manager_.RegisterInterest(UBUS_DASH_EXTERNAL_ACTIVATION, |
56 | @@ -218,13 +217,19 @@ | |||
57 | 218 | monitor_geo.height - panel_style.panel_height); | 217 | monitor_geo.height - panel_style.panel_height); |
58 | 219 | } | 218 | } |
59 | 220 | 219 | ||
61 | 221 | void Controller::Relayout(GdkScreen*screen) | 220 | void Controller::Relayout(bool check_monitor) |
62 | 222 | { | 221 | { |
63 | 223 | EnsureDash(); | 222 | EnsureDash(); |
64 | 224 | 223 | ||
65 | 224 | if (check_monitor) | ||
66 | 225 | { | ||
67 | 226 | monitor_ = CLAMP(GetIdealMonitor(), 0, static_cast<int>(UScreen::GetDefault()->GetMonitors().size()-1)); | ||
68 | 227 | printf("relayout on monitor:%d, monitor count:%d\n", monitor_, static_cast<int>(UScreen::GetDefault()->GetMonitors().size())); | ||
69 | 228 | } | ||
70 | 229 | |||
71 | 225 | nux::Geometry geo = GetIdealWindowGeometry(); | 230 | nux::Geometry geo = GetIdealWindowGeometry(); |
72 | 231 | view_->Relayout(); | ||
73 | 226 | window_->SetGeometry(geo); | 232 | window_->SetGeometry(geo); |
74 | 227 | view_->Relayout(); | ||
75 | 228 | panel::Style &panel_style = panel::Style::Instance(); | 233 | panel::Style &panel_style = panel::Style::Instance(); |
76 | 229 | view_->SetMonitorOffset(launcher_width, panel_style.panel_height); | 234 | view_->SetMonitorOffset(launcher_width, panel_style.panel_height); |
77 | 230 | } | 235 | } |
78 | @@ -291,7 +296,11 @@ | |||
79 | 291 | window_->ShowWindow(true); | 296 | window_->ShowWindow(true); |
80 | 292 | window_->PushToFront(); | 297 | window_->PushToFront(); |
81 | 293 | if (!Settings::Instance().is_standalone) // in standalone mode, we do not need an input window. we are one. | 298 | if (!Settings::Instance().is_standalone) // in standalone mode, we do not need an input window. we are one. |
82 | 299 | { | ||
83 | 294 | window_->EnableInputWindow(true, dash::window_title, true, false); | 300 | window_->EnableInputWindow(true, dash::window_title, true, false); |
84 | 301 | // update the input window geometry. This causes the input window to match the actual size of the dash. | ||
85 | 302 | window_->UpdateInputWindowGeometry(); | ||
86 | 303 | } | ||
87 | 295 | window_->SetInputFocus(); | 304 | window_->SetInputFocus(); |
88 | 296 | window_->CaptureMouseDownAnyWhereElse(true); | 305 | window_->CaptureMouseDownAnyWhereElse(true); |
89 | 297 | window_->QueueDraw(); | 306 | window_->QueueDraw(); |
90 | @@ -445,6 +454,14 @@ | |||
91 | 445 | } | 454 | } |
92 | 446 | } | 455 | } |
93 | 447 | 456 | ||
94 | 457 | nux::Geometry Controller::GetInputWindowGeometry() | ||
95 | 458 | { | ||
96 | 459 | EnsureDash(); | ||
97 | 460 | nux::Geometry const& window_geo(window_->GetGeometry()); | ||
98 | 461 | nux::Geometry const& view_content_geo(view_->GetContentGeometry()); | ||
99 | 462 | return nux::Geometry(window_geo.x, window_geo.y, view_content_geo.width, view_content_geo.height); | ||
100 | 463 | } | ||
101 | 464 | |||
102 | 448 | 465 | ||
103 | 449 | } | 466 | } |
104 | 450 | } | 467 | } |
105 | 451 | 468 | ||
106 | === modified file 'dash/DashController.h' | |||
107 | --- dash/DashController.h 2012-09-13 10:56:42 +0000 | |||
108 | +++ dash/DashController.h 2012-09-18 17:41:27 +0000 | |||
109 | @@ -27,12 +27,12 @@ | |||
110 | 27 | #include <NuxCore/Property.h> | 27 | #include <NuxCore/Property.h> |
111 | 28 | #include <NuxGraphics/GraphicsEngine.h> | 28 | #include <NuxGraphics/GraphicsEngine.h> |
112 | 29 | #include <Nux/Nux.h> | 29 | #include <Nux/Nux.h> |
113 | 30 | #include <Nux/BaseWindow.h> | ||
114 | 31 | 30 | ||
115 | 32 | #include "DashView.h" | 31 | #include "DashView.h" |
116 | 33 | #include "unity-shared/Animator.h" | 32 | #include "unity-shared/Animator.h" |
117 | 34 | #include "unity-shared/Introspectable.h" | 33 | #include "unity-shared/Introspectable.h" |
118 | 35 | #include "unity-shared/UBusWrapper.h" | 34 | #include "unity-shared/UBusWrapper.h" |
119 | 35 | #include "unity-shared/ResizingBaseWindow.h" | ||
120 | 36 | 36 | ||
121 | 37 | namespace unity | 37 | namespace unity |
122 | 38 | { | 38 | { |
123 | @@ -60,6 +60,7 @@ | |||
124 | 60 | void HideDash(bool restore_focus = true); | 60 | void HideDash(bool restore_focus = true); |
125 | 61 | 61 | ||
126 | 62 | bool IsVisible() const; | 62 | bool IsVisible() const; |
127 | 63 | nux::Geometry GetInputWindowGeometry(); | ||
128 | 63 | 64 | ||
129 | 64 | protected: | 65 | protected: |
130 | 65 | std::string GetName() const; | 66 | std::string GetName() const; |
131 | @@ -69,12 +70,11 @@ | |||
132 | 69 | void EnsureDash(); | 70 | void EnsureDash(); |
133 | 70 | void SetupWindow(); | 71 | void SetupWindow(); |
134 | 71 | void SetupDashView(); | 72 | void SetupDashView(); |
135 | 72 | void SetupRelayoutCallbacks(); | ||
136 | 73 | void RegisterUBusInterests(); | 73 | void RegisterUBusInterests(); |
137 | 74 | 74 | ||
138 | 75 | nux::Geometry GetIdealWindowGeometry(); | 75 | nux::Geometry GetIdealWindowGeometry(); |
139 | 76 | int GetIdealMonitor(); | 76 | int GetIdealMonitor(); |
141 | 77 | void Relayout(GdkScreen*screen=NULL); | 77 | void Relayout(bool check_monitor =false); |
142 | 78 | 78 | ||
143 | 79 | void OnMouseDownOutsideWindow(int x, int y, unsigned long bflags, unsigned long kflags); | 79 | void OnMouseDownOutsideWindow(int x, int y, unsigned long bflags, unsigned long kflags); |
144 | 80 | void OnScreenUngrabbed(); | 80 | void OnScreenUngrabbed(); |
145 | @@ -96,7 +96,7 @@ | |||
146 | 96 | static void OnWindowConfigure(int width, int height, nux::Geometry& geo, void* data); | 96 | static void OnWindowConfigure(int width, int height, nux::Geometry& geo, void* data); |
147 | 97 | 97 | ||
148 | 98 | private: | 98 | private: |
150 | 99 | nux::ObjectPtr<nux::BaseWindow> window_; | 99 | nux::ObjectPtr<ResizingBaseWindow> window_; |
151 | 100 | int monitor_; | 100 | int monitor_; |
152 | 101 | 101 | ||
153 | 102 | bool visible_; | 102 | bool visible_; |
154 | @@ -104,7 +104,6 @@ | |||
155 | 104 | DashView* view_; | 104 | DashView* view_; |
156 | 105 | 105 | ||
157 | 106 | sigc::connection screen_ungrabbed_slot_; | 106 | sigc::connection screen_ungrabbed_slot_; |
158 | 107 | glib::SignalManager sig_manager_; | ||
159 | 108 | glib::TimeoutSeconds ensure_timeout_; | 107 | glib::TimeoutSeconds ensure_timeout_; |
160 | 109 | Animator timeline_animator_; | 108 | Animator timeline_animator_; |
161 | 110 | UBusManager ubus_manager_; | 109 | UBusManager ubus_manager_; |
162 | 111 | 110 | ||
163 | === modified file 'dash/DashView.cpp' | |||
164 | --- dash/DashView.cpp 2012-09-18 13:29:09 +0000 | |||
165 | +++ dash/DashView.cpp 2012-09-18 17:41:27 +0000 | |||
166 | @@ -1078,5 +1078,10 @@ | |||
167 | 1078 | return (view == nullptr) ? this : view; | 1078 | return (view == nullptr) ? this : view; |
168 | 1079 | } | 1079 | } |
169 | 1080 | 1080 | ||
170 | 1081 | nux::Geometry const& DashView::GetContentGeometry() const | ||
171 | 1082 | { | ||
172 | 1083 | return content_geo_; | ||
173 | 1084 | } | ||
174 | 1085 | |||
175 | 1081 | } | 1086 | } |
176 | 1082 | } | 1087 | } |
177 | 1083 | 1088 | ||
178 | === modified file 'dash/DashView.h' | |||
179 | --- dash/DashView.h 2012-08-17 07:28:10 +0000 | |||
180 | +++ dash/DashView.h 2012-09-18 17:41:27 +0000 | |||
181 | @@ -69,6 +69,8 @@ | |||
182 | 69 | 69 | ||
183 | 70 | nux::View* default_focus() const; | 70 | nux::View* default_focus() const; |
184 | 71 | 71 | ||
185 | 72 | nux::Geometry const& GetContentGeometry() const; | ||
186 | 73 | |||
187 | 72 | protected: | 74 | protected: |
188 | 73 | void ProcessDndEnter(); | 75 | void ProcessDndEnter(); |
189 | 74 | 76 | ||
190 | 75 | 77 | ||
191 | === modified file 'hud/HudAbstractView.h' | |||
192 | --- hud/HudAbstractView.h 2012-06-09 08:42:53 +0000 | |||
193 | +++ hud/HudAbstractView.h 2012-09-18 17:41:27 +0000 | |||
194 | @@ -48,8 +48,9 @@ | |||
195 | 48 | virtual void SearchFinished() = 0; | 48 | virtual void SearchFinished() = 0; |
196 | 49 | virtual void SetIcon(std::string const& icon_name, unsigned int tile_size, unsigned int size, unsigned int padding) = 0; | 49 | virtual void SetIcon(std::string const& icon_name, unsigned int tile_size, unsigned int size, unsigned int padding) = 0; |
197 | 50 | virtual void SetQueries(Hud::Queries queries) = 0; | 50 | virtual void SetQueries(Hud::Queries queries) = 0; |
199 | 51 | virtual void SetWindowGeometry(nux::Geometry const& absolute_geo, nux::Geometry const& geo) = 0; | 51 | virtual void SetMonitorOffset(int x, int y) = 0; |
200 | 52 | virtual void ShowEmbeddedIcon(bool show) = 0; | 52 | virtual void ShowEmbeddedIcon(bool show) = 0; |
201 | 53 | virtual nux::Geometry GetContentGeometry() = 0; | ||
202 | 53 | 54 | ||
203 | 54 | virtual nux::View* default_focus() const = 0; | 55 | virtual nux::View* default_focus() const = 0; |
204 | 55 | 56 | ||
205 | @@ -58,6 +59,7 @@ | |||
206 | 58 | sigc::signal<void, std::string> search_activated; | 59 | sigc::signal<void, std::string> search_activated; |
207 | 59 | sigc::signal<void, Query::Ptr> query_activated; | 60 | sigc::signal<void, Query::Ptr> query_activated; |
208 | 60 | sigc::signal<void, Query::Ptr> query_selected; | 61 | sigc::signal<void, Query::Ptr> query_selected; |
209 | 62 | sigc::signal<void> layout_changed; | ||
210 | 61 | }; | 63 | }; |
211 | 62 | 64 | ||
212 | 63 | } // namespace hud | 65 | } // namespace hud |
213 | 64 | 66 | ||
214 | === modified file 'hud/HudController.cpp' | |||
215 | --- hud/HudController.cpp 2012-09-17 10:00:38 +0000 | |||
216 | +++ hud/HudController.cpp 2012-09-18 17:41:27 +0000 | |||
217 | @@ -54,7 +54,7 @@ | |||
218 | 54 | { | 54 | { |
219 | 55 | LOG_DEBUG(logger) << "hud startup"; | 55 | LOG_DEBUG(logger) << "hud startup"; |
220 | 56 | SetupWindow(); | 56 | SetupWindow(); |
222 | 57 | UScreen::GetDefault()->changed.connect([&] (int, std::vector<nux::Geometry>&) { Relayout(); }); | 57 | UScreen::GetDefault()->changed.connect([&] (int, std::vector<nux::Geometry>&) { Relayout(true); }); |
223 | 58 | 58 | ||
224 | 59 | ubus.RegisterInterest(UBUS_HUD_CLOSE_REQUEST, sigc::mem_fun(this, &Controller::OnExternalHideHud)); | 59 | ubus.RegisterInterest(UBUS_HUD_CLOSE_REQUEST, sigc::mem_fun(this, &Controller::OnExternalHideHud)); |
225 | 60 | 60 | ||
226 | @@ -90,7 +90,12 @@ | |||
227 | 90 | // Since BaseWindow is a View it is initially unowned. This means that the first | 90 | // Since BaseWindow is a View it is initially unowned. This means that the first |
228 | 91 | // reference that is taken grabs ownership of the pointer. Since the smart pointer | 91 | // reference that is taken grabs ownership of the pointer. Since the smart pointer |
229 | 92 | // references it, it becomes the owner, so no need to adopt the pointer here. | 92 | // references it, it becomes the owner, so no need to adopt the pointer here. |
231 | 93 | window_ = new nux::BaseWindow("Hud"); | 93 | window_ = new ResizingBaseWindow("Hud", [this](nux::Geometry const& geo) |
232 | 94 | { | ||
233 | 95 | if (view_) | ||
234 | 96 | return GetInputWindowGeometry(); | ||
235 | 97 | return geo; | ||
236 | 98 | }); | ||
237 | 94 | window_->SetBackgroundColor(nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); | 99 | window_->SetBackgroundColor(nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); |
238 | 95 | window_->SetConfigureNotifyCallback(&Controller::OnWindowConfigure, this); | 100 | window_->SetConfigureNotifyCallback(&Controller::OnWindowConfigure, this); |
239 | 96 | window_->ShowWindow(false); | 101 | window_->ShowWindow(false); |
240 | @@ -117,6 +122,8 @@ | |||
241 | 117 | layout_->AddView(view_, 1, nux::MINOR_POSITION_TOP); | 122 | layout_->AddView(view_, 1, nux::MINOR_POSITION_TOP); |
242 | 118 | window_->SetLayout(layout_); | 123 | window_->SetLayout(layout_); |
243 | 119 | 124 | ||
244 | 125 | window_->UpdateInputWindowGeometry(); | ||
245 | 126 | |||
246 | 120 | view_->mouse_down_outside_pointer_grab_area.connect(sigc::mem_fun(this, &Controller::OnMouseDownOutsideWindow)); | 127 | view_->mouse_down_outside_pointer_grab_area.connect(sigc::mem_fun(this, &Controller::OnMouseDownOutsideWindow)); |
247 | 121 | 128 | ||
248 | 122 | LOG_DEBUG(logger) << "connecting to signals"; | 129 | LOG_DEBUG(logger) << "connecting to signals"; |
249 | @@ -124,6 +131,7 @@ | |||
250 | 124 | view_->search_activated.connect(sigc::mem_fun(this, &Controller::OnSearchActivated)); | 131 | view_->search_activated.connect(sigc::mem_fun(this, &Controller::OnSearchActivated)); |
251 | 125 | view_->query_activated.connect(sigc::mem_fun(this, &Controller::OnQueryActivated)); | 132 | view_->query_activated.connect(sigc::mem_fun(this, &Controller::OnQueryActivated)); |
252 | 126 | view_->query_selected.connect(sigc::mem_fun(this, &Controller::OnQuerySelected)); | 133 | view_->query_selected.connect(sigc::mem_fun(this, &Controller::OnQuerySelected)); |
253 | 134 | view_->layout_changed.connect(sigc::bind(sigc::mem_fun(this, &Controller::Relayout), nullptr)); | ||
254 | 127 | // Add to the debug introspection. | 135 | // Add to the debug introspection. |
255 | 128 | AddChild(view_); | 136 | AddChild(view_); |
256 | 129 | } | 137 | } |
257 | @@ -155,13 +163,15 @@ | |||
258 | 155 | 163 | ||
259 | 156 | void Controller::EnsureHud() | 164 | void Controller::EnsureHud() |
260 | 157 | { | 165 | { |
261 | 158 | LOG_DEBUG(logger) << "Initializing Hud"; | ||
262 | 159 | |||
263 | 160 | if (!window_) | 166 | if (!window_) |
264 | 167 | { | ||
265 | 168 | LOG_DEBUG(logger) << "Initializing Hud Window"; | ||
266 | 161 | SetupWindow(); | 169 | SetupWindow(); |
267 | 170 | } | ||
268 | 162 | 171 | ||
269 | 163 | if (!view_) | 172 | if (!view_) |
270 | 164 | { | 173 | { |
271 | 174 | LOG_DEBUG(logger) << "Initializing Hud View"; | ||
272 | 165 | SetupHudView(); | 175 | SetupHudView(); |
273 | 166 | Relayout(); | 176 | Relayout(); |
274 | 167 | } | 177 | } |
275 | @@ -212,16 +222,20 @@ | |||
276 | 212 | return geo; | 222 | return geo; |
277 | 213 | } | 223 | } |
278 | 214 | 224 | ||
280 | 215 | void Controller::Relayout() | 225 | void Controller::Relayout(bool check_monitor) |
281 | 216 | { | 226 | { |
282 | 217 | EnsureHud(); | 227 | EnsureHud(); |
284 | 218 | nux::Geometry const& content_geo = view_->GetGeometry(); | 228 | |
285 | 229 | if (check_monitor) | ||
286 | 230 | { | ||
287 | 231 | monitor_index_ = CLAMP(GetIdealMonitor(), 0, static_cast<int>(UScreen::GetDefault()->GetMonitors().size()-1)); | ||
288 | 232 | } | ||
289 | 219 | nux::Geometry const& geo = GetIdealWindowGeometry(); | 233 | nux::Geometry const& geo = GetIdealWindowGeometry(); |
290 | 220 | 234 | ||
291 | 235 | view_->Relayout(); | ||
292 | 221 | window_->SetGeometry(geo); | 236 | window_->SetGeometry(geo); |
296 | 222 | layout_->SetMinMaxSize(content_geo.width, content_geo.height); | 237 | panel::Style &panel_style = panel::Style::Instance(); |
297 | 223 | view_->SetWindowGeometry(window_->GetAbsoluteGeometry(), window_->GetGeometry()); | 238 | view_->SetMonitorOffset(launcher_width, panel_style.panel_height); |
295 | 224 | view_->Relayout(); | ||
298 | 225 | } | 239 | } |
299 | 226 | 240 | ||
300 | 227 | void Controller::OnMouseDownOutsideWindow(int x, int y, | 241 | void Controller::OnMouseDownOutsideWindow(int x, int y, |
301 | @@ -255,7 +269,15 @@ | |||
302 | 255 | { | 269 | { |
303 | 256 | LOG_DEBUG(logger) << "External Hiding the hud"; | 270 | LOG_DEBUG(logger) << "External Hiding the hud"; |
304 | 257 | EnsureHud(); | 271 | EnsureHud(); |
306 | 258 | HideHud(); | 272 | |
307 | 273 | if (variant) | ||
308 | 274 | { | ||
309 | 275 | HideHud(g_variant_get_boolean(variant)); | ||
310 | 276 | } | ||
311 | 277 | else | ||
312 | 278 | { | ||
313 | 279 | HideHud(); | ||
314 | 280 | } | ||
315 | 259 | } | 281 | } |
316 | 260 | 282 | ||
317 | 261 | void Controller::ShowHideHud() | 283 | void Controller::ShowHideHud() |
318 | @@ -353,6 +375,7 @@ | |||
319 | 353 | window_->ShowWindow(true); | 375 | window_->ShowWindow(true); |
320 | 354 | window_->PushToFront(); | 376 | window_->PushToFront(); |
321 | 355 | window_->EnableInputWindow(true, "Hud", true, false); | 377 | window_->EnableInputWindow(true, "Hud", true, false); |
322 | 378 | window_->UpdateInputWindowGeometry(); | ||
323 | 356 | window_->SetInputFocus(); | 379 | window_->SetInputFocus(); |
324 | 357 | window_->CaptureMouseDownAnyWhereElse(true); | 380 | window_->CaptureMouseDownAnyWhereElse(true); |
325 | 358 | view_->CaptureMouseDownAnyWhereElse(true); | 381 | view_->CaptureMouseDownAnyWhereElse(true); |
326 | @@ -363,7 +386,6 @@ | |||
327 | 363 | visible_ = true; | 386 | visible_ = true; |
328 | 364 | 387 | ||
329 | 365 | StartShowHideTimeline(); | 388 | StartShowHideTimeline(); |
330 | 366 | view_->SetWindowGeometry(window_->GetAbsoluteGeometry(), window_->GetGeometry()); | ||
331 | 367 | 389 | ||
332 | 368 | // hide the launcher | 390 | // hide the launcher |
333 | 369 | GVariant* message_data = g_variant_new("(b)", TRUE); | 391 | GVariant* message_data = g_variant_new("(b)", TRUE); |
334 | @@ -504,6 +526,15 @@ | |||
335 | 504 | .add("locked_to_launcher", IsLockedToLauncher(monitor_index_)); | 526 | .add("locked_to_launcher", IsLockedToLauncher(monitor_index_)); |
336 | 505 | } | 527 | } |
337 | 506 | 528 | ||
338 | 529 | nux::Geometry Controller::GetInputWindowGeometry() | ||
339 | 530 | { | ||
340 | 531 | EnsureHud(); | ||
341 | 532 | nux::Geometry const& window_geo(window_->GetGeometry()); | ||
342 | 533 | nux::Geometry const& view_content_geo(view_->GetContentGeometry()); | ||
343 | 534 | return nux::Geometry(window_geo.x, window_geo.y, view_content_geo.width, view_content_geo.height); | ||
344 | 535 | } | ||
345 | 536 | |||
346 | 537 | |||
347 | 507 | 538 | ||
348 | 508 | } | 539 | } |
349 | 509 | } | 540 | } |
350 | 510 | 541 | ||
351 | === modified file 'hud/HudController.h' | |||
352 | --- hud/HudController.h 2012-09-13 10:56:42 +0000 | |||
353 | +++ hud/HudController.h 2012-09-18 17:41:27 +0000 | |||
354 | @@ -24,14 +24,15 @@ | |||
355 | 24 | 24 | ||
356 | 25 | #include <gdk/gdk.h> | 25 | #include <gdk/gdk.h> |
357 | 26 | #include <UnityCore/Hud.h> | 26 | #include <UnityCore/Hud.h> |
358 | 27 | #include <UnityCore/GLibSignal.h> | ||
359 | 27 | 28 | ||
360 | 28 | #include <NuxCore/Property.h> | 29 | #include <NuxCore/Property.h> |
361 | 29 | #include <NuxGraphics/GraphicsEngine.h> | 30 | #include <NuxGraphics/GraphicsEngine.h> |
362 | 30 | #include <Nux/Nux.h> | 31 | #include <Nux/Nux.h> |
363 | 31 | #include <Nux/BaseWindow.h> | ||
364 | 32 | 32 | ||
365 | 33 | #include "unity-shared/Animator.h" | 33 | #include "unity-shared/Animator.h" |
366 | 34 | #include "unity-shared/UBusWrapper.h" | 34 | #include "unity-shared/UBusWrapper.h" |
367 | 35 | #include "unity-shared/ResizingBaseWindow.h" | ||
368 | 35 | #include "HudView.h" | 36 | #include "HudView.h" |
369 | 36 | 37 | ||
370 | 37 | namespace unity | 38 | namespace unity |
371 | @@ -59,6 +60,8 @@ | |||
372 | 59 | void HideHud(bool restore_focus = true); | 60 | void HideHud(bool restore_focus = true); |
373 | 60 | bool IsVisible(); | 61 | bool IsVisible(); |
374 | 61 | 62 | ||
375 | 63 | nux::Geometry GetInputWindowGeometry(); | ||
376 | 64 | |||
377 | 62 | protected: | 65 | protected: |
378 | 63 | // Introspectable | 66 | // Introspectable |
379 | 64 | std::string GetName() const; | 67 | std::string GetName() const; |
380 | @@ -75,7 +78,7 @@ | |||
381 | 75 | bool IsLockedToLauncher(int monitor); | 78 | bool IsLockedToLauncher(int monitor); |
382 | 76 | 79 | ||
383 | 77 | nux::Geometry GetIdealWindowGeometry(); | 80 | nux::Geometry GetIdealWindowGeometry(); |
385 | 78 | void Relayout(); | 81 | void Relayout(bool check_monitor =false); |
386 | 79 | 82 | ||
387 | 80 | void OnMouseDownOutsideWindow(int x, int y, unsigned long bflags, unsigned long kflags); | 83 | void OnMouseDownOutsideWindow(int x, int y, unsigned long bflags, unsigned long kflags); |
388 | 81 | void OnScreenUngrabbed(); | 84 | void OnScreenUngrabbed(); |
389 | @@ -96,8 +99,9 @@ | |||
390 | 96 | void OnQueriesFinished(Hud::Queries queries); | 99 | void OnQueriesFinished(Hud::Queries queries); |
391 | 97 | 100 | ||
392 | 98 | private: | 101 | private: |
394 | 99 | nux::ObjectPtr<nux::BaseWindow> window_; | 102 | nux::ObjectPtr<ResizingBaseWindow> window_; |
395 | 100 | UBusManager ubus; | 103 | UBusManager ubus; |
396 | 104 | glib::SignalManager sig_manager_; | ||
397 | 101 | Hud hud_service_; | 105 | Hud hud_service_; |
398 | 102 | bool visible_; | 106 | bool visible_; |
399 | 103 | bool need_show_; | 107 | bool need_show_; |
400 | 104 | 108 | ||
401 | === modified file 'hud/HudView.cpp' | |||
402 | --- hud/HudView.cpp 2012-09-13 10:56:42 +0000 | |||
403 | +++ hud/HudView.cpp 2012-09-18 17:41:27 +0000 | |||
404 | @@ -61,10 +61,10 @@ | |||
405 | 61 | : AbstractView() | 61 | : AbstractView() |
406 | 62 | , button_views_(nullptr) | 62 | , button_views_(nullptr) |
407 | 63 | , visible_(false) | 63 | , visible_(false) |
408 | 64 | , timeline_animating_(false) | ||
409 | 64 | , start_time_(0) | 65 | , start_time_(0) |
410 | 65 | , last_known_height_(0) | 66 | , last_known_height_(0) |
411 | 66 | , current_height_(0) | 67 | , current_height_(0) |
412 | 67 | , timeline_need_more_draw_(false) | ||
413 | 68 | , selected_button_(0) | 68 | , selected_button_(0) |
414 | 69 | , show_embedded_icon_(true) | 69 | , show_embedded_icon_(true) |
415 | 70 | , keyboard_stole_focus_(false) | 70 | , keyboard_stole_focus_(false) |
416 | @@ -122,6 +122,12 @@ | |||
417 | 122 | { | 122 | { |
418 | 123 | } | 123 | } |
419 | 124 | 124 | ||
420 | 125 | void View::SetMonitorOffset(int x, int y) | ||
421 | 126 | { | ||
422 | 127 | renderer_.x_offset = x; | ||
423 | 128 | renderer_.y_offset = y; | ||
424 | 129 | } | ||
425 | 130 | |||
426 | 125 | void View::ProcessGrowShrink() | 131 | void View::ProcessGrowShrink() |
427 | 126 | { | 132 | { |
428 | 127 | float diff = g_get_monotonic_time() - start_time_; | 133 | float diff = g_get_monotonic_time() - start_time_; |
429 | @@ -129,24 +135,25 @@ | |||
430 | 129 | // only animate if we are after our defined pause time | 135 | // only animate if we are after our defined pause time |
431 | 130 | if (diff > pause_before_grow_length) | 136 | if (diff > pause_before_grow_length) |
432 | 131 | { | 137 | { |
449 | 132 | float progress = (diff - pause_before_grow_length) / grow_anim_length; | 138 | float progress = (diff - pause_before_grow_length) / grow_anim_length; |
450 | 133 | int last_height = last_known_height_; | 139 | int last_height = last_known_height_; |
451 | 134 | int new_height = 0; | 140 | int new_height = 0; |
452 | 135 | 141 | ||
453 | 136 | if (last_height < target_height) | 142 | if (last_height < target_height) |
454 | 137 | { | 143 | { |
455 | 138 | // grow | 144 | // grow |
456 | 139 | new_height = last_height + ((target_height - last_height) * progress); | 145 | new_height = last_height + ((target_height - last_height) * progress); |
457 | 140 | } | 146 | } |
458 | 141 | else | 147 | else |
459 | 142 | { | 148 | { |
460 | 143 | //shrink | 149 | //shrink |
461 | 144 | new_height = last_height - ((last_height - target_height) * progress); | 150 | new_height = last_height - ((last_height - target_height) * progress); |
462 | 145 | } | 151 | } |
463 | 146 | 152 | ||
464 | 147 | LOG_DEBUG(logger) << "resizing to " << target_height << " (" << new_height << ")" | 153 | |
465 | 154 | LOG_DEBUG(logger) << "resizing to " << target_height << " (" << new_height << ")" | ||
466 | 148 | << "View height: " << GetGeometry().height; | 155 | << "View height: " << GetGeometry().height; |
468 | 149 | current_height_ = new_height; | 156 | current_height_ = new_height; |
469 | 150 | } | 157 | } |
470 | 151 | 158 | ||
471 | 152 | for (auto button : buttons_) | 159 | for (auto button : buttons_) |
472 | @@ -154,14 +161,23 @@ | |||
473 | 154 | button->SetSkipDraw((button->GetAbsoluteY() + button->GetBaseHeight()) > (GetAbsoluteY() + current_height_)); | 161 | button->SetSkipDraw((button->GetAbsoluteY() + button->GetBaseHeight()) > (GetAbsoluteY() + current_height_)); |
474 | 155 | } | 162 | } |
475 | 156 | 163 | ||
476 | 157 | QueueDraw(); | ||
477 | 158 | |||
478 | 159 | if (diff > grow_anim_length + pause_before_grow_length) | 164 | if (diff > grow_anim_length + pause_before_grow_length) |
479 | 160 | { | 165 | { |
480 | 161 | // ensure we are at our final location and update last known height | 166 | // ensure we are at our final location and update last known height |
481 | 162 | current_height_ = target_height; | 167 | current_height_ = target_height; |
482 | 163 | last_known_height_ = target_height; | 168 | last_known_height_ = target_height; |
484 | 164 | timeline_need_more_draw_ = false; | 169 | |
485 | 170 | layout_changed.emit(); | ||
486 | 171 | timeline_idle_.reset(); | ||
487 | 172 | timeline_animating_ = false; | ||
488 | 173 | } | ||
489 | 174 | else | ||
490 | 175 | { | ||
491 | 176 | timeline_idle_.reset(new glib::Timeout(0, [this] | ||
492 | 177 | { | ||
493 | 178 | QueueDraw(); | ||
494 | 179 | return false; | ||
495 | 180 | })); | ||
496 | 165 | } | 181 | } |
497 | 166 | } | 182 | } |
498 | 167 | 183 | ||
499 | @@ -187,27 +203,6 @@ | |||
500 | 187 | QueueDraw(); | 203 | QueueDraw(); |
501 | 188 | } | 204 | } |
502 | 189 | 205 | ||
503 | 190 | long View::PostLayoutManagement(long LayoutResult) | ||
504 | 191 | { | ||
505 | 192 | Relayout(); | ||
506 | 193 | if (GetGeometry().height != last_known_height_) | ||
507 | 194 | { | ||
508 | 195 | // Start the timeline of drawing the dash resize | ||
509 | 196 | if (timeline_need_more_draw_) | ||
510 | 197 | { | ||
511 | 198 | // already started, just reset the last known height | ||
512 | 199 | last_known_height_ = current_height_; | ||
513 | 200 | } | ||
514 | 201 | |||
515 | 202 | timeline_need_more_draw_ = true; | ||
516 | 203 | start_time_ = g_get_monotonic_time(); | ||
517 | 204 | QueueDraw(); | ||
518 | 205 | } | ||
519 | 206 | |||
520 | 207 | return LayoutResult; | ||
521 | 208 | } | ||
522 | 209 | |||
523 | 210 | |||
524 | 211 | nux::View* View::default_focus() const | 206 | nux::View* View::default_focus() const |
525 | 212 | { | 207 | { |
526 | 213 | return search_bar_->text_entry(); | 208 | return search_bar_->text_entry(); |
527 | @@ -361,14 +356,6 @@ | |||
528 | 361 | renderer_.AboutToHide(); | 356 | renderer_.AboutToHide(); |
529 | 362 | } | 357 | } |
530 | 363 | 358 | ||
531 | 364 | void View::SetWindowGeometry(nux::Geometry const& absolute_geo, nux::Geometry const& geo) | ||
532 | 365 | { | ||
533 | 366 | window_geometry_ = geo; | ||
534 | 367 | window_geometry_.x = 0; | ||
535 | 368 | window_geometry_.y = 0; | ||
536 | 369 | absolute_window_geometry_ = absolute_geo; | ||
537 | 370 | } | ||
538 | 371 | |||
539 | 372 | void View::SetupViews() | 359 | void View::SetupViews() |
540 | 373 | { | 360 | { |
541 | 374 | dash::Style& style = dash::Style::Instance(); | 361 | dash::Style& style = dash::Style::Instance(); |
542 | @@ -405,6 +392,17 @@ | |||
543 | 405 | content_layout_->AddLayout(button_views_.GetPointer(), 1, nux::MINOR_POSITION_LEFT); | 392 | content_layout_->AddLayout(button_views_.GetPointer(), 1, nux::MINOR_POSITION_LEFT); |
544 | 406 | } | 393 | } |
545 | 407 | 394 | ||
546 | 395 | content_layout_->OnGeometryChanged.connect([&](nux::Area*, nux::Geometry& geo) | ||
547 | 396 | { | ||
548 | 397 | if (!timeline_animating_) | ||
549 | 398 | { | ||
550 | 399 | timeline_animating_ = true; | ||
551 | 400 | start_time_ = g_get_monotonic_time(); | ||
552 | 401 | QueueDraw(); | ||
553 | 402 | } | ||
554 | 403 | }); | ||
555 | 404 | |||
556 | 405 | |||
557 | 408 | layout_->AddLayout(content_layout_.GetPointer(), 1, nux::MINOR_POSITION_TOP); | 406 | layout_->AddLayout(content_layout_.GetPointer(), 1, nux::MINOR_POSITION_TOP); |
558 | 409 | } | 407 | } |
559 | 410 | 408 | ||
560 | @@ -450,14 +448,12 @@ | |||
561 | 450 | 448 | ||
562 | 451 | void View::Draw(nux::GraphicsEngine& gfx_context, bool force_draw) | 449 | void View::Draw(nux::GraphicsEngine& gfx_context, bool force_draw) |
563 | 452 | { | 450 | { |
566 | 453 | if (timeline_need_more_draw_) | 451 | if (timeline_animating_) |
565 | 454 | { | ||
567 | 455 | ProcessGrowShrink(); | 452 | ProcessGrowShrink(); |
568 | 456 | } | ||
569 | 457 | 453 | ||
570 | 458 | nux::Geometry draw_content_geo(layout_->GetGeometry()); | 454 | nux::Geometry draw_content_geo(layout_->GetGeometry()); |
571 | 459 | draw_content_geo.height = current_height_; | 455 | draw_content_geo.height = current_height_; |
573 | 460 | renderer_.DrawFull(gfx_context, draw_content_geo, absolute_window_geometry_, window_geometry_, true); | 456 | renderer_.DrawFull(gfx_context, draw_content_geo, GetAbsoluteGeometry(), GetGeometry(), true); |
574 | 461 | } | 457 | } |
575 | 462 | 458 | ||
576 | 463 | void View::DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw) | 459 | void View::DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw) |
577 | @@ -465,7 +461,7 @@ | |||
578 | 465 | nux::Geometry draw_content_geo(layout_->GetGeometry()); | 461 | nux::Geometry draw_content_geo(layout_->GetGeometry()); |
579 | 466 | draw_content_geo.height = current_height_; | 462 | draw_content_geo.height = current_height_; |
580 | 467 | 463 | ||
582 | 468 | renderer_.DrawInner(gfx_context, draw_content_geo, absolute_window_geometry_, window_geometry_); | 464 | renderer_.DrawInner(gfx_context, draw_content_geo, GetAbsoluteGeometry(), GetGeometry()); |
583 | 469 | 465 | ||
584 | 470 | gfx_context.PushClippingRectangle(draw_content_geo); | 466 | gfx_context.PushClippingRectangle(draw_content_geo); |
585 | 471 | 467 | ||
586 | @@ -492,16 +488,7 @@ | |||
587 | 492 | } | 488 | } |
588 | 493 | gfx_context.PopClippingRectangle(); | 489 | gfx_context.PopClippingRectangle(); |
589 | 494 | 490 | ||
600 | 495 | renderer_.DrawInnerCleanup(gfx_context, draw_content_geo, absolute_window_geometry_, window_geometry_); | 491 | renderer_.DrawInnerCleanup(gfx_context, draw_content_geo, GetAbsoluteGeometry(), GetGeometry()); |
591 | 496 | |||
592 | 497 | if (timeline_need_more_draw_ && !timeline_idle_) | ||
593 | 498 | { | ||
594 | 499 | timeline_idle_.reset(new glib::Idle([&] () { | ||
595 | 500 | QueueDraw(); | ||
596 | 501 | timeline_idle_.reset(); | ||
597 | 502 | return false; | ||
598 | 503 | })); | ||
599 | 504 | } | ||
601 | 505 | } | 492 | } |
602 | 506 | 493 | ||
603 | 507 | void View::MouseStealsHudButtonFocus() | 494 | void View::MouseStealsHudButtonFocus() |
604 | @@ -769,6 +756,14 @@ | |||
605 | 769 | return search_bar_->text_entry(); | 756 | return search_bar_->text_entry(); |
606 | 770 | } | 757 | } |
607 | 771 | 758 | ||
608 | 759 | nux::Geometry View::GetContentGeometry() | ||
609 | 760 | { | ||
610 | 761 | nux::Geometry geo(content_geo_); | ||
611 | 762 | geo.height = current_height_; | ||
612 | 763 | return geo; | ||
613 | 764 | } | ||
614 | 765 | |||
615 | 766 | |||
616 | 772 | } | 767 | } |
617 | 773 | } | 768 | } |
618 | 774 | 769 | ||
619 | 775 | 770 | ||
620 | === modified file 'hud/HudView.h' | |||
621 | --- hud/HudView.h 2012-09-04 18:15:34 +0000 | |||
622 | +++ hud/HudView.h 2012-09-18 17:41:27 +0000 | |||
623 | @@ -60,7 +60,9 @@ | |||
624 | 60 | void AboutToShow(); | 60 | void AboutToShow(); |
625 | 61 | void AboutToHide(); | 61 | void AboutToHide(); |
626 | 62 | 62 | ||
628 | 63 | void SetWindowGeometry(nux::Geometry const& absolute_geo, nux::Geometry const& geo); | 63 | void SetMonitorOffset(int x, int y); |
629 | 64 | |||
630 | 65 | nux::Geometry GetContentGeometry(); | ||
631 | 64 | 66 | ||
632 | 65 | protected: | 67 | protected: |
633 | 66 | virtual Area* FindKeyFocusArea(unsigned int event_type, | 68 | virtual Area* FindKeyFocusArea(unsigned int event_type, |
634 | @@ -69,7 +71,6 @@ | |||
635 | 69 | 71 | ||
636 | 70 | void SetupViews(); | 72 | void SetupViews(); |
637 | 71 | void OnSearchChanged(std::string const& search_string); | 73 | void OnSearchChanged(std::string const& search_string); |
638 | 72 | virtual long PostLayoutManagement(long LayoutResult); | ||
639 | 73 | 74 | ||
640 | 74 | private: | 75 | private: |
641 | 75 | void OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key); | 76 | void OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key); |
642 | @@ -110,14 +111,12 @@ | |||
643 | 110 | Hud::Queries queries_; | 111 | Hud::Queries queries_; |
644 | 111 | nux::Geometry content_geo_; | 112 | nux::Geometry content_geo_; |
645 | 112 | OverlayRenderer renderer_; | 113 | OverlayRenderer renderer_; |
646 | 113 | nux::Geometry window_geometry_; | ||
647 | 114 | nux::Geometry absolute_window_geometry_; | ||
648 | 115 | glib::Source::UniquePtr timeline_idle_; | 114 | glib::Source::UniquePtr timeline_idle_; |
649 | 115 | bool timeline_animating_; | ||
650 | 116 | 116 | ||
651 | 117 | guint64 start_time_; | 117 | guint64 start_time_; |
652 | 118 | int last_known_height_; | 118 | int last_known_height_; |
653 | 119 | int current_height_; | 119 | int current_height_; |
654 | 120 | bool timeline_need_more_draw_; | ||
655 | 121 | int selected_button_; | 120 | int selected_button_; |
656 | 122 | bool show_embedded_icon_; | 121 | bool show_embedded_icon_; |
657 | 123 | bool activated_signal_sent_; | 122 | bool activated_signal_sent_; |
658 | 124 | 123 | ||
659 | === modified file 'hud/StandaloneHud.cpp' | |||
660 | --- hud/StandaloneHud.cpp 2012-06-01 15:24:14 +0000 | |||
661 | +++ hud/StandaloneHud.cpp 2012-09-18 17:41:27 +0000 | |||
662 | @@ -69,7 +69,7 @@ | |||
663 | 69 | 69 | ||
664 | 70 | hud_view_ = new unity::hud::View(); | 70 | hud_view_ = new unity::hud::View(); |
665 | 71 | 71 | ||
667 | 72 | layout->AddView (hud_view_, 0, nux::MINOR_POSITION_TOP); | 72 | layout->AddView (hud_view_, 1, nux::MINOR_POSITION_TOP); |
668 | 73 | nux::GetWindowCompositor().SetKeyFocusArea(hud_view_->default_focus()); | 73 | nux::GetWindowCompositor().SetKeyFocusArea(hud_view_->default_focus()); |
669 | 74 | 74 | ||
670 | 75 | nux::GetWindowThread()->SetLayout (layout); | 75 | nux::GetWindowThread()->SetLayout (layout); |
671 | @@ -109,9 +109,6 @@ | |||
672 | 109 | }); | 109 | }); |
673 | 110 | 110 | ||
674 | 111 | hud_service_.RequestQuery(""); | 111 | hud_service_.RequestQuery(""); |
675 | 112 | |||
676 | 113 | hud_view_->SetWindowGeometry(layout->GetAbsoluteGeometry(), layout->GetGeometry()); | ||
677 | 114 | |||
678 | 115 | } | 112 | } |
679 | 116 | 113 | ||
680 | 117 | void TestRunner::InitWindowThread(nux::NThread* thread, void* InitData) | 114 | void TestRunner::InitWindowThread(nux::NThread* thread, void* InitData) |
681 | 118 | 115 | ||
682 | === modified file 'plugins/unityshell/src/unityshell.cpp' | |||
683 | --- plugins/unityshell/src/unityshell.cpp 2012-09-18 01:41:46 +0000 | |||
684 | +++ plugins/unityshell/src/unityshell.cpp 2012-09-18 17:41:27 +0000 | |||
685 | @@ -913,6 +913,33 @@ | |||
686 | 913 | } | 913 | } |
687 | 914 | } | 914 | } |
688 | 915 | 915 | ||
689 | 916 | bool UnityScreen::DoesPointIntersectUnityGeos(nux::Point const& pt) | ||
690 | 917 | { | ||
691 | 918 | auto launchers = launcher_controller_->launchers(); | ||
692 | 919 | for (auto launcher : launchers) | ||
693 | 920 | { | ||
694 | 921 | nux::Geometry hud_geo = launcher->GetAbsoluteGeometry(); | ||
695 | 922 | |||
696 | 923 | if (launcher->Hidden()) | ||
697 | 924 | continue; | ||
698 | 925 | |||
699 | 926 | if (hud_geo.IsInside(pt)) | ||
700 | 927 | { | ||
701 | 928 | return true; | ||
702 | 929 | } | ||
703 | 930 | } | ||
704 | 931 | |||
705 | 932 | for (nux::Geometry &panel_geo : panel_controller_->GetGeometries ()) | ||
706 | 933 | { | ||
707 | 934 | if (panel_geo.IsInside(pt)) | ||
708 | 935 | { | ||
709 | 936 | return true; | ||
710 | 937 | } | ||
711 | 938 | } | ||
712 | 939 | |||
713 | 940 | return false; | ||
714 | 941 | } | ||
715 | 942 | |||
716 | 916 | void UnityWindow::enterShowDesktop () | 943 | void UnityWindow::enterShowDesktop () |
717 | 917 | { | 944 | { |
718 | 918 | if (!mShowdesktopHandler) | 945 | if (!mShowdesktopHandler) |
719 | @@ -1435,12 +1462,26 @@ | |||
720 | 1435 | if (CompWindow *w = screen->findWindow(ss->getSelectedWindow())) | 1462 | if (CompWindow *w = screen->findWindow(ss->getSelectedWindow())) |
721 | 1436 | skip_other_plugins = UnityWindow::get(w)->handleEvent(event); | 1463 | skip_other_plugins = UnityWindow::get(w)->handleEvent(event); |
722 | 1437 | } | 1464 | } |
724 | 1438 | if (launcher_controller_->IsOverlayOpen()) | 1465 | |
725 | 1466 | |||
726 | 1467 | if (dash_controller_->IsVisible()) | ||
727 | 1439 | { | 1468 | { |
730 | 1440 | int monitor_with_mouse = UScreen::GetDefault()->GetMonitorWithMouse(); | 1469 | nux::Point pt(event->xbutton.x_root, event->xbutton.y_root); |
731 | 1441 | if (overlay_monitor_ != monitor_with_mouse) | 1470 | nux::Geometry dash_geo = dash_controller_->GetInputWindowGeometry(); |
732 | 1471 | |||
733 | 1472 | if (!dash_geo.IsInside(pt) && !DoesPointIntersectUnityGeos(pt)) | ||
734 | 1442 | { | 1473 | { |
735 | 1443 | dash_controller_->HideDash(false); | 1474 | dash_controller_->HideDash(false); |
736 | 1475 | } | ||
737 | 1476 | } | ||
738 | 1477 | |||
739 | 1478 | if (hud_controller_->IsVisible()) | ||
740 | 1479 | { | ||
741 | 1480 | nux::Point pt(event->xbutton.x_root, event->xbutton.y_root); | ||
742 | 1481 | nux::Geometry hud_geo = hud_controller_->GetInputWindowGeometry(); | ||
743 | 1482 | |||
744 | 1483 | if (!hud_geo.IsInside(pt) && !DoesPointIntersectUnityGeos(pt)) | ||
745 | 1484 | { | ||
746 | 1444 | hud_controller_->HideHud(false); | 1485 | hud_controller_->HideHud(false); |
747 | 1445 | } | 1486 | } |
748 | 1446 | } | 1487 | } |
749 | @@ -2683,6 +2724,7 @@ | |||
750 | 2683 | return pos; | 2724 | return pos; |
751 | 2684 | } | 2725 | } |
752 | 2685 | 2726 | ||
753 | 2727 | |||
754 | 2686 | bool UnityWindow::place(CompPoint& pos) | 2728 | bool UnityWindow::place(CompPoint& pos) |
755 | 2687 | { | 2729 | { |
756 | 2688 | bool was_maximized = PluginAdapter::Default ()->MaximizeIfBigEnough(window); | 2730 | bool was_maximized = PluginAdapter::Default ()->MaximizeIfBigEnough(window); |
757 | 2689 | 2731 | ||
758 | === modified file 'plugins/unityshell/src/unityshell.h' | |||
759 | --- plugins/unityshell/src/unityshell.h 2012-09-18 01:41:46 +0000 | |||
760 | +++ plugins/unityshell/src/unityshell.h 2012-09-18 17:41:27 +0000 | |||
761 | @@ -190,6 +190,8 @@ | |||
762 | 190 | switcher::Controller::Ptr switcher_controller(); | 190 | switcher::Controller::Ptr switcher_controller(); |
763 | 191 | launcher::Controller::Ptr launcher_controller(); | 191 | launcher::Controller::Ptr launcher_controller(); |
764 | 192 | 192 | ||
765 | 193 | bool DoesPointIntersectUnityGeos(nux::Point const& pt); | ||
766 | 194 | |||
767 | 193 | protected: | 195 | protected: |
768 | 194 | std::string GetName() const; | 196 | std::string GetName() const; |
769 | 195 | void AddProperties(GVariantBuilder* builder); | 197 | void AddProperties(GVariantBuilder* builder); |
770 | 196 | 198 | ||
771 | === modified file 'tests/autopilot/unity/emulators/dash.py' | |||
772 | --- tests/autopilot/unity/emulators/dash.py 2012-09-13 10:56:42 +0000 | |||
773 | +++ tests/autopilot/unity/emulators/dash.py 2012-09-18 17:41:27 +0000 | |||
774 | @@ -155,6 +155,10 @@ | |||
775 | 155 | active_lens_name = self.view.get_lensbar().active_lens | 155 | active_lens_name = self.view.get_lensbar().active_lens |
776 | 156 | return self.view.get_lensview_by_name(active_lens_name) | 156 | return self.view.get_lensview_by_name(active_lens_name) |
777 | 157 | 157 | ||
778 | 158 | @property | ||
779 | 159 | def geometry(self): | ||
780 | 160 | return (self.view.x, self.view.y, self.view.width, self.view.height) | ||
781 | 161 | |||
782 | 158 | 162 | ||
783 | 159 | class DashController(UnityIntrospectionObject): | 163 | class DashController(UnityIntrospectionObject): |
784 | 160 | """The main dash controller object.""" | 164 | """The main dash controller object.""" |
785 | 161 | 165 | ||
786 | === modified file 'tests/autopilot/unity/tests/test_dash.py' | |||
787 | --- tests/autopilot/unity/tests/test_dash.py 2012-09-18 01:41:46 +0000 | |||
788 | +++ tests/autopilot/unity/tests/test_dash.py 2012-09-18 17:41:27 +0000 | |||
789 | @@ -107,6 +107,39 @@ | |||
790 | 107 | self.dash.reveal_application_lens() | 107 | self.dash.reveal_application_lens() |
791 | 108 | self.assertThat(self.dash.active_lens, Eventually(Equals('applications.lens'))) | 108 | self.assertThat(self.dash.active_lens, Eventually(Equals('applications.lens'))) |
792 | 109 | 109 | ||
793 | 110 | def test_closes_mouse_down_outside(self): | ||
794 | 111 | """Test that a mouse down outside of the dash closes the dash.""" | ||
795 | 112 | |||
796 | 113 | self.dash.ensure_visible() | ||
797 | 114 | current_monitor = self.dash.monitor | ||
798 | 115 | |||
799 | 116 | (x,y,w,h) = self.dash.geometry | ||
800 | 117 | (screen_x,screen_y,screen_w,screen_h) = self.screen_geo.get_monitor_geometry(current_monitor) | ||
801 | 118 | |||
802 | 119 | self.mouse.move(x + w + (screen_w-((screen_x-x)+w))/2, y + h + (screen_h-((screen_y-y)+h))/2) | ||
803 | 120 | self.mouse.click() | ||
804 | 121 | |||
805 | 122 | self.assertThat(self.dash.visible, Eventually(Equals(False))) | ||
806 | 123 | |||
807 | 124 | def test_closes_then_focuses_window_on_mouse_down(self): | ||
808 | 125 | """If 2 windows are open with 1 maximized and the non-maxmized | ||
809 | 126 | focused. Then from the Dash clicking on the maximized window | ||
810 | 127 | must focus that window and close the dash. | ||
811 | 128 | """ | ||
812 | 129 | char_win = self.start_app("Character Map") | ||
813 | 130 | self.keybinding("window/maximize") | ||
814 | 131 | self.start_app("Calculator") | ||
815 | 132 | |||
816 | 133 | self.dash.ensure_visible() | ||
817 | 134 | |||
818 | 135 | #Click bottom right of the screen | ||
819 | 136 | w = self.screen_geo.get_screen_width() | ||
820 | 137 | h = self.screen_geo.get_screen_height() | ||
821 | 138 | self.mouse.move(w,h) | ||
822 | 139 | self.mouse.click() | ||
823 | 140 | |||
824 | 141 | self.assertProperty(char_win, is_active=True) | ||
825 | 142 | |||
826 | 110 | 143 | ||
827 | 111 | class DashSearchInputTests(DashTestCase): | 144 | class DashSearchInputTests(DashTestCase): |
828 | 112 | """Test features involving input to the dash search""" | 145 | """Test features involving input to the dash search""" |
829 | 113 | 146 | ||
830 | === modified file 'tests/autopilot/unity/tests/test_hud.py' | |||
831 | --- tests/autopilot/unity/tests/test_hud.py 2012-09-18 01:41:46 +0000 | |||
832 | +++ tests/autopilot/unity/tests/test_hud.py 2012-09-18 17:41:27 +0000 | |||
833 | @@ -409,6 +409,38 @@ | |||
834 | 409 | self.keyboard.type("HasFocus") | 409 | self.keyboard.type("HasFocus") |
835 | 410 | self.assertThat(self.hud.search_string, Eventually(Equals("HasFocus"))) | 410 | self.assertThat(self.hud.search_string, Eventually(Equals("HasFocus"))) |
836 | 411 | 411 | ||
837 | 412 | def test_closes_mouse_down_outside(self): | ||
838 | 413 | """Test that a mouse down outside of the hud closes the hud.""" | ||
839 | 414 | |||
840 | 415 | self.hud.ensure_visible() | ||
841 | 416 | current_monitor = self.hud.monitor | ||
842 | 417 | |||
843 | 418 | (x,y,w,h) = self.hud.geometry | ||
844 | 419 | (screen_x,screen_y,screen_w,screen_h) = self.screen_geo.get_monitor_geometry(current_monitor) | ||
845 | 420 | |||
846 | 421 | self.mouse.move(x + w + (screen_w-((screen_x-x)+w))/2, y + h + (screen_h-((screen_y-y)+h))/2) | ||
847 | 422 | self.mouse.click() | ||
848 | 423 | |||
849 | 424 | self.assertThat(self.hud.visible, Eventually(Equals(False))) | ||
850 | 425 | |||
851 | 426 | def test_closes_then_focuses_window_on_mouse_down(self): | ||
852 | 427 | """If 2 windows are open with 1 maximized and the non-maxmized | ||
853 | 428 | focused. Then from the Hud clicking on the maximized window | ||
854 | 429 | must focus that window and close the hud. | ||
855 | 430 | """ | ||
856 | 431 | char_win = self.start_app("Character Map") | ||
857 | 432 | self.keybinding("window/maximize") | ||
858 | 433 | self.start_app("Calculator") | ||
859 | 434 | |||
860 | 435 | self.hud.ensure_visible() | ||
861 | 436 | |||
862 | 437 | #Click bottom right of the screen | ||
863 | 438 | w = self.screen_geo.get_screen_width() | ||
864 | 439 | h = self.screen_geo.get_screen_height() | ||
865 | 440 | self.mouse.move(w,h) | ||
866 | 441 | self.mouse.click() | ||
867 | 442 | |||
868 | 443 | self.assertProperty(char_win, is_active=True) | ||
869 | 412 | 444 | ||
870 | 413 | class HudLauncherInteractionsTests(HudTestsBase): | 445 | class HudLauncherInteractionsTests(HudTestsBase): |
871 | 414 | 446 | ||
872 | 415 | 447 | ||
873 | === modified file 'tests/test_hud_controller.cpp' | |||
874 | --- tests/test_hud_controller.cpp 2012-07-04 02:37:23 +0000 | |||
875 | +++ tests/test_hud_controller.cpp 2012-09-18 17:41:27 +0000 | |||
876 | @@ -44,12 +44,13 @@ | |||
877 | 44 | MOCK_METHOD0(SearchFinished, void()); | 44 | MOCK_METHOD0(SearchFinished, void()); |
878 | 45 | MOCK_METHOD4(SetIcon, void(std::string const&, unsigned int tile_size, unsigned int size, unsigned int padding)); | 45 | MOCK_METHOD4(SetIcon, void(std::string const&, unsigned int tile_size, unsigned int size, unsigned int padding)); |
879 | 46 | MOCK_METHOD1(SetQueries, void(hud::Hud::Queries queries)); | 46 | MOCK_METHOD1(SetQueries, void(hud::Hud::Queries queries)); |
881 | 47 | MOCK_METHOD2(SetWindowGeometry, void(nux::Geometry const& absolute_geo, nux::Geometry const& geo)); | 47 | MOCK_METHOD2(SetMonitorOffset, void(int x, int y)); |
882 | 48 | MOCK_METHOD1(ShowEmbeddedIcon, void(bool show)); | 48 | MOCK_METHOD1(ShowEmbeddedIcon, void(bool show)); |
883 | 49 | MOCK_CONST_METHOD0(default_focus, nux::View*()); | 49 | MOCK_CONST_METHOD0(default_focus, nux::View*()); |
884 | 50 | MOCK_CONST_METHOD0(GetName, std::string()); | 50 | MOCK_CONST_METHOD0(GetName, std::string()); |
885 | 51 | MOCK_METHOD1(AddProperties, void(GVariantBuilder*)); | 51 | MOCK_METHOD1(AddProperties, void(GVariantBuilder*)); |
886 | 52 | MOCK_METHOD2(Draw, void(nux::GraphicsEngine&, bool)); | 52 | MOCK_METHOD2(Draw, void(nux::GraphicsEngine&, bool)); |
887 | 53 | MOCK_METHOD0(GetContentGeometry, nux::Geometry()); | ||
888 | 53 | 54 | ||
889 | 54 | }; | 55 | }; |
890 | 55 | 56 | ||
891 | 56 | 57 | ||
892 | === added file 'unity-shared/ResizingBaseWindow.h' | |||
893 | --- unity-shared/ResizingBaseWindow.h 1970-01-01 00:00:00 +0000 | |||
894 | +++ unity-shared/ResizingBaseWindow.h 2012-09-18 17:41:27 +0000 | |||
895 | @@ -0,0 +1,53 @@ | |||
896 | 1 | /* | ||
897 | 2 | * Copyright (C) 2012 Canonical Ltd | ||
898 | 3 | * | ||
899 | 4 | * This program is free software: you can redistribute it and/or modify | ||
900 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
901 | 6 | * published by the Free Software Foundation. | ||
902 | 7 | * | ||
903 | 8 | * This program is distributed in the hope that it will be useful, | ||
904 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
905 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
906 | 11 | * GNU General Public License for more details. | ||
907 | 12 | * | ||
908 | 13 | * You should have received a copy of the GNU General Public License | ||
909 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
910 | 15 | * | ||
911 | 16 | * Authored by: Nick Dedekind <nick.dedekind@canonical.com> | ||
912 | 17 | */ | ||
913 | 18 | |||
914 | 19 | #ifndef RESIZEDINPUTWINDOW_BASEWINDOW_H | ||
915 | 20 | #define RESIZEDINPUTWINDOW_BASEWINDOW_H | ||
916 | 21 | |||
917 | 22 | #include <Nux/BaseWindow.h> | ||
918 | 23 | |||
919 | 24 | namespace unity | ||
920 | 25 | { | ||
921 | 26 | |||
922 | 27 | class ResizingBaseWindow : public nux::BaseWindow | ||
923 | 28 | { | ||
924 | 29 | public: | ||
925 | 30 | ResizingBaseWindow(const char *WindowName, std::function<nux::Geometry (nux::Geometry const&)> geo_func) | ||
926 | 31 | : BaseWindow(WindowName, NUX_TRACKER_LOCATION) | ||
927 | 32 | { | ||
928 | 33 | geo_func_ = geo_func; | ||
929 | 34 | } | ||
930 | 35 | |||
931 | 36 | void UpdateInputWindowGeometry() | ||
932 | 37 | { | ||
933 | 38 | if (m_input_window && m_input_window_enabled) | ||
934 | 39 | m_input_window->SetGeometry(geo_func_(GetGeometry())); | ||
935 | 40 | } | ||
936 | 41 | |||
937 | 42 | virtual void SetGeometry(const nux::Geometry &geo) | ||
938 | 43 | { | ||
939 | 44 | Area::SetGeometry(geo); | ||
940 | 45 | UpdateInputWindowGeometry(); | ||
941 | 46 | } | ||
942 | 47 | |||
943 | 48 | private: | ||
944 | 49 | std::function<nux::Geometry (nux::Geometry const&)> geo_func_; | ||
945 | 50 | }; | ||
946 | 51 | |||
947 | 52 | } | ||
948 | 53 | #endif // RESIZEDINPUTWINDOW_BASEWINDOW_H |
This is a bit of a cheeky fix.
The problem causing the events to be stolen is that the base window of the dash/hud takes the monitor geometry as it's own. The XInputWindow which is responsible for receiving the XEvents has the same geometry.
This branch side-steps this issue by resizing the XInputWindow to match the actual size of the dash/hud, so if a user clicks outside the dash, it doesnt receive the click.