OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/aura/root_window.h" | 5 #include "ui/aura/root_window.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 root_window_ = NULL; | 101 root_window_ = NULL; |
102 } | 102 } |
103 | 103 |
104 bool RootWindow::hide_host_cursor_ = false; | 104 bool RootWindow::hide_host_cursor_ = false; |
105 | 105 |
106 //////////////////////////////////////////////////////////////////////////////// | 106 //////////////////////////////////////////////////////////////////////////////// |
107 // RootWindow, public: | 107 // RootWindow, public: |
108 | 108 |
109 RootWindow::RootWindow(const gfx::Rect& initial_bounds) | 109 RootWindow::RootWindow(const gfx::Rect& initial_bounds) |
110 : Window(NULL), | 110 : Window(NULL), |
111 host_(RootWindowHost::Create(initial_bounds)), | 111 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 112 host_(RootWindowHost::Create(this, initial_bounds))), |
112 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)), | 113 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)), |
113 ALLOW_THIS_IN_INITIALIZER_LIST(event_factory_(this)), | 114 ALLOW_THIS_IN_INITIALIZER_LIST(event_factory_(this)), |
114 mouse_button_flags_(0), | 115 mouse_button_flags_(0), |
115 touch_ids_down_(0), | 116 touch_ids_down_(0), |
116 last_cursor_(ui::kCursorNull), | 117 last_cursor_(ui::kCursorNull), |
117 mouse_pressed_handler_(NULL), | 118 mouse_pressed_handler_(NULL), |
118 mouse_moved_handler_(NULL), | 119 mouse_moved_handler_(NULL), |
119 ALLOW_THIS_IN_INITIALIZER_LIST( | 120 ALLOW_THIS_IN_INITIALIZER_LIST( |
120 gesture_recognizer_(ui::GestureRecognizer::Create(this))), | 121 gesture_recognizer_(ui::GestureRecognizer::Create(this))), |
121 synthesize_mouse_move_(false), | 122 synthesize_mouse_move_(false), |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 Window::Init(ui::LAYER_NOT_DRAWN); | 166 Window::Init(ui::LAYER_NOT_DRAWN); |
166 | 167 |
167 gfx::Point point; | 168 gfx::Point point; |
168 if (host_->QueryMouseLocation(&point)) | 169 if (host_->QueryMouseLocation(&point)) |
169 SetLastMouseLocation(this, ui::ConvertPointToDIP(layer(), point)); | 170 SetLastMouseLocation(this, ui::ConvertPointToDIP(layer(), point)); |
170 | 171 |
171 compositor()->SetRootLayer(layer()); | 172 compositor()->SetRootLayer(layer()); |
172 SetBounds( | 173 SetBounds( |
173 ui::ConvertRectToDIP(layer(), gfx::Rect(host_->GetBounds().size()))); | 174 ui::ConvertRectToDIP(layer(), gfx::Rect(host_->GetBounds().size()))); |
174 Show(); | 175 Show(); |
175 host_->SetRootWindow(this); | |
176 } | 176 } |
177 | 177 |
178 void RootWindow::ShowRootWindow() { | 178 void RootWindow::ShowRootWindow() { |
179 host_->Show(); | 179 host_->Show(); |
180 } | 180 } |
181 | 181 |
| 182 RootWindowHostDelegate* RootWindow::AsRootWindowHostDelegate() { |
| 183 return this; |
| 184 } |
| 185 |
182 void RootWindow::SetHostSize(const gfx::Size& size_in_pixel) { | 186 void RootWindow::SetHostSize(const gfx::Size& size_in_pixel) { |
183 DispatchHeldMouseMove(); | 187 DispatchHeldMouseMove(); |
184 gfx::Rect bounds = host_->GetBounds(); | 188 gfx::Rect bounds = host_->GetBounds(); |
185 bounds.set_size(size_in_pixel); | 189 bounds.set_size(size_in_pixel); |
186 host_->SetBounds(bounds); | 190 host_->SetBounds(bounds); |
187 | 191 |
188 // Requery the location to constrain it within the new root window size. | 192 // Requery the location to constrain it within the new root window size. |
189 gfx::Point point; | 193 gfx::Point point; |
190 if (host_->QueryMouseLocation(&point)) | 194 if (host_->QueryMouseLocation(&point)) |
191 SetLastMouseLocation(this, ui::ConvertPointToDIP(layer(), point)); | 195 SetLastMouseLocation(this, ui::ConvertPointToDIP(layer(), point)); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 TRACE_EVENT_ASYNC_BEGIN0("ui", "RootWindow::Draw", | 259 TRACE_EVENT_ASYNC_BEGIN0("ui", "RootWindow::Draw", |
256 compositor_->last_started_frame() + 1); | 260 compositor_->last_started_frame() + 1); |
257 | 261 |
258 compositor_->Draw(false); | 262 compositor_->Draw(false); |
259 } | 263 } |
260 | 264 |
261 void RootWindow::ScheduleFullDraw() { | 265 void RootWindow::ScheduleFullDraw() { |
262 compositor_->ScheduleFullDraw(); | 266 compositor_->ScheduleFullDraw(); |
263 } | 267 } |
264 | 268 |
265 bool RootWindow::DispatchMouseEvent(MouseEvent* event) { | |
266 if (event->type() == ui::ET_MOUSE_DRAGGED || | |
267 (event->flags() & ui::EF_IS_SYNTHESIZED)) { | |
268 if (mouse_move_hold_count_) { | |
269 held_mouse_move_.reset(new MouseEvent(*event, NULL, NULL)); | |
270 return true; | |
271 } else { | |
272 // We may have a held event for a period between the time | |
273 // mouse_move_hold_count_ fell to 0 and the DispatchHeldMouseMove | |
274 // executes. Since we're going to dispatch the new event directly below, | |
275 // we can reset the old one. | |
276 held_mouse_move_.reset(); | |
277 } | |
278 } | |
279 DispatchHeldMouseMove(); | |
280 return DispatchMouseEventImpl(event); | |
281 } | |
282 | |
283 bool RootWindow::DispatchKeyEvent(KeyEvent* event) { | |
284 DispatchHeldMouseMove(); | |
285 if (event->key_code() == ui::VKEY_UNKNOWN) | |
286 return false; | |
287 client::EventClient* client = client::GetEventClient(GetRootWindow()); | |
288 Window* focused_window = focus_manager_->GetFocusedWindow(); | |
289 if (client && !client->CanProcessEventsWithinSubtree(focused_window)) { | |
290 GetFocusManager()->SetFocusedWindow(NULL, NULL); | |
291 return false; | |
292 } | |
293 return ProcessKeyEvent(focused_window, event); | |
294 } | |
295 | |
296 bool RootWindow::DispatchScrollEvent(ScrollEvent* event) { | |
297 DispatchHeldMouseMove(); | |
298 float scale = ui::GetDeviceScaleFactor(layer()); | |
299 ui::Transform transform = layer()->transform(); | |
300 transform.ConcatScale(scale, scale); | |
301 event->UpdateForRootTransform(transform); | |
302 | |
303 SetLastMouseLocation(this, event->location()); | |
304 synthesize_mouse_move_ = false; | |
305 | |
306 Window* target = mouse_pressed_handler_ ? | |
307 mouse_pressed_handler_ : client::GetCaptureWindow(this); | |
308 if (!target) | |
309 target = GetEventHandlerForPoint(event->location()); | |
310 | |
311 if (target && target->delegate()) { | |
312 int flags = event->flags(); | |
313 gfx::Point location_in_window = event->location(); | |
314 Window::ConvertPointToWindow(this, target, &location_in_window); | |
315 if (IsNonClientLocation(target, location_in_window)) | |
316 flags |= ui::EF_IS_NON_CLIENT; | |
317 ScrollEvent translated_event(*event, this, target, event->type(), flags); | |
318 return ProcessMouseEvent(target, &translated_event); | |
319 } | |
320 return false; | |
321 } | |
322 | |
323 bool RootWindow::DispatchTouchEvent(TouchEvent* event) { | |
324 DispatchHeldMouseMove(); | |
325 switch (event->type()) { | |
326 case ui::ET_TOUCH_PRESSED: | |
327 touch_ids_down_ |= (1 << event->touch_id()); | |
328 Env::GetInstance()->set_touch_down(touch_ids_down_ != 0); | |
329 break; | |
330 | |
331 // Don't handle ET_TOUCH_CANCELLED since we always get a ET_TOUCH_RELEASED. | |
332 case ui::ET_TOUCH_RELEASED: | |
333 touch_ids_down_ = (touch_ids_down_ | (1 << event->touch_id())) ^ | |
334 (1 << event->touch_id()); | |
335 Env::GetInstance()->set_touch_down(touch_ids_down_ != 0); | |
336 break; | |
337 | |
338 default: | |
339 break; | |
340 } | |
341 float scale = ui::GetDeviceScaleFactor(layer()); | |
342 ui::Transform transform = layer()->transform(); | |
343 transform.ConcatScale(scale, scale); | |
344 event->UpdateForRootTransform(transform); | |
345 bool handled = false; | |
346 ui::TouchStatus status = ui::TOUCH_STATUS_UNKNOWN; | |
347 Window* target = client::GetCaptureWindow(this); | |
348 if (!target) { | |
349 target = ConsumerToWindow( | |
350 gesture_recognizer_->GetTouchLockedTarget(event)); | |
351 if (!target) { | |
352 target = ConsumerToWindow( | |
353 gesture_recognizer_->GetTargetForLocation(event->GetLocation())); | |
354 } | |
355 } | |
356 | |
357 if (!target && !bounds().Contains(event->location())) { | |
358 // If the initial touch is outside the root window, target the root. | |
359 target = this; | |
360 } else { | |
361 // We only come here when the first contact was within the root window. | |
362 if (!target) { | |
363 target = GetEventHandlerForPoint(event->location()); | |
364 if (!target) | |
365 return false; | |
366 } | |
367 | |
368 TouchEvent translated_event(*event, this, target); | |
369 status = ProcessTouchEvent(target, &translated_event); | |
370 handled = status != ui::TOUCH_STATUS_UNKNOWN; | |
371 | |
372 if (status == ui::TOUCH_STATUS_QUEUED || | |
373 status == ui::TOUCH_STATUS_QUEUED_END) | |
374 gesture_recognizer_->QueueTouchEventForGesture(target, *event); | |
375 } | |
376 | |
377 // Get the list of GestureEvents from GestureRecognizer. | |
378 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; | |
379 gestures.reset(gesture_recognizer_->ProcessTouchEventForGesture( | |
380 *event, status, target)); | |
381 | |
382 return ProcessGestures(gestures.get()) ? true : handled; | |
383 } | |
384 | |
385 bool RootWindow::DispatchGestureEvent(GestureEvent* event) { | 269 bool RootWindow::DispatchGestureEvent(GestureEvent* event) { |
386 DispatchHeldMouseMove(); | 270 DispatchHeldMouseMove(); |
387 | 271 |
388 Window* target = client::GetCaptureWindow(this); | 272 Window* target = client::GetCaptureWindow(this); |
389 if (!target) { | 273 if (!target) { |
390 target = ConsumerToWindow( | 274 target = ConsumerToWindow( |
391 gesture_recognizer_->GetTargetForGestureEvent(event)); | 275 gesture_recognizer_->GetTargetForGestureEvent(event)); |
392 if (!target) | 276 if (!target) |
393 return false; | 277 return false; |
394 } | 278 } |
395 | 279 |
396 if (target) { | 280 if (target) { |
397 GestureEvent translated_event(*event, this, target); | 281 GestureEvent translated_event(*event, this, target); |
398 ui::GestureStatus status = ProcessGestureEvent(target, &translated_event); | 282 ui::GestureStatus status = ProcessGestureEvent(target, &translated_event); |
399 return status != ui::GESTURE_STATUS_UNKNOWN; | 283 return status != ui::GESTURE_STATUS_UNKNOWN; |
400 } | 284 } |
401 | 285 |
402 return false; | 286 return false; |
403 } | 287 } |
404 | 288 |
405 void RootWindow::OnHostResized(const gfx::Size& size_in_pixel) { | |
406 DispatchHeldMouseMove(); | |
407 // The compositor should have the same size as the native root window host. | |
408 // Get the latest scale from display because it might have been changed. | |
409 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(this), | |
410 size_in_pixel); | |
411 gfx::Size old(bounds().size()); | |
412 // The layer, and all the observers should be notified of the | |
413 // transformed size of the root window. | |
414 gfx::Rect bounds(ui::ConvertSizeToDIP(layer(), size_in_pixel)); | |
415 layer()->transform().TransformRect(&bounds); | |
416 SetBounds(bounds); | |
417 FOR_EACH_OBSERVER(RootWindowObserver, observers_, | |
418 OnRootWindowResized(this, old)); | |
419 } | |
420 | |
421 void RootWindow::OnWindowDestroying(Window* window) { | 289 void RootWindow::OnWindowDestroying(Window* window) { |
422 OnWindowHidden(window, true); | 290 OnWindowHidden(window, true); |
423 | 291 |
424 if (window->IsVisible() && | 292 if (window->IsVisible() && |
425 window->ContainsPointInRoot(GetLastMouseLocationInRoot())) { | 293 window->ContainsPointInRoot(GetLastMouseLocationInRoot())) { |
426 PostMouseMoveEventAfterWindowChange(); | 294 PostMouseMoveEventAfterWindowChange(); |
427 } | 295 } |
428 } | 296 } |
429 | 297 |
430 void RootWindow::OnWindowBoundsChanged(Window* window, | 298 void RootWindow::OnWindowBoundsChanged(Window* window, |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 if (attached->IsVisible() && | 739 if (attached->IsVisible() && |
872 attached->ContainsPointInRoot(GetLastMouseLocationInRoot())) | 740 attached->ContainsPointInRoot(GetLastMouseLocationInRoot())) |
873 PostMouseMoveEventAfterWindowChange(); | 741 PostMouseMoveEventAfterWindowChange(); |
874 } | 742 } |
875 | 743 |
876 bool RootWindow::DispatchLongPressGestureEvent(ui::GestureEvent* event) { | 744 bool RootWindow::DispatchLongPressGestureEvent(ui::GestureEvent* event) { |
877 return DispatchGestureEvent(static_cast<GestureEvent*>(event)); | 745 return DispatchGestureEvent(static_cast<GestureEvent*>(event)); |
878 } | 746 } |
879 | 747 |
880 bool RootWindow::DispatchCancelTouchEvent(ui::TouchEvent* event) { | 748 bool RootWindow::DispatchCancelTouchEvent(ui::TouchEvent* event) { |
881 return DispatchTouchEvent(static_cast<TouchEvent*>(event)); | 749 return OnHostTouchEvent(static_cast<TouchEvent*>(event)); |
882 } | 750 } |
883 | 751 |
884 ui::GestureEvent* RootWindow::CreateGestureEvent( | 752 ui::GestureEvent* RootWindow::CreateGestureEvent( |
885 const ui::GestureEventDetails& details, | 753 const ui::GestureEventDetails& details, |
886 const gfx::Point& location, | 754 const gfx::Point& location, |
887 int flags, | 755 int flags, |
888 base::Time time, | 756 base::Time time, |
889 unsigned int touch_id_bitfield) { | 757 unsigned int touch_id_bitfield) { |
890 return new GestureEvent(details.type(), location.x(), location.y(), | 758 return new GestureEvent(details.type(), location.x(), location.y(), |
891 flags, time, details, | 759 flags, time, details, |
(...skipping 13 matching lines...) Expand all Loading... |
905 } | 773 } |
906 | 774 |
907 void RootWindow::OnLayerAnimationScheduled( | 775 void RootWindow::OnLayerAnimationScheduled( |
908 ui::LayerAnimationSequence* animation) { | 776 ui::LayerAnimationSequence* animation) { |
909 } | 777 } |
910 | 778 |
911 void RootWindow::OnLayerAnimationAborted( | 779 void RootWindow::OnLayerAnimationAborted( |
912 ui::LayerAnimationSequence* animation) { | 780 ui::LayerAnimationSequence* animation) { |
913 } | 781 } |
914 | 782 |
| 783 //////////////////////////////////////////////////////////////////////////////// |
| 784 // RootWindow, RootWindowHostDelegate implementation: |
| 785 |
| 786 bool RootWindow::OnHostKeyEvent(KeyEvent* event) { |
| 787 DispatchHeldMouseMove(); |
| 788 if (event->key_code() == ui::VKEY_UNKNOWN) |
| 789 return false; |
| 790 client::EventClient* client = client::GetEventClient(GetRootWindow()); |
| 791 Window* focused_window = focus_manager_->GetFocusedWindow(); |
| 792 if (client && !client->CanProcessEventsWithinSubtree(focused_window)) { |
| 793 GetFocusManager()->SetFocusedWindow(NULL, NULL); |
| 794 return false; |
| 795 } |
| 796 return ProcessKeyEvent(focused_window, event); |
| 797 } |
| 798 |
| 799 bool RootWindow::OnHostMouseEvent(MouseEvent* event) { |
| 800 if (event->type() == ui::ET_MOUSE_DRAGGED || |
| 801 (event->flags() & ui::EF_IS_SYNTHESIZED)) { |
| 802 if (mouse_move_hold_count_) { |
| 803 held_mouse_move_.reset(new MouseEvent(*event, NULL, NULL)); |
| 804 return true; |
| 805 } else { |
| 806 // We may have a held event for a period between the time |
| 807 // mouse_move_hold_count_ fell to 0 and the DispatchHeldMouseMove |
| 808 // executes. Since we're going to dispatch the new event directly below, |
| 809 // we can reset the old one. |
| 810 held_mouse_move_.reset(); |
| 811 } |
| 812 } |
| 813 DispatchHeldMouseMove(); |
| 814 return DispatchMouseEventImpl(event); |
| 815 } |
| 816 |
| 817 bool RootWindow::OnHostScrollEvent(ScrollEvent* event) { |
| 818 DispatchHeldMouseMove(); |
| 819 float scale = ui::GetDeviceScaleFactor(layer()); |
| 820 ui::Transform transform = layer()->transform(); |
| 821 transform.ConcatScale(scale, scale); |
| 822 event->UpdateForRootTransform(transform); |
| 823 |
| 824 SetLastMouseLocation(this, event->location()); |
| 825 synthesize_mouse_move_ = false; |
| 826 |
| 827 Window* target = mouse_pressed_handler_ ? |
| 828 mouse_pressed_handler_ : client::GetCaptureWindow(this); |
| 829 if (!target) |
| 830 target = GetEventHandlerForPoint(event->location()); |
| 831 |
| 832 if (target && target->delegate()) { |
| 833 int flags = event->flags(); |
| 834 gfx::Point location_in_window = event->location(); |
| 835 Window::ConvertPointToWindow(this, target, &location_in_window); |
| 836 if (IsNonClientLocation(target, location_in_window)) |
| 837 flags |= ui::EF_IS_NON_CLIENT; |
| 838 ScrollEvent translated_event(*event, this, target, event->type(), flags); |
| 839 return ProcessMouseEvent(target, &translated_event); |
| 840 } |
| 841 return false; |
| 842 } |
| 843 |
| 844 bool RootWindow::OnHostTouchEvent(TouchEvent* event) { |
| 845 DispatchHeldMouseMove(); |
| 846 switch (event->type()) { |
| 847 case ui::ET_TOUCH_PRESSED: |
| 848 touch_ids_down_ |= (1 << event->touch_id()); |
| 849 Env::GetInstance()->set_touch_down(touch_ids_down_ != 0); |
| 850 break; |
| 851 |
| 852 // Don't handle ET_TOUCH_CANCELLED since we always get a ET_TOUCH_RELEASED. |
| 853 case ui::ET_TOUCH_RELEASED: |
| 854 touch_ids_down_ = (touch_ids_down_ | (1 << event->touch_id())) ^ |
| 855 (1 << event->touch_id()); |
| 856 Env::GetInstance()->set_touch_down(touch_ids_down_ != 0); |
| 857 break; |
| 858 |
| 859 default: |
| 860 break; |
| 861 } |
| 862 float scale = ui::GetDeviceScaleFactor(layer()); |
| 863 ui::Transform transform = layer()->transform(); |
| 864 transform.ConcatScale(scale, scale); |
| 865 event->UpdateForRootTransform(transform); |
| 866 bool handled = false; |
| 867 ui::TouchStatus status = ui::TOUCH_STATUS_UNKNOWN; |
| 868 Window* target = client::GetCaptureWindow(this); |
| 869 if (!target) { |
| 870 target = ConsumerToWindow( |
| 871 gesture_recognizer_->GetTouchLockedTarget(event)); |
| 872 if (!target) { |
| 873 target = ConsumerToWindow( |
| 874 gesture_recognizer_->GetTargetForLocation(event->GetLocation())); |
| 875 } |
| 876 } |
| 877 |
| 878 if (!target && !bounds().Contains(event->location())) { |
| 879 // If the initial touch is outside the root window, target the root. |
| 880 target = this; |
| 881 } else { |
| 882 // We only come here when the first contact was within the root window. |
| 883 if (!target) { |
| 884 target = GetEventHandlerForPoint(event->location()); |
| 885 if (!target) |
| 886 return false; |
| 887 } |
| 888 |
| 889 TouchEvent translated_event(*event, this, target); |
| 890 status = ProcessTouchEvent(target, &translated_event); |
| 891 handled = status != ui::TOUCH_STATUS_UNKNOWN; |
| 892 |
| 893 if (status == ui::TOUCH_STATUS_QUEUED || |
| 894 status == ui::TOUCH_STATUS_QUEUED_END) |
| 895 gesture_recognizer_->QueueTouchEventForGesture(target, *event); |
| 896 } |
| 897 |
| 898 // Get the list of GestureEvents from GestureRecognizer. |
| 899 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; |
| 900 gestures.reset(gesture_recognizer_->ProcessTouchEventForGesture( |
| 901 *event, status, target)); |
| 902 |
| 903 return ProcessGestures(gestures.get()) ? true : handled; |
| 904 } |
| 905 |
| 906 void RootWindow::OnHostLostCapture() { |
| 907 Window* capture_window = client::GetCaptureWindow(this); |
| 908 if (capture_window && capture_window->GetRootWindow() == this) |
| 909 capture_window->ReleaseCapture(); |
| 910 } |
| 911 |
| 912 void RootWindow::OnHostPaint() { |
| 913 Draw(); |
| 914 } |
| 915 |
| 916 void RootWindow::OnHostResized(const gfx::Size& size) { |
| 917 DispatchHeldMouseMove(); |
| 918 // The compositor should have the same size as the native root window host. |
| 919 // Get the latest scale from display because it might have been changed. |
| 920 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(this), |
| 921 size); |
| 922 gfx::Size old(bounds().size()); |
| 923 // The layer, and all the observers should be notified of the |
| 924 // transformed size of the root window. |
| 925 gfx::Rect bounds(ui::ConvertSizeToDIP(layer(), size)); |
| 926 layer()->transform().TransformRect(&bounds); |
| 927 SetBounds(bounds); |
| 928 FOR_EACH_OBSERVER(RootWindowObserver, observers_, |
| 929 OnRootWindowResized(this, old)); |
| 930 } |
| 931 |
| 932 float RootWindow::GetDeviceScaleFactor() { |
| 933 return compositor()->device_scale_factor(); |
| 934 } |
| 935 |
| 936 RootWindow* RootWindow::AsRootWindow() { |
| 937 return this; |
| 938 } |
| 939 |
| 940 //////////////////////////////////////////////////////////////////////////////// |
| 941 // RootWindow, private: |
| 942 |
915 bool RootWindow::DispatchMouseEventImpl(MouseEvent* event) { | 943 bool RootWindow::DispatchMouseEventImpl(MouseEvent* event) { |
916 float scale = ui::GetDeviceScaleFactor(layer()); | 944 float scale = ui::GetDeviceScaleFactor(layer()); |
917 ui::Transform transform = layer()->transform(); | 945 ui::Transform transform = layer()->transform(); |
918 transform.ConcatScale(scale, scale); | 946 transform.ConcatScale(scale, scale); |
919 event->UpdateForRootTransform(transform); | 947 event->UpdateForRootTransform(transform); |
920 Window* target = mouse_pressed_handler_ ? | 948 Window* target = mouse_pressed_handler_ ? |
921 mouse_pressed_handler_ : client::GetCaptureWindow(this); | 949 mouse_pressed_handler_ : client::GetCaptureWindow(this); |
922 if (!target) | 950 if (!target) |
923 target = GetEventHandlerForPoint(event->location()); | 951 target = GetEventHandlerForPoint(event->location()); |
924 return DispatchMouseEventToTarget(event, target); | 952 return DispatchMouseEventToTarget(event, target); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 transform.ConcatScale(scale, scale); | 1022 transform.ConcatScale(scale, scale); |
995 transform.TransformPoint(point); | 1023 transform.TransformPoint(point); |
996 gfx::Point orig_mouse_location = point.AsPoint(); | 1024 gfx::Point orig_mouse_location = point.AsPoint(); |
997 | 1025 |
998 // TODO(derat|oshima): Don't use mouse_button_flags_ as it's | 1026 // TODO(derat|oshima): Don't use mouse_button_flags_ as it's |
999 // currently broken. See/ crbug.com/107931. | 1027 // currently broken. See/ crbug.com/107931. |
1000 MouseEvent event(ui::ET_MOUSE_MOVED, | 1028 MouseEvent event(ui::ET_MOUSE_MOVED, |
1001 orig_mouse_location, | 1029 orig_mouse_location, |
1002 orig_mouse_location, | 1030 orig_mouse_location, |
1003 ui::EF_IS_SYNTHESIZED); | 1031 ui::EF_IS_SYNTHESIZED); |
1004 DispatchMouseEvent(&event); | 1032 OnHostMouseEvent(&event); |
1005 #endif | 1033 #endif |
1006 } | 1034 } |
1007 | 1035 |
1008 void RootWindow::UnlockCompositor() { | 1036 void RootWindow::UnlockCompositor() { |
1009 DCHECK(compositor_lock_); | 1037 DCHECK(compositor_lock_); |
1010 compositor_lock_ = NULL; | 1038 compositor_lock_ = NULL; |
1011 if (draw_on_compositor_unlock_) { | 1039 if (draw_on_compositor_unlock_) { |
1012 draw_on_compositor_unlock_ = false; | 1040 draw_on_compositor_unlock_ = false; |
1013 ScheduleDraw(); | 1041 ScheduleDraw(); |
1014 } | 1042 } |
1015 } | 1043 } |
1016 | 1044 |
1017 } // namespace aura | 1045 } // namespace aura |
OLD | NEW |