Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/views/mus/native_widget_mus.h" | 5 #include "ui/views/mus/native_widget_mus.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "components/bitmap_uploader/bitmap_uploader.h" | 11 #include "components/bitmap_uploader/bitmap_uploader.h" |
| 12 #include "components/mus/public/cpp/property_type_converters.h" | 12 #include "components/mus/public/cpp/property_type_converters.h" |
| 13 #include "components/mus/public/cpp/window.h" | 13 #include "components/mus/public/cpp/window.h" |
| 14 #include "components/mus/public/cpp/window_observer.h" | 14 #include "components/mus/public/cpp/window_observer.h" |
| 15 #include "components/mus/public/cpp/window_property.h" | 15 #include "components/mus/public/cpp/window_property.h" |
| 16 #include "components/mus/public/cpp/window_tree_client.h" | 16 #include "components/mus/public/cpp/window_tree_client.h" |
| 17 #include "components/mus/public/interfaces/cursor.mojom.h" | 17 #include "components/mus/public/interfaces/cursor.mojom.h" |
| 18 #include "components/mus/public/interfaces/window_manager.mojom.h" | 18 #include "components/mus/public/interfaces/window_manager.mojom.h" |
| 19 #include "components/mus/public/interfaces/window_manager_constants.mojom.h" | 19 #include "components/mus/public/interfaces/window_manager_constants.mojom.h" |
| 20 #include "components/mus/public/interfaces/window_tree.mojom.h" | 20 #include "components/mus/public/interfaces/window_tree.mojom.h" |
| 21 #include "ui/aura/client/default_capture_client.h" | 21 #include "ui/aura/client/default_capture_client.h" |
| 22 #include "ui/aura/client/window_tree_client.h" | 22 #include "ui/aura/client/window_tree_client.h" |
| 23 #include "ui/aura/env.h" | 23 #include "ui/aura/env.h" |
| 24 #include "ui/aura/layout_manager.h" | 24 #include "ui/aura/layout_manager.h" |
| 25 #include "ui/aura/mus/mus_util.h" | 25 #include "ui/aura/mus/mus_util.h" |
| 26 #include "ui/aura/window.h" | 26 #include "ui/aura/window.h" |
| 27 #include "ui/aura/window_property.h" | 27 #include "ui/aura/window_property.h" |
| 28 #include "ui/base/hit_test.h" | 28 #include "ui/base/hit_test.h" |
| 29 #include "ui/base/view_prop.h" | 29 #include "ui/base/view_prop.h" |
| 30 #include "ui/display/display.h" | |
| 31 #include "ui/display/screen.h" | |
| 30 #include "ui/events/event.h" | 32 #include "ui/events/event.h" |
| 31 #include "ui/gfx/canvas.h" | 33 #include "ui/gfx/canvas.h" |
| 32 #include "ui/gfx/path.h" | 34 #include "ui/gfx/path.h" |
| 33 #include "ui/native_theme/native_theme_aura.h" | 35 #include "ui/native_theme/native_theme_aura.h" |
| 34 #include "ui/platform_window/platform_window_delegate.h" | 36 #include "ui/platform_window/platform_window_delegate.h" |
| 35 #include "ui/views/mus/surface_context_factory.h" | 37 #include "ui/views/mus/surface_context_factory.h" |
| 36 #include "ui/views/mus/window_manager_constants_converters.h" | 38 #include "ui/views/mus/window_manager_constants_converters.h" |
| 37 #include "ui/views/mus/window_manager_frame_values.h" | 39 #include "ui/views/mus/window_manager_frame_values.h" |
| 38 #include "ui/views/mus/window_tree_host_mus.h" | 40 #include "ui/views/mus/window_tree_host_mus.h" |
| 39 #include "ui/views/widget/native_widget_aura.h" | 41 #include "ui/views/widget/native_widget_aura.h" |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 810 } | 812 } |
| 811 | 813 |
| 812 ui::InputMethod* NativeWidgetMus::GetInputMethod() { | 814 ui::InputMethod* NativeWidgetMus::GetInputMethod() { |
| 813 return window_tree_host_ ? window_tree_host_->GetInputMethod() : nullptr; | 815 return window_tree_host_ ? window_tree_host_->GetInputMethod() : nullptr; |
| 814 } | 816 } |
| 815 | 817 |
| 816 void NativeWidgetMus::CenterWindow(const gfx::Size& size) { | 818 void NativeWidgetMus::CenterWindow(const gfx::Size& size) { |
| 817 // TODO(beng): clear user-placed property and set preferred size property. | 819 // TODO(beng): clear user-placed property and set preferred size property. |
| 818 window_->SetSharedProperty<gfx::Size>( | 820 window_->SetSharedProperty<gfx::Size>( |
| 819 mus::mojom::WindowManager::kPreferredSize_Property, size); | 821 mus::mojom::WindowManager::kPreferredSize_Property, size); |
| 822 | |
| 823 gfx::Rect bounds = display::Screen::GetScreen() | |
| 824 ->GetDisplayNearestWindow(content_) | |
| 825 .work_area(); | |
| 826 bounds.ClampToCenteredSize(size); | |
| 827 content_->SetBounds(bounds); | |
|
sky
2016/06/08 04:25:02
This makes me nervous.
Setting the bounds of the c
sadrul
2016/06/08 14:57:42
Done.
| |
| 820 } | 828 } |
| 821 | 829 |
| 822 void NativeWidgetMus::GetWindowPlacement( | 830 void NativeWidgetMus::GetWindowPlacement( |
| 823 gfx::Rect* bounds, | 831 gfx::Rect* bounds, |
| 824 ui::WindowShowState* maximized) const { | 832 ui::WindowShowState* maximized) const { |
| 825 // NOTIMPLEMENTED(); | 833 // NOTIMPLEMENTED(); |
| 826 } | 834 } |
| 827 | 835 |
| 828 bool NativeWidgetMus::SetWindowTitle(const base::string16& title) { | 836 bool NativeWidgetMus::SetWindowTitle(const base::string16& title) { |
| 829 if (!window_) | 837 if (!window_) |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1369 | 1377 |
| 1370 gfx::Path mask_path; | 1378 gfx::Path mask_path; |
| 1371 native_widget_delegate_->GetHitTestMask(&mask_path); | 1379 native_widget_delegate_->GetHitTestMask(&mask_path); |
| 1372 // TODO(jamescook): Use the full path for the mask. | 1380 // TODO(jamescook): Use the full path for the mask. |
| 1373 gfx::Rect mask_rect = | 1381 gfx::Rect mask_rect = |
| 1374 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); | 1382 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); |
| 1375 window_->SetHitTestMask(mask_rect); | 1383 window_->SetHitTestMask(mask_rect); |
| 1376 } | 1384 } |
| 1377 | 1385 |
| 1378 } // namespace views | 1386 } // namespace views |
| OLD | NEW |