| 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/views/widget/native_widget_aura.h" | 5 #include "ui/views/widget/native_widget_aura.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "services/ui/public/interfaces/window_manager.mojom.h" | 14 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| 15 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" | 15 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" |
| 16 #include "third_party/skia/include/core/SkRegion.h" | 16 #include "third_party/skia/include/core/SkRegion.h" |
| 17 #include "ui/aura/client/aura_constants.h" | 17 #include "ui/aura/client/aura_constants.h" |
| 18 #include "ui/aura/client/capture_client.h" | 18 #include "ui/aura/client/capture_client.h" |
| 19 #include "ui/aura/client/cursor_client.h" | 19 #include "ui/aura/client/cursor_client.h" |
| 20 #include "ui/aura/client/drag_drop_client.h" | 20 #include "ui/aura/client/drag_drop_client.h" |
| 21 #include "ui/aura/client/focus_client.h" | 21 #include "ui/aura/client/focus_client.h" |
| 22 #include "ui/aura/client/screen_position_client.h" | 22 #include "ui/aura/client/screen_position_client.h" |
| 23 #include "ui/aura/client/window_parenting_client.h" | 23 #include "ui/aura/client/window_parenting_client.h" |
| 24 #include "ui/aura/env.h" | 24 #include "ui/aura/env.h" |
| 25 #include "ui/aura/window.h" | 25 #include "ui/aura/window.h" |
| 26 #include "ui/aura/window_event_dispatcher.h" | 26 #include "ui/aura/window_event_dispatcher.h" |
| 27 #include "ui/aura/window_observer.h" | 27 #include "ui/aura/window_observer.h" |
| 28 #include "ui/aura/window_property.h" |
| 28 #include "ui/aura/window_tree_host.h" | 29 #include "ui/aura/window_tree_host.h" |
| 29 #include "ui/base/dragdrop/os_exchange_data.h" | 30 #include "ui/base/dragdrop/os_exchange_data.h" |
| 30 #include "ui/base/ui_base_types.h" | 31 #include "ui/base/ui_base_types.h" |
| 31 #include "ui/compositor/layer.h" | 32 #include "ui/compositor/layer.h" |
| 32 #include "ui/display/display.h" | 33 #include "ui/display/display.h" |
| 33 #include "ui/display/screen.h" | 34 #include "ui/display/screen.h" |
| 34 #include "ui/events/event.h" | 35 #include "ui/events/event.h" |
| 35 #include "ui/gfx/canvas.h" | 36 #include "ui/gfx/canvas.h" |
| 36 #include "ui/gfx/font_list.h" | 37 #include "ui/gfx/font_list.h" |
| 37 #include "ui/native_theme/native_theme_aura.h" | 38 #include "ui/native_theme/native_theme_aura.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 62 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 63 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 63 #include "ui/views/linux_ui/linux_ui.h" | 64 #include "ui/views/linux_ui/linux_ui.h" |
| 64 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" | 65 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" |
| 65 #endif | 66 #endif |
| 66 | 67 |
| 67 #if !defined(OS_CHROMEOS) | 68 #if !defined(OS_CHROMEOS) |
| 68 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 69 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 69 #include "ui/views/widget/desktop_aura/desktop_window_tree_host.h" | 70 #include "ui/views/widget/desktop_aura/desktop_window_tree_host.h" |
| 70 #endif | 71 #endif |
| 71 | 72 |
| 73 DECLARE_WINDOW_PROPERTY_TYPE(views::internal::NativeWidgetPrivate*) |
| 74 |
| 72 namespace views { | 75 namespace views { |
| 73 | 76 |
| 74 namespace { | 77 namespace { |
| 75 | 78 |
| 79 DEFINE_WINDOW_PROPERTY_KEY(internal::NativeWidgetPrivate*, |
| 80 kNativeWidgetPrivateKey, |
| 81 nullptr); |
| 82 |
| 76 void SetRestoreBounds(aura::Window* window, const gfx::Rect& bounds) { | 83 void SetRestoreBounds(aura::Window* window, const gfx::Rect& bounds) { |
| 77 window->SetProperty(aura::client::kRestoreBoundsKey, new gfx::Rect(bounds)); | 84 window->SetProperty(aura::client::kRestoreBoundsKey, new gfx::Rect(bounds)); |
| 78 } | 85 } |
| 79 | 86 |
| 80 void SetIcon(aura::Window* window, | 87 void SetIcon(aura::Window* window, |
| 81 const aura::WindowProperty<gfx::ImageSkia*>* key, | 88 const aura::WindowProperty<gfx::ImageSkia*>* key, |
| 82 const gfx::ImageSkia& value) { | 89 const gfx::ImageSkia& value) { |
| 83 if (value.isNull()) | 90 if (value.isNull()) |
| 84 window->ClearProperty(key); | 91 window->ClearProperty(key); |
| 85 else | 92 else |
| (...skipping 17 matching lines...) Expand all Loading... |
| 103 saved_window_state_(ui::SHOW_STATE_DEFAULT), | 110 saved_window_state_(ui::SHOW_STATE_DEFAULT), |
| 104 close_widget_factory_(this) { | 111 close_widget_factory_(this) { |
| 105 aura::client::SetFocusChangeObserver(window_, this); | 112 aura::client::SetFocusChangeObserver(window_, this); |
| 106 aura::client::SetActivationChangeObserver(window_, this); | 113 aura::client::SetActivationChangeObserver(window_, this); |
| 107 } | 114 } |
| 108 | 115 |
| 109 // static | 116 // static |
| 110 void NativeWidgetAura::RegisterNativeWidgetForWindow( | 117 void NativeWidgetAura::RegisterNativeWidgetForWindow( |
| 111 internal::NativeWidgetPrivate* native_widget, | 118 internal::NativeWidgetPrivate* native_widget, |
| 112 aura::Window* window) { | 119 aura::Window* window) { |
| 113 window->set_user_data(native_widget); | 120 window->SetProperty(kNativeWidgetPrivateKey, native_widget); |
| 114 } | 121 } |
| 115 | 122 |
| 116 // static | 123 // static |
| 117 void NativeWidgetAura::AssignIconToAuraWindow(aura::Window* window, | 124 void NativeWidgetAura::AssignIconToAuraWindow(aura::Window* window, |
| 118 const gfx::ImageSkia& window_icon, | 125 const gfx::ImageSkia& window_icon, |
| 119 const gfx::ImageSkia& app_icon) { | 126 const gfx::ImageSkia& app_icon) { |
| 120 if (window) { | 127 if (window) { |
| 121 SetIcon(window, aura::client::kWindowIconKey, window_icon); | 128 SetIcon(window, aura::client::kWindowIconKey, window_icon); |
| 122 SetIcon(window, aura::client::kAppIconKey, app_icon); | 129 SetIcon(window, aura::client::kAppIconKey, app_icon); |
| 123 } | 130 } |
| (...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 | 1101 |
| 1095 // static | 1102 // static |
| 1096 NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget( | 1103 NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget( |
| 1097 internal::NativeWidgetDelegate* delegate) { | 1104 internal::NativeWidgetDelegate* delegate) { |
| 1098 return new NativeWidgetAura(delegate); | 1105 return new NativeWidgetAura(delegate); |
| 1099 } | 1106 } |
| 1100 | 1107 |
| 1101 // static | 1108 // static |
| 1102 NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeView( | 1109 NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeView( |
| 1103 gfx::NativeView native_view) { | 1110 gfx::NativeView native_view) { |
| 1104 // Cast must match type supplied to RegisterNativeWidgetForWindow(). | 1111 return native_view->GetProperty(kNativeWidgetPrivateKey); |
| 1105 return reinterpret_cast<NativeWidgetPrivate*>(native_view->user_data()); | |
| 1106 } | 1112 } |
| 1107 | 1113 |
| 1108 // static | 1114 // static |
| 1109 NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeWindow( | 1115 NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeWindow( |
| 1110 gfx::NativeWindow native_window) { | 1116 gfx::NativeWindow native_window) { |
| 1111 // Cast must match type supplied to RegisterNativeWidgetForWindow(). | 1117 return native_window->GetProperty(kNativeWidgetPrivateKey); |
| 1112 return reinterpret_cast<NativeWidgetPrivate*>(native_window->user_data()); | |
| 1113 } | 1118 } |
| 1114 | 1119 |
| 1115 // static | 1120 // static |
| 1116 NativeWidgetPrivate* NativeWidgetPrivate::GetTopLevelNativeWidget( | 1121 NativeWidgetPrivate* NativeWidgetPrivate::GetTopLevelNativeWidget( |
| 1117 gfx::NativeView native_view) { | 1122 gfx::NativeView native_view) { |
| 1118 aura::Window* window = native_view; | 1123 aura::Window* window = native_view; |
| 1119 NativeWidgetPrivate* top_level_native_widget = NULL; | 1124 NativeWidgetPrivate* top_level_native_widget = NULL; |
| 1120 while (window) { | 1125 while (window) { |
| 1121 NativeWidgetPrivate* native_widget = GetNativeWidgetForNativeView(window); | 1126 NativeWidgetPrivate* native_widget = GetNativeWidgetForNativeView(window); |
| 1122 if (native_widget) | 1127 if (native_widget) |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 gfx::NativeView native_view) { | 1234 gfx::NativeView native_view) { |
| 1230 aura::client::CaptureClient* capture_client = | 1235 aura::client::CaptureClient* capture_client = |
| 1231 aura::client::GetCaptureClient(native_view->GetRootWindow()); | 1236 aura::client::GetCaptureClient(native_view->GetRootWindow()); |
| 1232 if (!capture_client) | 1237 if (!capture_client) |
| 1233 return nullptr; | 1238 return nullptr; |
| 1234 return capture_client->GetGlobalCaptureWindow(); | 1239 return capture_client->GetGlobalCaptureWindow(); |
| 1235 } | 1240 } |
| 1236 | 1241 |
| 1237 } // namespace internal | 1242 } // namespace internal |
| 1238 } // namespace views | 1243 } // namespace views |
| OLD | NEW |