Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(768)

Side by Side Diff: ash/aura/wm_window_aura.cc

Issue 2357143004: mash: Support ShelfWindowWatcher via ShelfItem properties. (Closed)
Patch Set: Address comments. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/aura/wm_window_aura.h ('k') | ash/common/shelf/shelf_constants.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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,
55 kShelfIconResourceIdKey,
56 kInvalidImageResourceID);
54 57
55 DEFINE_OWNED_WINDOW_PROPERTY_KEY(ShelfItemDetails,
56 kShelfItemDetailsKey,
57 nullptr);
58 DEFINE_OWNED_WINDOW_PROPERTY_KEY(WmWindowAura, kWmWindowKey, nullptr); 58 DEFINE_OWNED_WINDOW_PROPERTY_KEY(WmWindowAura, kWmWindowKey, nullptr);
59 59
60 static_assert(aura::Window::kInitialId == kShellWindowId_Invalid, 60 static_assert(aura::Window::kInitialId == kShellWindowId_Invalid,
61 "ids must match"); 61 "ids must match");
62 62
63 namespace { 63 namespace {
64 64
65 // A tentative class to set the bounds on the window. 65 // 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 66 // TODO(oshima): Once all logic is cleaned up, move this to the real layout
67 // manager with proper friendship. 67 // manager with proper friendship.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 161 }
162 162
163 void WmWindowAura::SetName(const char* name) { 163 void WmWindowAura::SetName(const char* name) {
164 window_->SetName(name); 164 window_->SetName(name);
165 } 165 }
166 166
167 std::string WmWindowAura::GetName() const { 167 std::string WmWindowAura::GetName() const {
168 return window_->name(); 168 return window_->name();
169 } 169 }
170 170
171 void WmWindowAura::SetTitle(const base::string16& title) {
172 window_->SetTitle(title);
173 }
174
171 base::string16 WmWindowAura::GetTitle() const { 175 base::string16 WmWindowAura::GetTitle() const {
172 return window_->title(); 176 return window_->title();
173 } 177 }
174 178
175 void WmWindowAura::SetShellWindowId(int id) { 179 void WmWindowAura::SetShellWindowId(int id) {
176 window_->set_id(id); 180 window_->set_id(id);
177 } 181 }
178 182
179 int WmWindowAura::GetShellWindowId() const { 183 int WmWindowAura::GetShellWindowId() const {
180 return window_->id(); 184 return window_->id();
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 return; 313 return;
310 } 314 }
311 315
312 NOTREACHED(); 316 NOTREACHED();
313 } 317 }
314 318
315 int WmWindowAura::GetIntProperty(WmWindowProperty key) { 319 int WmWindowAura::GetIntProperty(WmWindowProperty key) {
316 if (key == WmWindowProperty::MODAL_TYPE) 320 if (key == WmWindowProperty::MODAL_TYPE)
317 return window_->GetProperty(aura::client::kModalKey); 321 return window_->GetProperty(aura::client::kModalKey);
318 322
323 if (key == WmWindowProperty::SHELF_ICON_RESOURCE_ID)
324 return window_->GetProperty(kShelfIconResourceIdKey);
325
319 if (key == WmWindowProperty::SHELF_ID) 326 if (key == WmWindowProperty::SHELF_ID)
320 return window_->GetProperty(kShelfIDKey); 327 return window_->GetProperty(kShelfIDKey);
321 328
329 if (key == WmWindowProperty::SHELF_ITEM_TYPE)
330 return window_->GetProperty(kShelfItemTypeKey);
331
322 if (key == WmWindowProperty::TOP_VIEW_INSET) 332 if (key == WmWindowProperty::TOP_VIEW_INSET)
323 return window_->GetProperty(aura::client::kTopViewInset); 333 return window_->GetProperty(aura::client::kTopViewInset);
324 334
325 NOTREACHED(); 335 NOTREACHED();
326 return 0; 336 return 0;
327 } 337 }
328 338
329 void WmWindowAura::SetIntProperty(WmWindowProperty key, int value) { 339 void WmWindowAura::SetIntProperty(WmWindowProperty key, int value) {
340 if (key == WmWindowProperty::SHELF_ICON_RESOURCE_ID) {
341 window_->SetProperty(kShelfIconResourceIdKey, value);
342 return;
343 }
330 if (key == WmWindowProperty::SHELF_ID) { 344 if (key == WmWindowProperty::SHELF_ID) {
331 window_->SetProperty(kShelfIDKey, value); 345 window_->SetProperty(kShelfIDKey, value);
332 return; 346 return;
333 } 347 }
348 if (key == WmWindowProperty::SHELF_ITEM_TYPE) {
349 window_->SetProperty(kShelfItemTypeKey, value);
350 return;
351 }
334 if (key == WmWindowProperty::TOP_VIEW_INSET) { 352 if (key == WmWindowProperty::TOP_VIEW_INSET) {
335 window_->SetProperty(aura::client::kTopViewInset, value); 353 window_->SetProperty(aura::client::kTopViewInset, value);
336 return; 354 return;
337 } 355 }
338 356
339 NOTREACHED(); 357 NOTREACHED();
340 } 358 }
341 359
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 { 360 const wm::WindowState* WmWindowAura::GetWindowState() const {
357 return ash::wm::GetWindowState(window_); 361 return ash::wm::GetWindowState(window_);
358 } 362 }
359 363
360 WmWindow* WmWindowAura::GetToplevelWindow() { 364 WmWindow* WmWindowAura::GetToplevelWindow() {
361 return Get(window_->GetToplevelWindow()); 365 return Get(window_->GetToplevelWindow());
362 } 366 }
363 367
364 WmWindow* WmWindowAura::GetToplevelWindowForFocus() { 368 WmWindow* WmWindowAura::GetToplevelWindowForFocus() {
365 return Get(::wm::GetToplevelWindow(window_)); 369 return Get(::wm::GetToplevelWindow(window_));
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 ash::wm::GetWindowState(window_)->OnWindowShowStateChanged(); 822 ash::wm::GetWindowState(window_)->OnWindowShowStateChanged();
819 return; 823 return;
820 } 824 }
821 WmWindowProperty wm_property; 825 WmWindowProperty wm_property;
822 if (key == aura::client::kAlwaysOnTopKey) { 826 if (key == aura::client::kAlwaysOnTopKey) {
823 wm_property = WmWindowProperty::ALWAYS_ON_TOP; 827 wm_property = WmWindowProperty::ALWAYS_ON_TOP;
824 } else if (key == aura::client::kExcludeFromMruKey) { 828 } else if (key == aura::client::kExcludeFromMruKey) {
825 wm_property = WmWindowProperty::EXCLUDE_FROM_MRU; 829 wm_property = WmWindowProperty::EXCLUDE_FROM_MRU;
826 } else if (key == aura::client::kModalKey) { 830 } else if (key == aura::client::kModalKey) {
827 wm_property = WmWindowProperty::MODAL_TYPE; 831 wm_property = WmWindowProperty::MODAL_TYPE;
832 } else if (key == kShelfIconResourceIdKey) {
833 wm_property = WmWindowProperty::SHELF_ICON_RESOURCE_ID;
828 } else if (key == kShelfIDKey) { 834 } else if (key == kShelfIDKey) {
829 wm_property = WmWindowProperty::SHELF_ID; 835 wm_property = WmWindowProperty::SHELF_ID;
830 } else if (key == kShelfItemDetailsKey) { 836 } else if (key == kShelfItemTypeKey) {
831 wm_property = WmWindowProperty::SHELF_ITEM_DETAILS; 837 wm_property = WmWindowProperty::SHELF_ITEM_TYPE;
832 } else if (key == kSnapChildrenToPixelBoundary) { 838 } else if (key == kSnapChildrenToPixelBoundary) {
833 wm_property = WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY; 839 wm_property = WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY;
834 } else if (key == aura::client::kTopViewInset) { 840 } else if (key == aura::client::kTopViewInset) {
835 wm_property = WmWindowProperty::TOP_VIEW_INSET; 841 wm_property = WmWindowProperty::TOP_VIEW_INSET;
836 } else { 842 } else {
837 return; 843 return;
838 } 844 }
839 FOR_EACH_OBSERVER(WmWindowObserver, observers_, 845 FOR_EACH_OBSERVER(WmWindowObserver, observers_,
840 OnWindowPropertyChanged(this, wm_property)); 846 OnWindowPropertyChanged(this, wm_property));
841 } 847 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 OnTransientChildAdded(this, Get(transient))); 884 OnTransientChildAdded(this, Get(transient)));
879 } 885 }
880 886
881 void WmWindowAura::OnTransientChildRemoved(aura::Window* window, 887 void WmWindowAura::OnTransientChildRemoved(aura::Window* window,
882 aura::Window* transient) { 888 aura::Window* transient) {
883 FOR_EACH_OBSERVER(WmTransientWindowObserver, transient_observers_, 889 FOR_EACH_OBSERVER(WmTransientWindowObserver, transient_observers_,
884 OnTransientChildRemoved(this, Get(transient))); 890 OnTransientChildRemoved(this, Get(transient)));
885 } 891 }
886 892
887 } // namespace ash 893 } // namespace ash
OLDNEW
« no previous file with comments | « ash/aura/wm_window_aura.h ('k') | ash/common/shelf/shelf_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698