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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 compositor()->SetRootLayer(layer()); | 173 compositor()->SetRootLayer(layer()); |
174 SetBounds( | 174 SetBounds( |
175 ui::ConvertRectToDIP(layer(), gfx::Rect(host_->GetBounds().size()))); | 175 ui::ConvertRectToDIP(layer(), gfx::Rect(host_->GetBounds().size()))); |
176 Show(); | 176 Show(); |
177 } | 177 } |
178 | 178 |
179 void RootWindow::ShowRootWindow() { | 179 void RootWindow::ShowRootWindow() { |
180 host_->Show(); | 180 host_->Show(); |
181 } | 181 } |
182 | 182 |
| 183 void RootWindow::HideRootWindow() { |
| 184 host_->Hide(); |
| 185 } |
| 186 |
183 RootWindowHostDelegate* RootWindow::AsRootWindowHostDelegate() { | 187 RootWindowHostDelegate* RootWindow::AsRootWindowHostDelegate() { |
184 return this; | 188 return this; |
185 } | 189 } |
186 | 190 |
187 void RootWindow::SetHostSize(const gfx::Size& size_in_pixel) { | 191 void RootWindow::SetHostSize(const gfx::Size& size_in_pixel) { |
188 DispatchHeldMouseMove(); | 192 DispatchHeldMouseMove(); |
189 gfx::Rect bounds = host_->GetBounds(); | 193 gfx::Rect bounds = host_->GetBounds(); |
190 bounds.set_size(size_in_pixel); | 194 bounds.set_size(size_in_pixel); |
191 host_->SetBounds(bounds); | 195 host_->SetBounds(bounds); |
192 | 196 |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 //////////////////////////////////////////////////////////////////////////////// | 519 //////////////////////////////////////////////////////////////////////////////// |
516 // RootWindow, overridden from aura::client::CaptureDelegate: | 520 // RootWindow, overridden from aura::client::CaptureDelegate: |
517 | 521 |
518 void RootWindow::UpdateCapture(Window* old_capture, | 522 void RootWindow::UpdateCapture(Window* old_capture, |
519 Window* new_capture) { | 523 Window* new_capture) { |
520 if (old_capture && old_capture->GetRootWindow() == this && | 524 if (old_capture && old_capture->GetRootWindow() == this && |
521 old_capture->delegate()) { | 525 old_capture->delegate()) { |
522 // Send a capture changed event with bogus location data. | 526 // Send a capture changed event with bogus location data. |
523 ui::MouseEvent event(ui::ET_MOUSE_CAPTURE_CHANGED, gfx::Point(), | 527 ui::MouseEvent event(ui::ET_MOUSE_CAPTURE_CHANGED, gfx::Point(), |
524 gfx::Point(), 0); | 528 gfx::Point(), 0); |
| 529 |
525 ProcessMouseEvent(old_capture, &event); | 530 ProcessMouseEvent(old_capture, &event); |
526 | 531 |
527 old_capture->delegate()->OnCaptureLost(); | 532 old_capture->delegate()->OnCaptureLost(); |
528 } | 533 } |
529 | 534 |
530 // Reset the mouse_moved_handler_ if the mouse_moved_handler_ belongs | 535 // Reset the mouse_moved_handler_ if the mouse_moved_handler_ belongs |
531 // to another root window when losing the capture. | 536 // to another root window when losing the capture. |
532 if (mouse_moved_handler_ && old_capture && | 537 if (mouse_moved_handler_ && old_capture && |
533 old_capture->Contains(mouse_moved_handler_) && | 538 old_capture->Contains(mouse_moved_handler_) && |
534 old_capture->GetRootWindow() != this) { | 539 old_capture->GetRootWindow() != this) { |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 void RootWindow::OnHostLostCapture() { | 913 void RootWindow::OnHostLostCapture() { |
909 Window* capture_window = client::GetCaptureWindow(this); | 914 Window* capture_window = client::GetCaptureWindow(this); |
910 if (capture_window && capture_window->GetRootWindow() == this) | 915 if (capture_window && capture_window->GetRootWindow() == this) |
911 capture_window->ReleaseCapture(); | 916 capture_window->ReleaseCapture(); |
912 } | 917 } |
913 | 918 |
914 void RootWindow::OnHostPaint() { | 919 void RootWindow::OnHostPaint() { |
915 Draw(); | 920 Draw(); |
916 } | 921 } |
917 | 922 |
| 923 void RootWindow::OnHostMoved(const gfx::Point& origin) { |
| 924 FOR_EACH_OBSERVER(RootWindowObserver, observers_, |
| 925 OnRootWindowMoved(this, origin)); |
| 926 } |
| 927 |
918 void RootWindow::OnHostResized(const gfx::Size& size) { | 928 void RootWindow::OnHostResized(const gfx::Size& size) { |
919 DispatchHeldMouseMove(); | 929 DispatchHeldMouseMove(); |
920 // The compositor should have the same size as the native root window host. | 930 // The compositor should have the same size as the native root window host. |
921 // Get the latest scale from display because it might have been changed. | 931 // Get the latest scale from display because it might have been changed. |
922 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(this), | 932 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(this), |
923 size); | 933 size); |
924 gfx::Size old(bounds().size()); | 934 gfx::Size old(bounds().size()); |
925 // The layer, and all the observers should be notified of the | 935 // The layer, and all the observers should be notified of the |
926 // transformed size of the root window. | 936 // transformed size of the root window. |
927 gfx::Rect bounds(ui::ConvertSizeToDIP(layer(), size)); | 937 gfx::Rect bounds(ui::ConvertSizeToDIP(layer(), size)); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 transform.ConcatScale(scale, scale); | 1036 transform.ConcatScale(scale, scale); |
1027 transform.TransformPoint(point); | 1037 transform.TransformPoint(point); |
1028 gfx::Point orig_mouse_location = point.AsPoint(); | 1038 gfx::Point orig_mouse_location = point.AsPoint(); |
1029 | 1039 |
1030 // TODO(derat|oshima): Don't use mouse_button_flags_ as it's | 1040 // TODO(derat|oshima): Don't use mouse_button_flags_ as it's |
1031 // currently broken. See/ crbug.com/107931. | 1041 // currently broken. See/ crbug.com/107931. |
1032 ui::MouseEvent event(ui::ET_MOUSE_MOVED, | 1042 ui::MouseEvent event(ui::ET_MOUSE_MOVED, |
1033 orig_mouse_location, | 1043 orig_mouse_location, |
1034 orig_mouse_location, | 1044 orig_mouse_location, |
1035 ui::EF_IS_SYNTHESIZED); | 1045 ui::EF_IS_SYNTHESIZED); |
| 1046 event.set_system_location(Env::GetInstance()->last_mouse_location()); |
1036 OnHostMouseEvent(&event); | 1047 OnHostMouseEvent(&event); |
1037 #endif | 1048 #endif |
1038 } | 1049 } |
1039 | 1050 |
1040 void RootWindow::UnlockCompositor() { | 1051 void RootWindow::UnlockCompositor() { |
1041 DCHECK(compositor_lock_); | 1052 DCHECK(compositor_lock_); |
1042 compositor_lock_ = NULL; | 1053 compositor_lock_ = NULL; |
1043 if (draw_on_compositor_unlock_) { | 1054 if (draw_on_compositor_unlock_) { |
1044 draw_on_compositor_unlock_ = false; | 1055 draw_on_compositor_unlock_ = false; |
1045 ScheduleDraw(); | 1056 ScheduleDraw(); |
1046 } | 1057 } |
1047 } | 1058 } |
1048 | 1059 |
1049 } // namespace aura | 1060 } // namespace aura |
OLD | NEW |