Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ash/aura/wm_window_aura.h" | 5 #include "ash/aura/wm_window_aura.h" |
| 6 | 6 |
| 7 #include "ash/aura/aura_layout_manager_adapter.h" | 7 #include "ash/aura/aura_layout_manager_adapter.h" |
| 8 #include "ash/aura/wm_root_window_controller_aura.h" | 8 #include "ash/aura/wm_root_window_controller_aura.h" |
| 9 #include "ash/aura/wm_shell_aura.h" | 9 #include "ash/aura/wm_shell_aura.h" |
| 10 #include "ash/common/ash_constants.h" | 10 #include "ash/common/ash_constants.h" |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 #include "ui/display/screen.h" | 38 #include "ui/display/screen.h" |
| 39 #include "ui/gfx/geometry/insets.h" | 39 #include "ui/gfx/geometry/insets.h" |
| 40 #include "ui/views/widget/widget.h" | 40 #include "ui/views/widget/widget.h" |
| 41 #include "ui/views/widget/widget_delegate.h" | 41 #include "ui/views/widget/widget_delegate.h" |
| 42 #include "ui/wm/core/coordinate_conversion.h" | 42 #include "ui/wm/core/coordinate_conversion.h" |
| 43 #include "ui/wm/core/easy_resize_window_targeter.h" | 43 #include "ui/wm/core/easy_resize_window_targeter.h" |
| 44 #include "ui/wm/core/transient_window_manager.h" | 44 #include "ui/wm/core/transient_window_manager.h" |
| 45 #include "ui/wm/core/visibility_controller.h" | 45 #include "ui/wm/core/visibility_controller.h" |
| 46 #include "ui/wm/core/window_util.h" | 46 #include "ui/wm/core/window_util.h" |
| 47 | 47 |
| 48 DECLARE_WINDOW_PROPERTY_TYPE(ash::ShelfItemDetails*); | |
| 49 DECLARE_WINDOW_PROPERTY_TYPE(ash::WmWindowAura*); | 48 DECLARE_WINDOW_PROPERTY_TYPE(ash::WmWindowAura*); |
| 50 | 49 |
| 51 namespace ash { | 50 namespace ash { |
| 52 | 51 |
| 53 DEFINE_WINDOW_PROPERTY_KEY(ShelfID, kShelfIDKey, kInvalidShelfID); | 52 DEFINE_WINDOW_PROPERTY_KEY(ShelfID, kShelfIDKey, kInvalidShelfID); |
| 53 DEFINE_WINDOW_PROPERTY_KEY(int, kShelfItemTypeKey, TYPE_UNDEFINED); | |
| 54 DEFINE_WINDOW_PROPERTY_KEY(int, kShelfIconIdKey, kInvalidImageResourceID); | |
|
James Cook
2016/09/28 20:41:03
So on aura, GetWindowProperty(kShelfIconIdKey) for
msw
2016/09/28 23:27:46
Yes, for now mash relies on ShelfWindowWatcher for
| |
| 54 | 55 |
| 55 DEFINE_OWNED_WINDOW_PROPERTY_KEY(ShelfItemDetails, | |
| 56 kShelfItemDetailsKey, | |
| 57 nullptr); | |
| 58 DEFINE_OWNED_WINDOW_PROPERTY_KEY(WmWindowAura, kWmWindowKey, nullptr); | 56 DEFINE_OWNED_WINDOW_PROPERTY_KEY(WmWindowAura, kWmWindowKey, nullptr); |
| 59 | 57 |
| 60 static_assert(aura::Window::kInitialId == kShellWindowId_Invalid, | 58 static_assert(aura::Window::kInitialId == kShellWindowId_Invalid, |
| 61 "ids must match"); | 59 "ids must match"); |
| 62 | 60 |
| 63 namespace { | 61 namespace { |
| 64 | 62 |
| 65 // A tentative class to set the bounds on the window. | 63 // A tentative class to set the bounds on the window. |
| 66 // TODO(oshima): Once all logic is cleaned up, move this to the real layout | 64 // TODO(oshima): Once all logic is cleaned up, move this to the real layout |
| 67 // manager with proper friendship. | 65 // manager with proper friendship. |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 } | 159 } |
| 162 | 160 |
| 163 void WmWindowAura::SetName(const char* name) { | 161 void WmWindowAura::SetName(const char* name) { |
| 164 window_->SetName(name); | 162 window_->SetName(name); |
| 165 } | 163 } |
| 166 | 164 |
| 167 std::string WmWindowAura::GetName() const { | 165 std::string WmWindowAura::GetName() const { |
| 168 return window_->name(); | 166 return window_->name(); |
| 169 } | 167 } |
| 170 | 168 |
| 169 void WmWindowAura::SetTitle(const base::string16& title) { | |
| 170 window_->SetTitle(title); | |
| 171 } | |
| 172 | |
| 171 base::string16 WmWindowAura::GetTitle() const { | 173 base::string16 WmWindowAura::GetTitle() const { |
| 172 return window_->title(); | 174 return window_->title(); |
| 173 } | 175 } |
| 174 | 176 |
| 175 void WmWindowAura::SetShellWindowId(int id) { | 177 void WmWindowAura::SetShellWindowId(int id) { |
| 176 window_->set_id(id); | 178 window_->set_id(id); |
| 177 } | 179 } |
| 178 | 180 |
| 179 int WmWindowAura::GetShellWindowId() const { | 181 int WmWindowAura::GetShellWindowId() const { |
| 180 return window_->id(); | 182 return window_->id(); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 return; | 311 return; |
| 310 } | 312 } |
| 311 | 313 |
| 312 NOTREACHED(); | 314 NOTREACHED(); |
| 313 } | 315 } |
| 314 | 316 |
| 315 int WmWindowAura::GetIntProperty(WmWindowProperty key) { | 317 int WmWindowAura::GetIntProperty(WmWindowProperty key) { |
| 316 if (key == WmWindowProperty::MODAL_TYPE) | 318 if (key == WmWindowProperty::MODAL_TYPE) |
| 317 return window_->GetProperty(aura::client::kModalKey); | 319 return window_->GetProperty(aura::client::kModalKey); |
| 318 | 320 |
| 321 if (key == WmWindowProperty::SHELF_ICON_ID) | |
| 322 return window_->GetProperty(kShelfIconIdKey); | |
| 323 | |
| 319 if (key == WmWindowProperty::SHELF_ID) | 324 if (key == WmWindowProperty::SHELF_ID) |
| 320 return window_->GetProperty(kShelfIDKey); | 325 return window_->GetProperty(kShelfIDKey); |
| 321 | 326 |
| 327 if (key == WmWindowProperty::SHELF_ITEM_TYPE) | |
| 328 return window_->GetProperty(kShelfItemTypeKey); | |
| 329 | |
| 322 if (key == WmWindowProperty::TOP_VIEW_INSET) | 330 if (key == WmWindowProperty::TOP_VIEW_INSET) |
| 323 return window_->GetProperty(aura::client::kTopViewInset); | 331 return window_->GetProperty(aura::client::kTopViewInset); |
| 324 | 332 |
| 325 NOTREACHED(); | 333 NOTREACHED(); |
| 326 return 0; | 334 return 0; |
| 327 } | 335 } |
| 328 | 336 |
| 329 void WmWindowAura::SetIntProperty(WmWindowProperty key, int value) { | 337 void WmWindowAura::SetIntProperty(WmWindowProperty key, int value) { |
| 338 if (key == WmWindowProperty::SHELF_ICON_ID) { | |
| 339 window_->SetProperty(kShelfIconIdKey, value); | |
| 340 return; | |
| 341 } | |
| 330 if (key == WmWindowProperty::SHELF_ID) { | 342 if (key == WmWindowProperty::SHELF_ID) { |
| 331 window_->SetProperty(kShelfIDKey, value); | 343 window_->SetProperty(kShelfIDKey, value); |
| 332 return; | 344 return; |
| 333 } | 345 } |
| 346 if (key == WmWindowProperty::SHELF_ITEM_TYPE) { | |
| 347 window_->SetProperty(kShelfItemTypeKey, value); | |
| 348 return; | |
| 349 } | |
| 334 if (key == WmWindowProperty::TOP_VIEW_INSET) { | 350 if (key == WmWindowProperty::TOP_VIEW_INSET) { |
| 335 window_->SetProperty(aura::client::kTopViewInset, value); | 351 window_->SetProperty(aura::client::kTopViewInset, value); |
| 336 return; | 352 return; |
| 337 } | 353 } |
| 338 | 354 |
| 339 NOTREACHED(); | 355 NOTREACHED(); |
| 340 } | 356 } |
| 341 | 357 |
| 342 ShelfItemDetails* WmWindowAura::GetShelfItemDetails() { | |
| 343 return window_->GetProperty(kShelfItemDetailsKey); | |
| 344 } | |
| 345 | |
| 346 void WmWindowAura::SetShelfItemDetails(const ShelfItemDetails& details) { | |
| 347 // |item_details| is owned by |window_|. | |
| 348 ShelfItemDetails* item_details = new ShelfItemDetails(details); | |
| 349 window_->SetProperty(kShelfItemDetailsKey, item_details); | |
| 350 } | |
| 351 | |
| 352 void WmWindowAura::ClearShelfItemDetails() { | |
| 353 window_->ClearProperty(kShelfItemDetailsKey); | |
| 354 } | |
| 355 | |
| 356 const wm::WindowState* WmWindowAura::GetWindowState() const { | 358 const wm::WindowState* WmWindowAura::GetWindowState() const { |
| 357 return ash::wm::GetWindowState(window_); | 359 return ash::wm::GetWindowState(window_); |
| 358 } | 360 } |
| 359 | 361 |
| 360 WmWindow* WmWindowAura::GetToplevelWindow() { | 362 WmWindow* WmWindowAura::GetToplevelWindow() { |
| 361 return Get(window_->GetToplevelWindow()); | 363 return Get(window_->GetToplevelWindow()); |
| 362 } | 364 } |
| 363 | 365 |
| 364 WmWindow* WmWindowAura::GetToplevelWindowForFocus() { | 366 WmWindow* WmWindowAura::GetToplevelWindowForFocus() { |
| 365 return Get(::wm::GetToplevelWindow(window_)); | 367 return Get(::wm::GetToplevelWindow(window_)); |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 811 ash::wm::GetWindowState(window_)->OnWindowShowStateChanged(); | 813 ash::wm::GetWindowState(window_)->OnWindowShowStateChanged(); |
| 812 return; | 814 return; |
| 813 } | 815 } |
| 814 WmWindowProperty wm_property; | 816 WmWindowProperty wm_property; |
| 815 if (key == aura::client::kAlwaysOnTopKey) { | 817 if (key == aura::client::kAlwaysOnTopKey) { |
| 816 wm_property = WmWindowProperty::ALWAYS_ON_TOP; | 818 wm_property = WmWindowProperty::ALWAYS_ON_TOP; |
| 817 } else if (key == aura::client::kExcludeFromMruKey) { | 819 } else if (key == aura::client::kExcludeFromMruKey) { |
| 818 wm_property = WmWindowProperty::EXCLUDE_FROM_MRU; | 820 wm_property = WmWindowProperty::EXCLUDE_FROM_MRU; |
| 819 } else if (key == aura::client::kModalKey) { | 821 } else if (key == aura::client::kModalKey) { |
| 820 wm_property = WmWindowProperty::MODAL_TYPE; | 822 wm_property = WmWindowProperty::MODAL_TYPE; |
| 823 } else if (key == kShelfIconIdKey) { | |
| 824 wm_property = WmWindowProperty::SHELF_ICON_ID; | |
| 821 } else if (key == kShelfIDKey) { | 825 } else if (key == kShelfIDKey) { |
| 822 wm_property = WmWindowProperty::SHELF_ID; | 826 wm_property = WmWindowProperty::SHELF_ID; |
| 823 } else if (key == kShelfItemDetailsKey) { | 827 } else if (key == kShelfItemTypeKey) { |
| 824 wm_property = WmWindowProperty::SHELF_ITEM_DETAILS; | 828 wm_property = WmWindowProperty::SHELF_ITEM_TYPE; |
| 825 } else if (key == kSnapChildrenToPixelBoundary) { | 829 } else if (key == kSnapChildrenToPixelBoundary) { |
| 826 wm_property = WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY; | 830 wm_property = WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY; |
| 827 } else if (key == aura::client::kTopViewInset) { | 831 } else if (key == aura::client::kTopViewInset) { |
| 828 wm_property = WmWindowProperty::TOP_VIEW_INSET; | 832 wm_property = WmWindowProperty::TOP_VIEW_INSET; |
| 829 } else { | 833 } else { |
| 830 return; | 834 return; |
| 831 } | 835 } |
| 832 FOR_EACH_OBSERVER(WmWindowObserver, observers_, | 836 FOR_EACH_OBSERVER(WmWindowObserver, observers_, |
| 833 OnWindowPropertyChanged(this, wm_property)); | 837 OnWindowPropertyChanged(this, wm_property)); |
| 834 } | 838 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 870 OnTransientChildAdded(this, Get(transient))); | 874 OnTransientChildAdded(this, Get(transient))); |
| 871 } | 875 } |
| 872 | 876 |
| 873 void WmWindowAura::OnTransientChildRemoved(aura::Window* window, | 877 void WmWindowAura::OnTransientChildRemoved(aura::Window* window, |
| 874 aura::Window* transient) { | 878 aura::Window* transient) { |
| 875 FOR_EACH_OBSERVER(WmTransientWindowObserver, transient_observers_, | 879 FOR_EACH_OBSERVER(WmTransientWindowObserver, transient_observers_, |
| 876 OnTransientChildRemoved(this, Get(transient))); | 880 OnTransientChildRemoved(this, Get(transient))); |
| 877 } | 881 } |
| 878 | 882 |
| 879 } // namespace ash | 883 } // namespace ash |
| OLD | NEW |